Sha256: 99e1309d054148cab301c181cc899840a83514e19b68b6215bb40d9f8092f05d

Contents?: true

Size: 1.24 KB

Versions: 7

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true

module Mihari
  module Analyzers
    #
    # VirusTotal Intelligence analyzer
    #
    class VirusTotalIntelligence < Base
      # @return [String, nil]
      attr_reader :api_key

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

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

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

      def configuration_keys
        %w[virustotal_api_key]
      end

      class << self
        #
        # @return [String]
        #
        def class_key
          "virustotal_intelligence"
        end

        #
        # @return [Array<String>, nil]
        #
        def class_key_aliases
          ["vt_intel"]
        end
      end

      private

      #
      # VT API
      #
      # @return [::VirusTotal::API]
      #
      def client
        Clients::VirusTotal.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/virustotal_intelligence.rb
mihari-6.2.0 lib/mihari/analyzers/virustotal_intelligence.rb
mihari-6.1.0 lib/mihari/analyzers/virustotal_intelligence.rb
mihari-6.0.0 lib/mihari/analyzers/virustotal_intelligence.rb
mihari-5.7.2 lib/mihari/analyzers/virustotal_intelligence.rb
mihari-5.7.1 lib/mihari/analyzers/virustotal_intelligence.rb
mihari-5.7.0 lib/mihari/analyzers/virustotal_intelligence.rb