Add stub for cve score retriever. (#7858)

This commit is contained in:
Nicolo Maio 2023-10-06 17:30:06 +02:00
parent 5e4bf02d5d
commit e93d92c9b7
4 changed files with 49 additions and 3 deletions

View file

@ -48,6 +48,7 @@ local scanned_hosts_changes_key = "ntopng.alerts.scanned_hosts_changes"
local json = require("dkjson")
local format_utils = require("format_utils")
local recipients = require("recipients")
local cve_utils = require("cve_utils")
local debug_print = false
local vs_utils = {}
@ -479,6 +480,24 @@ end
-- **********************************************************
-- Function to format cve list with scores
local function get_cve_with_score(cve)
local cve_with_score_list = {}
for _,cve_id in ipairs(cve) do
local score = cve_utils.getCVEscore(cve_id)
local cve_formatted = cve
if(score ~= nil) then
cve_formatted = string.format("%s|%s",cve_id,score)
end
cve_with_score_list[#cve_with_score_list+1] = cve_formatted
end
return cve_with_score_list
end
-- **********************************************************
-- Function to save host configuration
function vs_utils.save_host_to_scan(scan_type, host, scan_result, last_scan_time, last_duration,
is_ok_last_scan, ports, scan_frequency, num_open_ports,
@ -538,6 +557,9 @@ function vs_utils.save_host_to_scan(scan_type, host, scan_result, last_scan_time
if (isEmptyString(is_ok_last_scan)) then
is_ok_last_scan = vs_utils.scan_status.not_scanned
end
local new_item = {
host = host,
host_name = host_name,
@ -545,7 +567,7 @@ function vs_utils.save_host_to_scan(scan_type, host, scan_result, last_scan_time
ports = ports,
num_open_ports = num_open_ports,
num_vulnerabilities_found = num_vulnerabilities_found,
cve = cve,
cve = get_cve_with_score(cve),
id = epoch_id,
is_ok_last_scan = is_ok_last_scan
}