mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-05 02:16:39 +00:00
Vulnerability scan improvements
This commit is contained in:
parent
883d3faee9
commit
5dc8770918
20 changed files with 353 additions and 263 deletions
|
|
@ -1,52 +0,0 @@
|
|||
--
|
||||
-- (C) 2013-23 - ntop.org
|
||||
--
|
||||
dirs = ntop.getDirs()
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/host/?.lua;" .. package.path
|
||||
|
||||
local rest_utils = require "rest_utils"
|
||||
local json = require("dkjson")
|
||||
local vulnerability_scan = require "vulnerability_scan"
|
||||
|
||||
|
||||
local host = _GET["host"]
|
||||
local scan_type = _GET["scan_type"]
|
||||
local single_host = toboolean(_GET["scan_single_host"]) or false
|
||||
|
||||
local debug = false
|
||||
debug = true
|
||||
|
||||
|
||||
if single_host then
|
||||
if isEmptyString(host) or isEmptyString(scan_type) then
|
||||
rest_utils.answer(rest_utils.consts.err.invalid_args)
|
||||
end
|
||||
|
||||
local res = vulnerability_scan.scan_host(scan_type, host, true)
|
||||
|
||||
if res == 1 then
|
||||
if debug then
|
||||
tprint("SENDING BACK RESPO")
|
||||
end
|
||||
rest_utils.answer(rest_utils.consts.success.ok)
|
||||
else
|
||||
rest_utils.answer(rest_utils.consts.err.internal_error)
|
||||
|
||||
end
|
||||
else
|
||||
|
||||
local res = vulnerability_scan.scan_all_host(true)
|
||||
|
||||
if res == 1 then
|
||||
if debug then
|
||||
tprint("SENDING BACK ALLs RESPO")
|
||||
end
|
||||
rest_utils.answer(rest_utils.consts.success.ok)
|
||||
else
|
||||
rest_utils.answer(rest_utils.consts.err.internal_error)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
|
@ -1,13 +1,14 @@
|
|||
--
|
||||
-- (C) 2013-23 - ntop.org
|
||||
--
|
||||
dirs = ntop.getDirs()
|
||||
|
||||
local dirs = ntop.getDirs()
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/host/?.lua;" .. package.path
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/vulnerability_scan/?.lua;" .. package.path
|
||||
|
||||
local rest_utils = require "rest_utils"
|
||||
local vulnerability_scan_utils = require "vulnerability_scan_utils"
|
||||
|
||||
local vs_utils = require "vs_utils"
|
||||
|
||||
local host = _GET["host"]
|
||||
local scan_type = _GET["scan_type"]
|
||||
|
|
@ -16,15 +17,10 @@ if isEmptyString(host) or isEmptyString(scan_type) then
|
|||
rest_utils.answer(rest_utils.consts.err.bad_content)
|
||||
end
|
||||
|
||||
local function set_host_to_scan(ip, scan_type)
|
||||
return vulnerability_scan_utils.save_host_to_scan(scan_type, ip)
|
||||
end
|
||||
|
||||
|
||||
local result = set_host_to_scan(host, scan_type)
|
||||
local result = vs_utils.save_host_to_scan(scan_type, host) -- FIXME: add ports
|
||||
|
||||
if result == 1 then
|
||||
rest_utils.answer(rest_utils.consts.success.ok)
|
||||
else
|
||||
rest_utils.answer(rest_utils.consts.err.internal_error)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue