[VS] Add score and fix badges in report.

This commit is contained in:
Nicolo Maio 2023-10-09 12:17:03 +02:00
parent c89018628b
commit 317065c7d0
8 changed files with 126 additions and 17 deletions

View file

@ -480,23 +480,56 @@ end
-- **********************************************************
local function compare(a,b)
local a_array = split(a,"|")
local a_has_score = false
if (#a_array > 1) then
a_has_score = true
a = a_array[2]
end
local b_array = split(b,"|")
local b_has_score = false
if (#b_array > 1) then
b_has_score = true
b = b_array[2]
end
if (a_has_score and b_has_score) then
return a > b
else
return a_array[1] > b_array[1]
end
end
-- **********************************************************
-- Function to format cve list with scores
local function get_cve_with_score(cve)
local cve_with_score_list = {}
local max_score = 0
if(cve ~= nil) then
for _,cve_id in ipairs(cve) do
local score = cve_utils.getCVEscore(cve_id)
local cve_formatted = cve
if(score ~= nil) then
if(max_score < score) then
max_score = score
end
cve_formatted = string.format("%s|%s",cve_id,score)
end
cve_with_score_list[#cve_with_score_list+1] = cve_formatted
end
end
if next(cve_with_score_list) then
table.sort(cve_with_score_list, compare)
end
return cve_with_score_list
return cve_with_score_list, max_score
end
-- **********************************************************
@ -562,7 +595,7 @@ function vs_utils.save_host_to_scan(scan_type, host, scan_result, last_scan_time
end
local cve_formatted, max_score_cve = get_cve_with_score(cve)
local new_item = {
host = host,
host_name = host_name,
@ -570,7 +603,8 @@ 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 = get_cve_with_score(cve),
cve = cve_formatted,
max_score_cve = max_score_cve,
id = epoch_id,
is_ok_last_scan = is_ok_last_scan
}