Sha256: 620442ca3d57a4a9ef46e72011773ee997fb33ee1fc6ce608ab18817216f8051

Contents?: true

Size: 824 Bytes

Versions: 7

Compression:

Stored size: 824 Bytes

Contents

# frozen_string_literal: true

require "onyphe"

module Mihari
  module Analyzers
    class Onyphe < Base
      attr_reader :api
      attr_reader :title
      attr_reader :description
      attr_reader :query
      attr_reader :tags

      def initialize(query, title: nil, description: nil, tags: [])
        super()

        @api = ::Onyphe::API.new
        @query = query
        @title = title || "Onyphe lookup"
        @description = description || "query = #{query}"
        @tags = tags
      end

      def artifacts
        result = search
        return [] unless result

        results = result.dig("results") || []
        results.map { |e| e.dig("ip") }.compact
      end

      private

      def search
        api.datascan(query)
      rescue ::Onyphe::Error => _e
        nil
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mihari-0.9.0 lib/mihari/analyzers/onyphe.rb
mihari-0.8.2 lib/mihari/analyzers/onyphe.rb
mihari-0.8.1 lib/mihari/analyzers/onyphe.rb
mihari-0.8.0 lib/mihari/analyzers/onyphe.rb
mihari-0.7.0 lib/mihari/analyzers/onyphe.rb
mihari-0.6.0 lib/mihari/analyzers/onyphe.rb
mihari-0.5.2 lib/mihari/analyzers/onyphe.rb