Sha256: 57e5215922c82a40c7bc6ede19acc044ea5f1cd4e3adde9b36a9860d8675ca21

Contents?: true

Size: 924 Bytes

Versions: 7

Compression:

Stored size: 924 Bytes

Contents

# frozen_string_literal: true

module Mihari
  module Analyzers
    #
    # GreyNoise analyzer
    #
    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
        Clients::GreyNoise.new(
          api_key: api_key,
          pagination_interval: pagination_interval,
          timeout: timeout
        )
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mihari-6.3.0 lib/mihari/analyzers/greynoise.rb
mihari-6.2.0 lib/mihari/analyzers/greynoise.rb
mihari-6.1.0 lib/mihari/analyzers/greynoise.rb
mihari-6.0.0 lib/mihari/analyzers/greynoise.rb
mihari-5.7.2 lib/mihari/analyzers/greynoise.rb
mihari-5.7.1 lib/mihari/analyzers/greynoise.rb
mihari-5.7.0 lib/mihari/analyzers/greynoise.rb