Sha256: 0893c638b394018e1651c9387b3221bf3ec55d909b6a7f10e8a15fc77827c0f6
Contents?: true
Size: 740 Bytes
Versions: 7
Compression:
Stored size: 740 Bytes
Contents
# frozen_string_literal: true module Mihari module Models # # Port model # class Port < ActiveRecord::Base belongs_to :artifact class << self include Dry::Monads[:result] # # Build ports # # @param [String] ip # @param [Mihari::Enrichers::Shodan] enricher # # @return [Array<Mihari::Port>] # def build_by_ip(ip, enricher: Enrichers::Shodan.new) result = enricher.result(ip).bind do |res| if res.nil? Success [] else Success(res.ports.map { |port| new(port: port) }) end end result.value_or [] end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems