Fix invalid host add (#7762)

This commit is contained in:
Nicolo Maio 2023-08-21 12:15:07 +02:00
parent f7a78017be
commit 2539c1ef0a

View file

@ -232,7 +232,7 @@ local function isAlreadyPresent(item)
local hosts_details = vs_utils.retrieve_hosts_to_scan()
for _,value in ipairs(hosts_details) do
if (item.host == value.host ) then
if (item.host == value.host and item.scan_type == value.scan_type ) then
return true
end
end
@ -332,6 +332,7 @@ function vs_utils.save_host_to_scan(scan_type, host, scan_result, last_scan_time
vs_utils.delete_host_to_scan_by_id(id)
end
local result = 1 -- success
if(not isAlreadyPresent(new_item)) then
--saved_hosts[#saved_hosts+1] = new_item
ntop.setHashCache(host_to_scan_key, host_hash_key, json.encode(new_item))
@ -339,10 +340,12 @@ function vs_utils.save_host_to_scan(scan_type, host, scan_result, last_scan_time
-- edit case
ntop.setHashCache(host_to_scan_key, host_hash_key, json.encode(new_item))
else
result = 2 --aleready_present
end
--ntop.setCache(host_to_scan_key, json.encode(saved_hosts))
return 1
return result
end
-- **********************************************************