mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-03 17:30:11 +00:00
add notification for unexpected plugins (#4659)
This commit is contained in:
parent
109c79eafa
commit
cf16003826
18 changed files with 184 additions and 153 deletions
|
|
@ -5,18 +5,20 @@
|
|||
local user_scripts = require("user_scripts")
|
||||
local flow_consts = require("flow_consts")
|
||||
|
||||
local UNEXPECTED_PLUGINS_ENABLED_CACHE_KEY = "ntopng.cache.user_scripts.unexpected_plugins_enabled"
|
||||
|
||||
-- #################################################################
|
||||
|
||||
local script = {
|
||||
-- Script category
|
||||
category = user_scripts.script_categories.security,
|
||||
category = user_scripts.script_categories.security,
|
||||
|
||||
-- Priority
|
||||
prio = -20, -- Lower priority (executed after) than default 0 priority
|
||||
|
||||
-- This module is disabled by default
|
||||
default_enabled = false,
|
||||
|
||||
|
||||
-- NOTE: hooks defined below
|
||||
hooks = {},
|
||||
|
||||
|
|
@ -41,20 +43,30 @@ local script = {
|
|||
|
||||
-- #################################################################
|
||||
|
||||
function script.onEnable(hook, hook_config)
|
||||
-- Set a flag to indicate to the notifications system that an unexpected plugin
|
||||
-- has been enabled
|
||||
if isEmptyString(ntop.getCache(UNEXPECTED_PLUGINS_ENABLED_CACHE_KEY)) then
|
||||
ntop.setCache(UNEXPECTED_PLUGINS_ENABLED_CACHE_KEY, "1")
|
||||
end
|
||||
end
|
||||
|
||||
-- #################################################################
|
||||
|
||||
function script.hooks.protocolDetected(now, conf)
|
||||
if flow.isServerUnicast() then
|
||||
if(table.len(conf.items) > 0) then
|
||||
local ok = 0
|
||||
local flow_info = flow.getInfo()
|
||||
local server_ip = flow_info["srv.ip"]
|
||||
|
||||
|
||||
for _, dns_ip in pairs(conf.items) do
|
||||
if server_ip == dns_ip then
|
||||
ok = 1
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if ok == 0 then
|
||||
flow.triggerStatus(
|
||||
flow_consts.status_types.status_unexpected_dhcp.create(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue