Sha256: bc03b0d32f6d53ef8cf3e66c9a074129b1984ca93311701f66c9a934b035567c

Contents?: true

Size: 1.14 KB

Versions: 3

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

module Mihari
  module Enrichers
    #
    # Google Public DNS enricher
    #
    class GooglePublicDNS < Base
      #
      # @param [Mihari::Models::Artifact] artifact
      #
      # @return [Mihari::Models::Artifact]
      #
      def call(artifact)
        return if artifact.domain.nil?

        res = client.query_all(artifact.domain)

        artifact.tap do |tapped|
          if tapped.dns_records.empty?
            tapped.dns_records = res.answers.map do |answer|
              Models::DnsRecord.new(resource: answer.resource_type, value: answer.data)
            end
          end
        end
      end

      class << self
        #
        # @return [String]
        #
        def key
          "google_public_dns"
        end
      end

      private

      #
      # @param [Mihari::Models::Artifact] artifact
      #
      # @return [Boolean]
      #
      def callable_relationships?(artifact)
        artifact.dns_records.empty?
      end

      def supported_data_types
        %w[url domain]
      end

      def client
        @client ||= Clients::GooglePublicDNS.new(timeout: timeout)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mihari-7.3.2 lib/mihari/enrichers/google_public_dns.rb
mihari-7.3.1 lib/mihari/enrichers/google_public_dns.rb
mihari-7.3.0 lib/mihari/enrichers/google_public_dns.rb