Sha256: 3d494d457e33fdca9ddd26e300bcb6291734c535127064962525fd9e151553be

Contents?: true

Size: 796 Bytes

Versions: 7

Compression:

Stored size: 796 Bytes

Contents

# frozen_string_literal: true

module Mihari
  module Models
    #
    # Reverse DNS name model
    #
    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::Models::ReverseDnsName>]
        #
        def build_by_ip(ip, enricher: Enrichers::Shodan.new)
          result = enricher.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
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mihari-6.3.0 lib/mihari/models/reverse_dns.rb
mihari-6.2.0 lib/mihari/models/reverse_dns.rb
mihari-6.1.0 lib/mihari/models/reverse_dns.rb
mihari-6.0.0 lib/mihari/models/reverse_dns.rb
mihari-5.7.2 lib/mihari/models/reverse_dns.rb
mihari-5.7.1 lib/mihari/models/reverse_dns.rb
mihari-5.7.0 lib/mihari/models/reverse_dns.rb