From 4a8af3799d8cff0179a2e4eb45edef29bdfd5a13 Mon Sep 17 00:00:00 2001 From: Manabu Niseki Date: Thu, 25 Jan 2024 16:03:30 +0900 Subject: [PATCH] fix: enrich vulns --- lib/mihari/enrichers/shodan.rb | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/mihari/enrichers/shodan.rb b/lib/mihari/enrichers/shodan.rb index 5c3cfabf..a77bdd90 100644 --- a/lib/mihari/enrichers/shodan.rb +++ b/lib/mihari/enrichers/shodan.rb @@ -19,21 +19,19 @@ def call(artifact) 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: name) end end - end - end - # - # @param [Mihari::Models::Artifact] artifact - # - # @return [Boolean] - # - def callable?(artifact) - false unless supported_data_types.include?(artifact.data_type) + if tapped.vulnerabilities.empty? + tapped.vulnerabilities = (res&.vulns || []).map do |name| + Models::Vulnerability.new(name: name) + end + end + end end private @@ -44,7 +42,7 @@ def callable?(artifact) # @return [Boolean] # def callable_relationships?(artifact) - artifact.cpes.empty? || artifact.ports.empty? || artifact.reverse_dns_names.empty? + artifact.cpes.empty? || artifact.ports.empty? || artifact.reverse_dns_names.empty? || artifact.vulnerabilities.empty? end def supported_data_types