Sha256: 4609f6cd97e3c505c95c8c7ab34fa4bb7c35e78a2916a60b26a18590962b933f

Contents?: true

Size: 1.12 KB

Versions: 10

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

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

      # @return [String, nil]
      attr_reader :email

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

        @api_key = api_key || Mihari.config.fofa_api_key
        @email = email || Mihari.config.fofa_email
      end

      def artifacts
        client.search_with_pagination(query, pagination_limit:).map do |res|
          (res.results || []).map { |result| result[1] }
        end.flatten.compact
      end

      def configured?
        api_key? && email?
      end

      private

      def email?
        !email.nil?
      end

      #
      # @return [Mihari::Clients::Fofa]
      #
      def client
        Clients::Fofa.new(
          api_key:,
          email:,
          pagination_interval:,
          timeout:
        )
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
mihari-8.0.2 lib/mihari/analyzers/fofa.rb
mihari-8.0.1 lib/mihari/analyzers/fofa.rb
mihari-8.0.0 lib/mihari/analyzers/fofa.rb
mihari-7.6.4 lib/mihari/analyzers/fofa.rb
mihari-7.6.3 lib/mihari/analyzers/fofa.rb
mihari-7.6.2 lib/mihari/analyzers/fofa.rb
mihari-7.6.1 lib/mihari/analyzers/fofa.rb
mihari-7.6.0 lib/mihari/analyzers/fofa.rb
mihari-7.5.0 lib/mihari/analyzers/fofa.rb
mihari-7.4.0 lib/mihari/analyzers/fofa.rb