Sha256: 2ec6e189aa7eabbddae66b2bcf5398e2942c3379f64446cd2493751f65f843b0

Contents?: true

Size: 1.31 KB

Versions: 4

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

module Mihari
  module Analyzers
    #
    # hunter.how analyzer
    #
    class HunterHow < Base
      # @return [String, nil]
      attr_reader :api_key

      # @return [Date]
      attr_reader :start_time

      # @return [Date]
      attr_reader :end_time

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

        @api_key = api_key || Mihari.config.hunterhow_api_key

        @start_time = start_time
        @end_time = end_time
      end

      #
      # @return [Array<Mihari::Models::Artifact>]
      #
      def artifacts
        client.search_with_pagination(
          query,
          start_time: start_time.strftime("%Y-%m-%d"),
          end_time: end_time.strftime("%Y-%m-%d")
        ).map do |res|
          res.data.artifacts
        end.flatten
      end

      def configuration_keys
        %w[hunterhow_api_key]
      end

      private

      def client
        Clients::HunterHow.new(
          api_key: api_key,
          pagination_interval: pagination_interval,
          timeout: timeout
        )
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mihari-6.0.0 lib/mihari/analyzers/hunterhow.rb
mihari-5.7.2 lib/mihari/analyzers/hunterhow.rb
mihari-5.7.1 lib/mihari/analyzers/hunterhow.rb
mihari-5.7.0 lib/mihari/analyzers/hunterhow.rb