mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 07:29:32 +00:00
[VS] Fix email format.
This commit is contained in:
parent
d6bacdd1bb
commit
9843d3f024
2 changed files with 16 additions and 25 deletions
|
|
@ -853,30 +853,14 @@ local function update_scan_info_for_report(type_of_scan_execution, new_item, hos
|
|||
info_json.begin_epoch = os.time()
|
||||
end
|
||||
|
||||
|
||||
if discrepancies then
|
||||
-- HAD DISCREPANCY INFO TO EMAIL REPORT
|
||||
local cve_case = false
|
||||
if (info_json ~= {} and info_json.num_cve_solved ~= nil and new_item.scan_type == 'cve') then
|
||||
info_json.num_cve_solved = tonumber(info_json.num_cve_solved or 0) + tonumber(discrepancies.num_cve_solved or 0)
|
||||
cve_case = true
|
||||
else
|
||||
info_json.num_cve_solved = 0
|
||||
end
|
||||
|
||||
if ((info_json ~= {} and info_json.new_open_ports ~= nil) and (new_item.scan_type == 'tcp_portscan' or new_item.scan_type == 'tcp_openports') and discrepancies.tcp_open_ports and discrepancies.tcp_open_ports.num and discrepancies.tcp_open_ports.num>0) then
|
||||
info_json.new_open_ports = tonumber(info_json.new_open_ports or 0) + tonumber(discrepancies.tcp_open_ports.num)
|
||||
else
|
||||
info_json.new_open_ports = 0
|
||||
end
|
||||
|
||||
if (info_json ~= {} and info_json.new_open_ports ~= nil and new_item.scan_type == 'udp_portscan' and discrepancies.udp_open_ports and discrepancies.udp_open_ports.num and discrepancies.udp_open_ports.num>0) then
|
||||
info_json.new_open_ports = tonumber(info_json.new_open_ports or 0) + tonumber(discrepancies.udp_open_ports.num or 0)
|
||||
else
|
||||
info_json.new_open_ports = 0
|
||||
end
|
||||
|
||||
|
||||
local host_discrepancies_details = ""
|
||||
local port_type = "TCP"
|
||||
local prefix_key = "tcp_"
|
||||
|
|
@ -885,6 +869,8 @@ local function update_scan_info_for_report(type_of_scan_execution, new_item, hos
|
|||
prefix_key = "udp_"
|
||||
end
|
||||
|
||||
local host_id = ternary(isEmptyString(new_item.host_name),new_item.host, string.format("%s (%s)",new_item.host_name,new_item.host))
|
||||
|
||||
if (not cve_case and info_json ~= {}) then
|
||||
-- DISCREPANCY PORTS CASES
|
||||
info_json.discrepancy_case = 'ports'
|
||||
|
|
@ -892,16 +878,17 @@ local function update_scan_info_for_report(type_of_scan_execution, new_item, hos
|
|||
if (tonumber(discrepancies[prefix_key.."open_ports"].num or 0) > 0) then
|
||||
-- take only open ports not the closed ports
|
||||
info_json.new_open_ports = tonumber(info_json.new_open_ports or 0) + tonumber(discrepancies[prefix_key.."open_ports"].num or 0)
|
||||
|
||||
host_discrepancies_details = string.format("<br>Host %s has these %s ports open: %s.</br>",new_item.host,port_type,discrepancies[prefix_key.."open_ports"].ports)
|
||||
host_discrepancies_details = i18n("hosts_stats.page_scan_hosts.email.host_port_discrepancy_description", {
|
||||
host_id = host_id,
|
||||
port_type = port_type,
|
||||
ports = discrepancies[prefix_key.."open_ports"].ports
|
||||
})
|
||||
|
||||
if (isEmptyString(info_json.hosts_discrepancies_details)) then
|
||||
info_json.hosts_discrepancies_details = host_discrepancies_details
|
||||
else
|
||||
info_json.hosts_discrepancies_details = string.format("%s%s",info_json.hosts_discrepancies_details,host_discrepancies_details)
|
||||
end
|
||||
else
|
||||
info_json.new_open_ports = tonumber(info_json.new_open_ports or 0)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -910,7 +897,10 @@ local function update_scan_info_for_report(type_of_scan_execution, new_item, hos
|
|||
info_json.discrepancy_case = 'cves'
|
||||
|
||||
local cve_string = format_port_list_to_string(discrepancies.cve_solved)
|
||||
host_discrepancies_details = string.format("<br>Host %s has solved these CVEs: %s.</br>",new_item.host,cve_string)
|
||||
host_discrepancies_details = i18n("hosts_stats.page_scan_hosts.email.host_cve_discrepancy_description", {
|
||||
host_id = host_id,
|
||||
cves = cve_string,
|
||||
})
|
||||
|
||||
if (isEmptyString(info_json.hosts_discrepancies_details)) then
|
||||
info_json.hosts_discrepancies_details = host_discrepancies_details
|
||||
|
|
@ -1395,8 +1385,7 @@ local function retrieve_email_info(exec_type)
|
|||
if (email_info.has_discrepancy) then
|
||||
email_info.new_open_ports = info_json.new_open_ports or 0
|
||||
email_info.fixed_cves = info_json.num_cve_solved or 0
|
||||
local string_hosts_discrepancies_details = tostring(info_json.hosts_discrepancies_details)
|
||||
email_info.discrepancies_details = string_hosts_discrepancies_details:gsub("%|","\n")
|
||||
email_info.discrepancies_details = tostring(info_json.hosts_discrepancies_details)
|
||||
end
|
||||
|
||||
email_info.duration = email_info.end_epoch_t - email_info.begin_epoch_t
|
||||
|
|
@ -1519,7 +1508,7 @@ function vs_utils.notify_scan_results(exec_type, periodicity)
|
|||
cves_fixed = ternary(email_info.fixed_cves ~= 0, format_high_num_value_for_tables({num = email_info.fixed_cves }, "num"),"0"),
|
||||
hosts_discrepancy_details = email_info.discrepancies_details
|
||||
})
|
||||
notification_message = string.format("%s\n\n%s",notification_message,discrepancies_info)
|
||||
notification_message = string.format("%s%s",notification_message,discrepancies_info)
|
||||
end
|
||||
if verbose then
|
||||
traceError(TRACE_NORMAL,TRACE_CONSOLE, "Vulnerability Scan completed. Sending " .. title .."\n")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue