Sha256: 541b336e979641f2aae116f7d84846b898801d4c3f754b9894739ef05bae03ec

Contents?: true

Size: 592 Bytes

Versions: 14

Compression:

Stored size: 592 Bytes

Contents

# frozen_string_literal: true

module Mihari
  module Models
    #
    # Port model
    #
    class Port < ActiveRecord::Base
      belongs_to :artifact

      class << self
        #
        # Build ports
        #
        # @param [String] ip
        # @param [Mihari::Enrichers::Shodan] enricher
        #
        # @return [Array<Mihari::Port>]
        #
        def build_by_ip(ip, enricher: Enrichers::Shodan.new)
          enricher.result(ip).fmap do |res|
            (res&.ports || []).map { |port| new(port: port) }
          end.value_or []
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
mihari-7.3.2 lib/mihari/models/port.rb
mihari-7.3.1 lib/mihari/models/port.rb
mihari-7.3.0 lib/mihari/models/port.rb
mihari-7.2.0 lib/mihari/models/port.rb
mihari-7.1.3 lib/mihari/models/port.rb
mihari-7.1.2 lib/mihari/models/port.rb
mihari-7.1.1 lib/mihari/models/port.rb
mihari-7.1.0 lib/mihari/models/port.rb
mihari-7.0.5 lib/mihari/models/port.rb
mihari-7.0.4 lib/mihari/models/port.rb
mihari-7.0.3 lib/mihari/models/port.rb
mihari-7.0.2 lib/mihari/models/port.rb
mihari-7.0.1 lib/mihari/models/port.rb
mihari-7.0.0 lib/mihari/models/port.rb