Sha256: cb704a0b85c52c1d99d5db28e93b2d209f33c3e97948fc6399eda16ef477d492

Contents?: true

Size: 1.25 KB

Versions: 4

Compression:

Stored size: 1.25 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: nil, end_time: nil, 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

      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-7.3.2 lib/mihari/analyzers/hunterhow.rb
mihari-7.3.1 lib/mihari/analyzers/hunterhow.rb
mihari-7.3.0 lib/mihari/analyzers/hunterhow.rb
mihari-7.2.0 lib/mihari/analyzers/hunterhow.rb