Sha256: ba13e9bffc85d415c484a00b27009487dbe4bec42d54d49a54d81e4aa6fabda6

Contents?: true

Size: 819 Bytes

Versions: 5

Compression:

Stored size: 819 Bytes

Contents

# frozen_string_literal: true

module Mihari
  module Analyzers
    class GreyNoise < 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.greynoise_api_key
      end

      def artifacts
        client.gnql_search_with_pagination(
          query,
          pagination_limit: pagination_limit
        ).map(&:artifacts).flatten
      end

      def configuration_keys
        %w[greynoise_api_key]
      end

      private

      def client
        @client ||= Clients::GreyNoise.new(api_key: api_key, interval: interval)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mihari-5.4.7 lib/mihari/analyzers/greynoise.rb
mihari-5.4.6 lib/mihari/analyzers/greynoise.rb
mihari-5.4.5 lib/mihari/analyzers/greynoise.rb
mihari-5.4.4 lib/mihari/analyzers/greynoise.rb
mihari-5.4.3 lib/mihari/analyzers/greynoise.rb