mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-05 19:15:03 +00:00
Added rest to map score to severity (#9005)
This commit is contained in:
parent
c6c47f727e
commit
76bfcc88ce
1 changed files with 29 additions and 0 deletions
29
scripts/lua/rest/v2/get/flow/alert/score_to_severity.lua
Normal file
29
scripts/lua/rest/v2/get/flow/alert/score_to_severity.lua
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
--
|
||||
-- (C) 2025 - ntop.org
|
||||
--
|
||||
local dirs = ntop.getDirs()
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
||||
|
||||
require "http_lint"
|
||||
local am_utils = require "am_utils"
|
||||
local auth = require "auth"
|
||||
local rest_utils = require "rest_utils"
|
||||
local alert_consts = require "alert_consts"
|
||||
|
||||
-- ################################################
|
||||
-- This REST converts a score to the severity label associated
|
||||
|
||||
local score = _GET["score"]
|
||||
|
||||
if isEmptyString(score) then
|
||||
rest_utils.answer(rest_utils.consts.err.missing_parameters, {"Please provide a score value to convert to severity"})
|
||||
end
|
||||
|
||||
local severity_label = alert_consts.alertSeverityLabel(tonumber(score), true) -- true to remove html and only get severity label
|
||||
|
||||
local res = {
|
||||
["severityLabel"] = severity_label
|
||||
}
|
||||
|
||||
rest_utils.answer(rest_utils.consts.success.ok, res)
|
||||
Loading…
Add table
Add a link
Reference in a new issue