Sha256: 6f225f9195ce09111758e48058b654297c5ceba00dd1ced45ea2d95e4ddb762f

Contents?: true

Size: 595 Bytes

Versions: 6

Compression:

Stored size: 595 Bytes

Contents

# frozen_string_literal: true

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

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

      #
      # Build AS
      #
      # @param [String] ip
      #
      # @return [Mihari::AutonomousSystem, nil]
      #
      def build_by_ip(ip)
        result = Enrichers::IPInfo.query_result(ip).bind do |res|
          value = res&.asn
          if value.nil?
            Success nil
          else
            Success new(asn: value)
          end
        end
        result.value_or nil
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

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