Return rest failure when check is not enabled (#7170)

This commit is contained in:
Alfredo Cardigliano 2023-01-30 17:37:03 +01:00
parent e7a6059abb
commit c47858004d
3 changed files with 32 additions and 13 deletions

View file

@ -10,6 +10,8 @@ require "lua_utils"
local auth = require "auth"
local rest_utils = require "rest_utils"
local all_alert_store = require "all_alert_store".new()
local alert_entities = require "alert_entities"
local checks = require "checks"
--
-- Trigger a custom host alert
@ -30,6 +32,11 @@ if not auth.has_capability(auth.capabilities.alerts) then
return
end
if not checks.isCheckEnabled("host", "external_host_script") then
rest_utils.answer(rest_utils.consts.err.not_enabled)
return
end
if isEmptyString(ifid) then
rc = rest_utils.consts.err.invalid_interface
rest_utils.answer(rc)