Sha256: b465544eeef498e1925bafc931d389ad32f2bd1f2653464c57dbefe347ed975d

Contents?: true

Size: 683 Bytes

Versions: 3

Compression:

Stored size: 683 Bytes

Contents

# frozen_string_literal: true

module Mihari
  class ReverseDnsName < ActiveRecord::Base
    belongs_to :artifact

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

      #
      # Build reverse DNS names
      #
      # @param [String] ip
      # @param [Mihari::Enrichers::Shodan] enricher
      #
      # @return [Array<Mihari::ReverseDnsName>]
      #
      def build_by_ip(ip, enricher: Enrichers::Shodan.new)
        result = enricher.query_result(ip).bind do |res|
          if res.nil?
            Success []
          else
            Success(res.hostnames.map { |name| new(name: name) })
          end
        end
        result.value_or []
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mihari-5.6.1 lib/mihari/models/reverse_dns.rb
mihari-5.6.0 lib/mihari/models/reverse_dns.rb
mihari-5.5.0 lib/mihari/models/reverse_dns.rb