Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: enrich vulns #1051

Merged
merged 1 commit into from
Jan 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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