Sha256: da7aaf905779ee2ddf0292f45305f95f12c896d2c4ae72c14f69c6e5de692502

Contents?: true

Size: 584 Bytes

Versions: 1

Compression:

Stored size: 584 Bytes

Contents

# frozen_string_literal: true

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

      class << self
        #
        # Build CPEs
        #
        # @param [String] ip
        # @param [Mihari::Enrichers::Shodan] enricher
        #
        # @return [Array<Mihari::CPE>]
        #
        def build_by_ip(ip, enricher: Enrichers::Shodan.new)
          enricher.result(ip).fmap do |res|
            (res&.cpes || []).map { |cpe| new(cpe: cpe) }
          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/cpe.rb