Sha256: c8e904ac48fbe5132f643f05e9eca0c5d49d6dc7afcb126013c3faaf769c9be7

Contents?: true

Size: 607 Bytes

Versions: 6

Compression:

Stored size: 607 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
      #
      # @return [Array<Mihari::ReverseDnsName>]
      #
      def build_by_ip(ip)
        result = Enrichers::Shodan.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

6 entries across 6 versions & 1 rubygems

Version Path
mihari-5.4.9 lib/mihari/models/reverse_dns.rb
mihari-5.4.8 lib/mihari/models/reverse_dns.rb
mihari-5.4.7 lib/mihari/models/reverse_dns.rb
mihari-5.4.6 lib/mihari/models/reverse_dns.rb
mihari-5.4.5 lib/mihari/models/reverse_dns.rb
mihari-5.4.4 lib/mihari/models/reverse_dns.rb