Added rest to map score to severity (#9005)

This commit is contained in:
GabrieleDeri 2025-02-26 21:53:54 +01:00 committed by GitHub
parent c6c47f727e
commit 76bfcc88ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View 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)