Sha256: 7e9ba93741a53b027cefcc8d4f48e523cbddc939c041e747ee4f81ee0752e4a0

Contents?: true

Size: 686 Bytes

Versions: 1

Compression:

Stored size: 686 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)
          enricher.result(ip).fmap do |res|
            (res&.hostnames || []).map { |name| new(name: name) }
          end.value_or []
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mihari-7.0.0 lib/mihari/models/reverse_dns.rb