Class: Mihari::Services::ArtifactEnricher

Inherits:
Mihari::Service show all
Defined in:
lib/mihari/services/enrichers.rb

Instance Method Summary collapse

Methods inherited from Mihari::Service

call, #result, result

Instance Method Details

#call(id) ⇒ Object

Parameters:

  • id (String)

Raises:



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/mihari/services/enrichers.rb', line 9

def call(id)
  artifact = Mihari::Models::Artifact.includes(
    :autonomous_system,
    :geolocation,
    :whois_record,
    :dns_records,
    :reverse_dns_names,
    :cpes,
    :ports
  ).find(id)

  raise UnenrichableError.new, "#{artifact.id} is already enriched or unenrichable" unless artifact.enrichable?

  artifact.enrich
  artifact.save
end