mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 07:29:32 +00:00
Use meaningful names
This commit is contained in:
parent
061f2b50fc
commit
d29c4d384d
3 changed files with 29 additions and 29 deletions
|
|
@ -43,20 +43,20 @@ local host_to_scan_key = "ntopng.vs.hosts.scanned_values"
|
|||
local prefs_host_values_key = "ntopng.prefs.vs.hosts_conf"
|
||||
|
||||
local host_to_scan_periodicity_key = "ntopng.vs.periodic_scan"
|
||||
local host_to_scan_all_key = "ntopng.vs.scan_all"
|
||||
local ondemand_scan_key = "ntopng.vs.scan_all"
|
||||
local host_scannned_count_key = "ntopng.prefs.host_to_scan.count_scanned"
|
||||
local host_scan_queue_key = "ntopng.vs.scan_queue"
|
||||
local scanned_hosts_changes_key = "ntopng.alerts.scanned_hosts_changes"
|
||||
local host_in_scanning_hash_key = "ntopng.vs.hosts.in_scanning"
|
||||
|
||||
-- redis key for last scan report dates
|
||||
local hosts_scan_last_report_dates = "ntopng.vs.report_dates"
|
||||
local hosts_scan_last_report_dates = "ntopng.vs.report_dates"
|
||||
|
||||
-- redis keys for periodic scan info
|
||||
local host_periodic_scan_info = "ntopng.vs.periodic_scan.info"
|
||||
local periodic_scan_host_info_key = "ntopng.vs.periodic_scan.info"
|
||||
|
||||
-- redis keys for scan all info
|
||||
local host_scan_all_info = "ntopng.vs.scan_all.info"
|
||||
local ondemand_scan_host_info_key = "ntopng.vs.scan_all.info"
|
||||
|
||||
local json = require("dkjson")
|
||||
local format_utils = require("format_utils")
|
||||
|
|
@ -124,7 +124,7 @@ local function get_report_path(scan_type, ip, all)
|
|||
local base_dir
|
||||
local ret = ""
|
||||
|
||||
base_dir = dirs.workingdir .. "/-1/vulnerability_scan"
|
||||
base_dir = dirs.workingdir .. "/" .. getSystemInterfaceId() .. "/vulnerability_scan"
|
||||
ntop.mkdir(base_dir)
|
||||
|
||||
if (not all or all == nil) then
|
||||
|
|
@ -634,9 +634,9 @@ end
|
|||
-- Function to select correctly redis keys on periodic or scan all
|
||||
local function get_counter_periodic_all_scan_keys(is_periodic)
|
||||
if (is_periodic) then
|
||||
return host_periodic_scan_info --host_periodic_scan_cve_num_key,host_periodic_scan_udp_ports_key,host_periodic_scan_tcp_ports_key
|
||||
return periodic_scan_host_info_key --host_periodic_scan_cve_num_key,host_periodic_scan_udp_ports_key,host_periodic_scan_tcp_ports_key
|
||||
else
|
||||
return host_scan_all_info --host_scan_all_cve_num_key,host_scan_all_udp_ports_key,host_scan_all_tcp_ports_key
|
||||
return ondemand_scan_host_info_key --host_scan_all_cve_num_key,host_scan_all_udp_ports_key,host_scan_all_tcp_ports_key
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -1046,7 +1046,7 @@ end
|
|||
-- Function to send notification after a periodic scan
|
||||
-- @param is_periodic (true -> is a periodic scan message, false -> is an all scan message)
|
||||
-- @param periodicity (can be nil in case of scan all)
|
||||
function vs_utils.notify_end_periodicity_or_all_scan(is_periodic, periodicity)
|
||||
function vs_utils.notify_scan_results(is_periodic, periodicity)
|
||||
local notification_message = ""
|
||||
|
||||
local info_redis_key = get_counter_periodic_all_scan_keys(is_periodic)
|
||||
|
|
@ -1074,8 +1074,8 @@ function vs_utils.notify_end_periodicity_or_all_scan(is_periodic, periodicity)
|
|||
|
||||
local begin_epoch_t = tonumber(info_json.begin_epoch)
|
||||
local end_epoch_t = os.time()
|
||||
|
||||
if (info_json.begin_epoch ~= nil) then
|
||||
|
||||
duration = end_epoch_t - begin_epoch_t
|
||||
duration_label = secondsToTime(duration)
|
||||
end
|
||||
|
|
@ -1142,7 +1142,7 @@ end
|
|||
-- **********************************************************
|
||||
|
||||
-- Function to verify if periodic scan is ended
|
||||
function vs_utils.is_periodic_scan_over()
|
||||
function vs_utils.is_periodic_scan_completed()
|
||||
local periodicity_scan_in_progress = ntop.getCache(host_to_scan_periodicity_key) == "1"
|
||||
|
||||
if (periodicity_scan_in_progress) then
|
||||
|
|
@ -1181,8 +1181,8 @@ end
|
|||
-- **********************************************************
|
||||
|
||||
-- Function to verify if scan all is ended
|
||||
function vs_utils.is_scan_all_over()
|
||||
local scan_all_in_progress = ntop.getCache(host_to_scan_all_key) == "1"
|
||||
function vs_utils.is_ondemand_scan_completed()
|
||||
local scan_all_in_progress = ntop.getCache(ondemand_scan_key) == "1"
|
||||
|
||||
if (scan_all_in_progress) then
|
||||
local hosts_details = vs_utils.retrieve_hosts_to_scan()
|
||||
|
|
@ -1194,7 +1194,7 @@ function vs_utils.is_scan_all_over()
|
|||
end
|
||||
end
|
||||
|
||||
ntop.setCache(host_to_scan_all_key, "0")
|
||||
ntop.setCache(ondemand_scan_key, "0")
|
||||
|
||||
for _,item in ipairs(hosts_details) do
|
||||
local host_hash_key = vs_utils.get_host_hash_key(item.host, item.scan_type)
|
||||
|
|
@ -1541,7 +1541,7 @@ end
|
|||
|
||||
-- **********************************************************
|
||||
|
||||
function vs_utils.schedule_host_scan(scan_type, host, ports, scan_id, is_periodicity, is_all)
|
||||
function vs_utils.schedule_ondemand_single_host_scan(scan_type, host, ports, scan_id, is_periodicity, is_all)
|
||||
local scan = { scan_type = scan_type, host = host, ports = ports, id= scan_id}
|
||||
vs_utils.set_status_scan(scan_type, host, ports, scan_id, is_periodicity, is_all, vs_utils.scan_status.scheduled)
|
||||
|
||||
|
|
@ -1552,27 +1552,27 @@ end
|
|||
|
||||
-- **********************************************************
|
||||
|
||||
function vs_utils.schedule_all_hosts_scan()
|
||||
function vs_utils.schedule_ondemand_all_hosts_scan()
|
||||
local host_to_scan_list = vs_utils.retrieve_hosts_to_scan()
|
||||
|
||||
local is_scanning_almost_one = false
|
||||
if #host_to_scan_list > 0 then
|
||||
for _,scan_info in ipairs(host_to_scan_list) do
|
||||
vs_utils.schedule_host_scan(scan_info.scan_type, scan_info.host, scan_info.ports, scan_info.id, false, true)
|
||||
vs_utils.schedule_ondemand_single_host_scan(scan_info.scan_type, scan_info.host, scan_info.ports, scan_info.id, false, true)
|
||||
is_scanning_almost_one = true
|
||||
end
|
||||
end
|
||||
|
||||
if (is_scanning_almost_one) then
|
||||
ntop.setCache(host_to_scan_all_key , "1")
|
||||
ntop.setCache(ondemand_scan_key , "1")
|
||||
end
|
||||
|
||||
ntop.setCache(host_scan_all_info,json.encode({
|
||||
ntop.setCache(ondemand_scan_host_info_key, json.encode({
|
||||
cves = 0,
|
||||
udp_ports = 0,
|
||||
tcp_ports = 0,
|
||||
begin_epoch = os.time(),
|
||||
scanned_host = 0
|
||||
scanned_host = 0
|
||||
}))
|
||||
|
||||
return true
|
||||
|
|
@ -1594,7 +1594,7 @@ function vs_utils.schedule_periodic_scan(periodicity)
|
|||
local frequency = scan_info.scan_frequency
|
||||
|
||||
if(frequency == periodicity) then
|
||||
vs_utils.schedule_host_scan(scan_info.scan_type, scan_info.host, scan_info.ports, scan_info.id, true, false)
|
||||
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
|
||||
end
|
||||
end
|
||||
|
|
@ -1605,7 +1605,7 @@ function vs_utils.schedule_periodic_scan(periodicity)
|
|||
ntop.setCache(host_to_scan_periodicity_key.."type", periodicity)
|
||||
|
||||
|
||||
ntop.setCache(host_periodic_scan_info , json.encode({
|
||||
ntop.setCache(periodic_scan_host_info_key , json.encode({
|
||||
cves = 0,
|
||||
udp_ports = 0,
|
||||
tcp_ports = 0,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue