Sha256: 81548146b6179b0530afc7f944976a033b6543787bbfa1c00c9ba469e8e5f1fc

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

module Mihari
  module Analyzers
    class BinaryEdge < Base
      # @return [String, nil]
      attr_reader :api_key

      #
      # @param [String] query
      # @param [Hash, nil] options
      # @param [String, nil] api_key
      #
      def initialize(query, options: nil, api_key: nil)
        super(query, options: options)

        @api_key = api_key || Mihari.config.binaryedge_api_key
      end

      def artifacts
        client.search_with_pagination(query, pagination_limit: pagination_limit).map do |res|
          events = res["events"] || []
          events.filter_map do |event|
            data = event.dig("target", "ip")
            data.nil? ? nil : Artifact.new(data: data, source: source, metadata: event)
          end
        end
      end

      def configuration_keys
        %w[binaryedge_api_key]
      end

      private

      #
      #
      # @return [Mihari::Clients::BinaryEdge]
      #
      def client
        @client ||= Clients::BinaryEdge.new(api_key: api_key, interval: interval)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mihari-5.4.3 lib/mihari/analyzers/binaryedge.rb