[VS] Fix find single host function.

This commit is contained in:
Nicolo Maio 2023-11-08 11:38:25 +01:00
parent 0584f6970f
commit 0c403fd7b1

View file

@ -1247,13 +1247,25 @@ end
-- Function to retrieve a specific host scan info
function vs_utils.retrieve_host(host)
local hosts_scanned = ntop.getHashKeysCache(host_to_scan_key) or {}
for key, _ in pairs(hosts_scanned) do
if key:find(host) then
return json.decode(ntop.getHashCache(host_to_scan_key, key) or "")
if key:find(host) and key:find("cve") then
local hash_value_string = ntop.getHashCache(host_to_scan_key, key)
local hash_prefs_string = ntop.getHashCache(prefs_host_values_key,key)
local hash_value = json.decode(hash_prefs_string)
if (not isEmptyString(hash_value_string)) then
-- hash value found
hash_value = json.decode(hash_value_string)
local hash_pref_value = json.decode(hash_prefs_string) or {}
for k,value in pairs(hash_pref_value) do
if (k ~= 'is_ok_last_scan') then
hash_value[k] = value
end
end
end
return hash_value
end
end
return nil
end