Sha256: c547d54a31b9f020eccdfa03f9add5a94b7691a653c58cdc33e708cfc770155e
Contents?: true
Size: 1.46 KB
Versions: 10
Compression:
Stored size: 1.46 KB
Contents
# frozen_string_literal: true module Mihari module Enrichers # # Shodan enricher # class Shodan < Base # # Query Shodan Internet DB # # @param [Mihari::Models::Artifact] artifact # # @return [Mihari::Structs::Shodan::InternetDBResponse, nil] # 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 private # # @param [Mihari::Models::Artifact] artifact # # @return [Boolean] # def callable_relationships?(artifact) artifact.cpes.empty? || artifact.ports.empty? || artifact.reverse_dns_names.empty? || artifact.vulnerabilities.empty? end def supported_data_types %w[ip] end def client @client ||= Clients::ShodanInternetDB.new(timeout:) end end end end
Version data entries
10 entries across 10 versions & 1 rubygems