Sha256: f7c792f20d011c5b9c5600a8086db2e0a0a0a067b639e23332ce7a7792c24312

Contents?: true

Size: 758 Bytes

Versions: 2

Compression:

Stored size: 758 Bytes

Contents

# frozen_string_literal: true

module Mihari
  module Models
    #
    # DNS record model
    #
    class DnsRecord < ActiveRecord::Base
      belongs_to :artifact

      class << self
        include Dry::Monads[:result]

        #
        # Build DNS records
        #
        # @param [String] domain
        # @param [Mihari::Enrichers::Shodan] enricher
        #
        # @return [Array<Mihari::Models::DnsRecord>]
        #
        def build_by_domain(domain, enricher: Enrichers::GooglePublicDNS.new)
          enricher.result(domain).bind do |res|
            Success(
              res.answers.map { |answer| new(resource: answer.resource_type, value: answer.data) }
            )
          end.value_or([])
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mihari-6.3.0 lib/mihari/models/dns.rb
mihari-6.2.0 lib/mihari/models/dns.rb