mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-01 00:19:33 +00:00
121 lines
4.4 KiB
Lua
121 lines
4.4 KiB
Lua
--
|
|
-- (C) 2013-23 - ntop.org
|
|
--
|
|
local dirs = ntop.getDirs()
|
|
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
|
package.path = dirs.installdir .. "/scripts/lua/modules/vulnerability_scan/?.lua;" .. package.path
|
|
|
|
if(ntop.isPro()) then
|
|
package.path = dirs.installdir .. "/pro/scripts/lua/modules/?.lua;" .. package.path
|
|
end
|
|
|
|
require "lua_utils"
|
|
local page_utils = require("page_utils")
|
|
local template = require("template_utils")
|
|
local graph_utils = require("graph_utils")
|
|
local json = require("dkjson")
|
|
local page = _GET["page"]
|
|
local auth = require "auth"
|
|
|
|
|
|
|
|
if not isAllowedSystemInterface() then return end
|
|
|
|
sendHTTPContentTypeHeader('text/html')
|
|
|
|
page_utils.print_header_and_set_active_menu_entry(page_utils.menu_entries.vulnerability_scan)
|
|
|
|
dofile(dirs.installdir .. "/scripts/lua/inc/menu.lua")
|
|
|
|
local base_url = ntop.getHttpPrefix() .. "/lua/vulnerability_scan.lua"
|
|
local charts_available = areHostTimeseriesEnabled(ifId, nil)
|
|
local host_result = _GET["host"]
|
|
|
|
page_utils.print_navbar(i18n("scan_hosts"), base_url .. "?", {{
|
|
active = page == "overview" or page == nil,
|
|
page_name = "overview",
|
|
label = "<i class=\"fas fa-lg fa-home\"></i>"
|
|
},{
|
|
hidden = not areAlertsEnabled() or not auth.has_capability(auth.capabilities.alerts),
|
|
active = page == "alerts",
|
|
page_name = "alerts",
|
|
label = "<i class='fas fa-lg fa-exclamation-triangle' title='" .. i18n("alerts_dashboard.alerts") .. "'></i>",
|
|
url = ntop.getHttpPrefix() .."/lua/alert_stats.lua?page=am_host&alert_id=4184%3Beq&is_va=true"
|
|
}, {
|
|
hidden = not ntop.isPro(),--not charts_available or page == "overview" or page == nil,
|
|
active = page == "va_historical",
|
|
page_name = "va_historical",
|
|
--url = ntop.getHttpPrefix() .."/lua/vulnerability_scan.lua?page=historical×eries_groups_mode=1_chart_x_metric×eries_groups=am_vuln_scan%3Anum_open_ports%3Dtrue%3Afalse%3Afalse%3Afalse%3Anum_configured_hosts%3Dtrue%3Afalse%3Afalse%3Afalse%3Anum_scans%3Dtrue%3Afalse%3Afalse%3Afalse%3Anum_cve%3Dtrue%3Afalse%3Afalse%3Afalse",
|
|
label = "<i class='fas fa-lg fa-chart-area' title='" .. i18n("historical") .. "'></i>"
|
|
}, {
|
|
active = page == "open_ports",
|
|
hidden = not ntop.isEnterpriseL(), -- disable the entry when the user is in the overview page
|
|
page_name = "open_ports",
|
|
label = i18n('hosts_stats.page_scan_hosts.num_open_ports')
|
|
},
|
|
{
|
|
active = page == "show_result",
|
|
hidden = page == "overview" or page == nil or page == "va_historical" or page == "scan_hosts" or page == "open_ports", -- disable the entry when the user is in the overview page
|
|
page_name = "show_result",
|
|
label = i18n('scan_details')
|
|
}})
|
|
|
|
|
|
local page = _GET["page"] or ('overview')
|
|
local ifid = interface.getId()
|
|
|
|
|
|
local scan_type = _GET["scan_type"]
|
|
local scan_date = _GET["scan_date"]
|
|
|
|
-- #######################################################
|
|
|
|
if (page == "scan_hosts" or page == "overview") then
|
|
local json_context = {
|
|
csrf = ntop.getRandomCSRFValue(),
|
|
ifid = ifid,
|
|
is_enterprise_l = ntop.isEnterpriseL(),
|
|
host = host_result
|
|
}
|
|
template.render("pages/vue_page.template", { vue_page_name = "PageHostsToScan", page_context = json.encode(json_context) })
|
|
|
|
elseif (page == "show_result") then
|
|
local json_context = {
|
|
csrf = ntop.getRandomCSRFValue(),
|
|
ifid = ifid,
|
|
host = host_result,
|
|
scan_type = scan_type,
|
|
date = scan_date
|
|
}
|
|
template.render("pages/vue_page.template", { vue_page_name = "PageHostVsResult", page_context = json.encode(json_context) })
|
|
|
|
elseif (page == "add_notification_rec") then
|
|
local json_context = {
|
|
csrf = ntop.getRandomCSRFValue(),
|
|
ifid = ifid,
|
|
host = host_result
|
|
}
|
|
template.render("pages/vue_page.template", { vue_page_name = "PageHostsVARecipient", page_context = json.encode(json_context) })
|
|
elseif (page == "open_ports") then
|
|
local json_context = {
|
|
csrf = ntop.getRandomCSRFValue(),
|
|
ifid = ifid,
|
|
is_enterprise_l = ntop.isEnterpriseL()
|
|
|
|
}
|
|
template.render("pages/vue_page.template", { vue_page_name = "PageOpenPorts", page_context = json.encode(json_context) })
|
|
|
|
|
|
elseif (page == "va_historical") then
|
|
|
|
local source_value_object = {
|
|
ifid = ifid,
|
|
is_va = true
|
|
--host = host_result
|
|
}
|
|
|
|
graph_utils.drawNewGraphs(source_value_object)
|
|
end
|
|
-- #######################################################
|
|
|
|
dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua")
|