Skip to content

Commit f0a0253

Browse files
committed
18194 FIX Host check command: crash when using "Use a custom check plug-in" option
When setting the "Use a custom check plug-in" option for the Host check command ruleset and then logging in as a normal monitoring user without the permission to configure this option, this would lead to a crash to both the UI and the REST API. Now this option is still being display but not editable by users without permission. SUP-23384 Change-Id: Id709889822f854f3010324944b64507828769a55
1 parent c73ca29 commit f0a0253

3 files changed

Lines changed: 26 additions & 5 deletions

File tree

.werks/18194

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Title: Host check command: crash when using "Use a custom check plug-in" option
2+
Class: fix
3+
Compatible: compat
4+
Component: wato
5+
Date: 1753255863
6+
Edition: cre
7+
Level: 1
8+
Version: 2.2.0p45
9+
10+
When setting the "Use a custom check plug-in" option for the Host check command ruleset
11+
and then logging in as a normal monitoring user without the permission to configure this
12+
option, this would lead to a crash to both the UI and the REST API.
13+
14+
Now this option is still being display but not editable by users without permission.

cmk/gui/plugins/wato/check_mk_configuration.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3562,11 +3562,12 @@ def _host_check_commands_host_check_command_choices() -> list[CascadingDropdownC
35623562
),
35633563
),
35643564
),
3565+
(
3566+
"custom",
3567+
_("Use a custom check plug-in..."),
3568+
PluginCommandLine(read_only=not user.may("wato.add_or_modify_executables")),
3569+
),
35653570
]
3566-
3567-
if user.may("wato.add_or_modify_executables"):
3568-
choices.append(("custom", _("Use a custom check plugin..."), PluginCommandLine()))
3569-
35703571
return choices
35713572

35723573

cmk/gui/plugins/wato/utils/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,13 @@ def title(self) -> str:
214214
return _("Setup")
215215

216216

217-
def PluginCommandLine() -> ValueSpec:
217+
def PluginCommandLine(read_only: bool = False) -> ValueSpec:
218218
def _validate_custom_check_command_line(value, varprefix):
219+
if read_only:
220+
raise MKUserError(
221+
varprefix,
222+
_("You are not allowed to change the command line of a custom check plug-in."),
223+
)
219224
if "--pwstore=" in value:
220225
raise MKUserError(
221226
varprefix, _("You are not allowed to use passwords from the password store here.")
@@ -231,6 +236,7 @@ def _validate_custom_check_command_line(value, varprefix):
231236
)
232237
+ monitoring_macro_help(),
233238
size="max",
239+
read_only=read_only,
234240
validate=_validate_custom_check_command_line,
235241
)
236242

0 commit comments

Comments
 (0)