Class: Mihari::Enrichers::Shodan
- Defined in:
- lib/mihari/enrichers/shodan.rb
Overview
Shodan enricher
Constant Summary
Constants included from Concerns::Retriable
Concerns::Retriable::DEFAULT_CONDITION, Concerns::Retriable::RETRIABLE_ERRORS
Instance Attribute Summary
Attributes inherited from Actor
Instance Method Summary collapse
-
#call(artifact) ⇒ Mihari::Structs::Shodan::InternetDBResponse?
Query Shodan Internet DB.
Methods inherited from Base
#callable?, inherited, #initialize, #result
Methods inherited from Actor
configuration_keys, #initialize, key, key_aliases, keys, #result, #retry_exponential_backoff, #retry_interval, #retry_times, #timeout, type, #validate_configuration!
Methods included from Concerns::Retriable
Methods included from Concerns::Configurable
#configuration_keys?, #configured?
Constructor Details
This class inherits a constructor from Mihari::Enrichers::Base
Instance Method Details
#call(artifact) ⇒ Mihari::Structs::Shodan::InternetDBResponse?
Query Shodan Internet DB
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/mihari/enrichers/shodan.rb', line 16 def call(artifact) res = client.query(artifact.data) artifact.tap do |tapped| tapped.cpes = (res&.cpes || []).map { |cpe| Models::CPE.new(name: cpe) } if tapped.cpes.empty? tapped.ports = (res&.ports || []).map { |port| Models::Port.new(number: port) } if tapped.ports.empty? if tapped.reverse_dns_names.empty? tapped.reverse_dns_names = (res&.hostnames || []).map do |name| Models::ReverseDnsName.new(name:) end end if tapped.vulnerabilities.empty? tapped.vulnerabilities = (res&.vulns || []).map do |name| Models::Vulnerability.new(name:) end end end end |