lib/tasks/helpers/vulndb.rb
def add_vulns_by_cpe(component_list)

        # Make sure the key is set before querying intrigue api
        intrigueio_api_key = _get_task_config "intrigueio_api_key"
        use_api = intrigueio_api_key && intrigueio_api_key.length > 0

        # for ech fingerprint, map vulns 
        component_list = component_list.map do |fp|
          next unless fp 

          vulns = []
          if fp["type"] == "fingerprint" && fp["inference"]
            cpe = Intrigue::VulnDb::Cpe.new(fp["cpe"])
            if use_api # get vulns via intrigue API
              _log "Matching vulns for #{fp["cpe"]} via Intrigue API"
              vulns = cpe.query_intrigue_vulndb_api(intrigueio_api_key)
            else
              vulns = cpe.query_local_nvd_json
            end

            # merge it in 
            fp.merge!({"vulns" => vulns })
          else 
            _log "Inference disallowed on: #{fp["cpe"]}" if fp["cpe"]
            _log "Returning un-enriched fps"
            fp if fp["type"] == "fingerprint"
          end

        end

      component_list.compact
      end
#
# This method assumes we get a list of objects with a CPE we can parse
# and use for a vuln lookup based on the configured methdo
#
This method assumes we get a list of objects with a CPE we can parse
and use for a vuln lookup based on the configured methdo
This method assumes we get a list of objects with a CPE we can parse and use for a vuln lookup based on the configured methdo
def add_vulns_by_cpe(component_list)
        intrigueio_api_key = _get_task_config "intrigueio_api_key"
        use_api = intrigueio_api_key && intrigueio_api_key.length > 0
        component_list = component_list.map do |fp|
          next unless fp 
          vulns = []
          if fp["type"] == "fingerprint" && fp["inference"]
            cpe = Intrigue::VulnDb::Cpe.new(fp["cpe"])
            if use_api 
              _log "Matching vulns for #{fp["cpe"]} via Intrigue API"
              vulns = cpe.query_intrigue_vulndb_api(intrigueio_api_key)
            else
              vulns = cpe.query_local_nvd_json
            end
            fp.merge!({"vulns" => vulns })
          else 
            _log "Inference disallowed on: #{fp["cpe"]}" if fp["cpe"]
            _log "Returning un-enriched fps"
            fp if fp["type"] == "fingerprint"
          end
        end
      component_list.compact
      end
def add_vulns_by_cpe ( component_list ) intrigueio_api_key = _get_task_config "intrigueio_api_key" use_api = intrigueio_api_key && intrigueio_api_key . length > 0 component_list = component_list . map do | fp | next unless fp vulns = [ ] if fp [ "type" ] == "fingerprint" && fp [ "inference" ] cpe = Intrigue :: VulnDb :: Cpe . new ( fp [ "cpe" ] ) if use_api _log "Matching vulns for #{fp["cpe"]} via Intrigue API" vulns = cpe . query_intrigue_vulndb_api ( intrigueio_api_key ) else vulns = cpe . query_local_nvd_json end fp . merge! ( { "vulns" => vulns } ) else _log "Inference disallowed on: #{fp["cpe"]}" if fp [ "cpe" ] _log "Returning un-enriched fps" fp if fp [ "type" ] == "fingerprint" end end component_list . compact end
This method assumes we get a list of objects with a CPE we can parse
and use for a vuln lookup based on the configured methdo
This method assumes we get a list of objects with a CPE we can parse and use for a vuln lookup based on the configured methdo
# Make sure the key is set before querying intrigue api # for ech fingerprint, map vulns  # get vulns via intrigue API # merge it in 
component_list