mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 15:39:33 +00:00
92 lines
3.4 KiB
Lua
92 lines
3.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
|
|
|
|
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>"
|
|
}, {
|
|
active = page == "show_result",
|
|
hidden = page == "overview" or page == nil, -- disable the entry when the user is in the overview page
|
|
page_name = "show_result",
|
|
label = i18n('scan_details')
|
|
},{
|
|
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"
|
|
}, {
|
|
hidden = true,--not charts_available or page == "overview" or page == nil,
|
|
active = page == "historical",
|
|
page_name = "historical",
|
|
--url = ntop.getHttpPrefix() .."/lua/vulnerability_scan.lua?page=historical×eries_groups_mode=1_chart_x_metric&ts_schema=host:host_tcp_unidirectional_flows&host="..ternary(host_result~=nil, host_result,"").."timeseries_groups=host;"..ternary(host_result~=nil, host_result,"")..";host:traffic;bytes_sent=true:false:false:false|bytes_rcvd=true:false:false:false",
|
|
label = "<i class='fas fa-lg fa-chart-area' title='" .. i18n("historical") .. "'></i>"
|
|
}})
|
|
|
|
|
|
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 == "historical") then
|
|
local source_value_object = {
|
|
ifid = ifid,
|
|
host = host_result,
|
|
}
|
|
graph_utils.drawNewGraphs(source_value_object)
|
|
end
|
|
|
|
-- #######################################################
|
|
|
|
dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua")
|