Skip to content

Commit

Permalink
fix: enrich vulns
Browse files Browse the repository at this point in the history
  • Loading branch information
ninoseki committed Jan 25, 2024
1 parent 593b7c3 commit 4a8af37
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions lib/mihari/enrichers/shodan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 4a8af37

Please sign in to comment.