Add VS verbosity and redis variable to enable debugging

This commit is contained in:
Alfredo Cardigliano 2023-11-03 11:51:20 +01:00
parent 628cdac01b
commit c1ec822937

View file

@ -64,7 +64,11 @@ local format_utils = require("format_utils")
local recipients = require("recipients")
local cve_utils = require("cve_utils")
local debug_me = false
-- Enable debug with:
-- redis-cli set "ntopng.prefs.vs.debug_enabled" "1"
-- systemctl restart ntopng
local debug_me = ntop.getCache("ntopng.prefs.vs.debug_enabled") == "1"
local verbose = true
local vs_utils = {}
@ -1108,7 +1112,7 @@ function vs_utils.notify_scan_results(is_periodic, periodicity)
end_date = end_date_formatted
})
else
-- scan all case
-- on demand scan
notification_message = i18n("hosts_stats.page_scan_hosts.email.scan_all_ended", {
cves = format_num_for_email(cve_num,0),
udp_ports = format_num_for_email(udp_ports,1),
@ -1122,6 +1126,10 @@ function vs_utils.notify_scan_results(is_periodic, periodicity)
})
end
if verbose then
traceError(TRACE_NORMAL,TRACE_CONSOLE, "Vulnerability Scan completed. Sending " .. title .."\n")
end
recipients.sendMessageByNotificationType({periodicity = periodicity, success=true, message = notification_message, title = title}, "vulnerability_scans")
ntop.setCache(info_redis_key,json.encode({
@ -1129,7 +1137,7 @@ function vs_utils.notify_scan_results(is_periodic, periodicity)
udp_ports = 0,
tcp_ports = 0,
begin_epoch = 0,
scanned_hosts = 0
scanned_hosts = 0
}))
end
@ -1586,6 +1594,7 @@ function vs_utils.schedule_periodic_scan(periodicity)
local host_to_scan_list = vs_utils.retrieve_hosts_to_scan()
if (#host_to_scan_list > 0 ) then
local is_already_running = ntop.getCache(periodic_scan_key) == "1"
if not is_already_running then
@ -1593,7 +1602,6 @@ function vs_utils.schedule_periodic_scan(periodicity)
for _,scan_info in ipairs(host_to_scan_list) do
local frequency = scan_info.scan_frequency
if(frequency == periodicity) then
vs_utils.schedule_ondemand_single_host_scan(scan_info.scan_type, scan_info.host, scan_info.ports, scan_info.id, true, false)
is_scanning_almost_one = true