mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 15:39:33 +00:00
[VS] Refactor email format.
This commit is contained in:
parent
4deb5af7d6
commit
8081492a90
4 changed files with 152 additions and 49 deletions
|
|
@ -122,5 +122,54 @@ function cve_utils.getDocURL(cve_id, scan_type)
|
|||
end
|
||||
end
|
||||
|
||||
-- **********************************************************
|
||||
|
||||
-- Function to select first 5 CVEs.
|
||||
function cve_utils.getFirst5(cves, scan_type, print_result)
|
||||
local result_string = ""
|
||||
local i = 0
|
||||
|
||||
for _,vs in ipairs(cves) do
|
||||
if (i<5) then
|
||||
|
||||
local cve_details = split(vs,"|")
|
||||
local cve_score = tonumber(cve_details[2])
|
||||
local cve_id = cve_details[1]
|
||||
|
||||
local badge_type = "";
|
||||
if (cve_score == 0) then
|
||||
badge_type = "bg-success";
|
||||
elseif(cve_score < 3.9) then
|
||||
badge_type = "bg-secondary";
|
||||
elseif(cve_score < 7) then
|
||||
badge_type = "bg-warning";
|
||||
else
|
||||
badge_type = "bg-danger";
|
||||
end
|
||||
|
||||
local url = cve_utils.getDocURL(cve_id, scan_type)
|
||||
local element = '<a href='..url..'><span class="badge '..badge_type..'">'..cve_id..'</span></a>'
|
||||
if (print_result) then
|
||||
print(element..' ')
|
||||
else
|
||||
result_string = string.format("%s%s",ternary(result_string~="",result_string..",",result_string),element)
|
||||
end
|
||||
else
|
||||
if(print_result) then
|
||||
|
||||
print('...')
|
||||
else
|
||||
result_string = string.format("%s%s",result_string,"...")
|
||||
end
|
||||
break
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
if (not print_result) then
|
||||
return result_string
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return cve_utils
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue