mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-01 00:19:33 +00:00
[VS] Fix a bug related to removing CVEs when a scan is in progress and make minor optimizations."
This commit is contained in:
parent
5d21795ca2
commit
c907e42926
2 changed files with 18 additions and 16 deletions
|
|
@ -687,10 +687,13 @@ end
|
|||
|
||||
-- Function to save host configuration
|
||||
local function isAlreadyPresent(item)
|
||||
local hosts_details = vs_utils.retrieve_hosts_to_scan()
|
||||
local host_hash_key = vs_utils.get_host_hash_key(item.host, item.scan_type)
|
||||
local hash_prefs_string = ntop.getHashCache(prefs_host_values_key,host_hash_key)
|
||||
|
||||
for _,value in ipairs(hosts_details) do
|
||||
if (item.host == value.host and item.scan_type == value.scan_type ) then
|
||||
if (not isEmptyString(hash_prefs_string)) then
|
||||
local host_pref_value = json.decode(hash_prefs_string)
|
||||
-- the value must not be empty
|
||||
if (host_pref_value and host_pref_value.host == item.host and host_pref_value.scan_type == host_pref_value.scan_type) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
|
@ -2102,7 +2105,7 @@ function vs_utils.delete_host_to_scan(host, scan_type, all)
|
|||
break
|
||||
else
|
||||
local r = json.decode(e)
|
||||
if(not((r.scan_type == "cve") and (r.host == "127.0.0.1"))) then
|
||||
if(r and not((r.scan_type == scan_type) and (r.host == host))) then
|
||||
table.insert(elems, e)
|
||||
end
|
||||
end
|
||||
|
|
@ -2227,11 +2230,16 @@ function vs_utils.scan_host(scan_type, host, ports, scan_id, use_coroutines)
|
|||
|
||||
if(ntop.isShuttingDown()) then return(false) end
|
||||
|
||||
vs_utils.set_status_scan(scan_type, host, ports_scan_param, id, nil,nil,nil, vs_utils.scan_status.scanning)
|
||||
|
||||
-- Save on redis the scanning host to avoid inconsistent state on ntopng restarts
|
||||
local scanning_host = {scan_type = scan_type, host = host, ports = ports_scan_param, id = scan_id}
|
||||
save_scanning_host(scanning_host)
|
||||
if (isAlreadyPresent({host= host, scan_type= scan_type})) then
|
||||
-- It is possible that the scan entry could be removed during the vs_utils.discover_open_ports phase.
|
||||
vs_utils.set_status_scan(scan_type, host, ports_scan_param, id, nil,nil,nil, vs_utils.scan_status.scanning)
|
||||
-- Save on redis the scanning host to avoid inconsistent state on ntopng restarts
|
||||
local scanning_host = {scan_type = scan_type, host = host, ports = ports_scan_param, id = scan_id}
|
||||
save_scanning_host(scanning_host)
|
||||
else
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
-- Scan host
|
||||
local scan_module = vs_utils.load_module(scan_type)
|
||||
|
|
@ -2260,9 +2268,7 @@ function vs_utils.scan_host(scan_type, host, ports, scan_id, use_coroutines)
|
|||
scan_result = vs_utils.scan_status.failed
|
||||
end
|
||||
|
||||
if debug_me then
|
||||
-- traceError(TRACE_NORMAL, TRACE_CONSOLE, "End scan Host ".. host .. ", result: " .. result .. "\n")
|
||||
end
|
||||
--traceError(TRACE_NORMAL, TRACE_CONSOLE, "End scan Host ".. host .. ", result: " .. result .. "\n")
|
||||
|
||||
if (isAlreadyPresent({host= host, scan_type= scan_type})) then
|
||||
vs_utils.save_host_to_scan(scan_type, host, result, now, duration, scan_result,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue