Tracking more user activities: alerts deleted, all/inactive/interface data deleted, host data deleted, all/host data exproted

This commit is contained in:
Alfredo Cardigliano 2018-12-05 04:36:30 +01:00
parent a087fb3bc9
commit bc7283ce3f
5 changed files with 87 additions and 23 deletions

View file

@ -32,30 +32,29 @@ end
function tracker.hook(f, name)
return function(...)
local f_name
if name ~= nil then
f_name = name
else
local f_name = name
if f_name == nil then
f_name = debug.getinfo(1, "n").name
end
if f_name ~= nil then
local f_args = {}
for k, v in pairs({...}) do
if (f_name == 'addUser' and k == 3) or
(f_name == 'resetUserPassword' and k == 4) then
-- hiding password
f_args[k] = ''
else
f_args[k] = tostring(v)
end
local f_args = {}
for k, v in pairs({...}) do
if (f_name == 'addUser' and k == 3) or
(f_name == 'resetUserPassword' and k == 4) then
-- hiding password
f_args[k] = ''
else
f_args[k] = tostring(v)
end
tracker.log(f_name, f_args)
end
local result = {f(...)}
if f_name ~= nil then
tracker.log(f_name, f_args)
end
return table.unpack(result)
end
end
@ -90,7 +89,11 @@ function tracker.track_interface()
end
function tracker.track(table, fn)
table[fn] = tracker.hook(table[fn], fn)
if table[fn] ~= nil and type(table[fn]) == "function" then
table[fn] = tracker.hook(table[fn], fn)
else
io.write("tracker: "..fn.." is not defined or not a function\n")
end
end
-- #################################