Module: check_mk
Branch: master
Commit: 49301cf591e919f9c0c4de17596d268a75b8d4a1
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=49301cf591e919…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Apr 3 08:49:34 2019 +0200
7334 FIX Prevent tag groups with a single choice (checkbox) and empty tag ID
In previous versions it was possible to create tag groups that had a single
choice (shown as checkbox) and an empty tag ID for this single choice. This
was not intended and was not usable at all. The tag management GUI and API
calls are now preventing this configuration.
Change-Id: I59bbbd63a909f14c8f0c0b07b4cc7ab344ef4f6a
---
.werks/7334 | 14 ++++++++++++++
cmk/gui/tags.py | 7 +++++++
2 files changed, 21 insertions(+)
diff --git a/.werks/7334 b/.werks/7334
new file mode 100644
index 0000000..8ac2b22
--- /dev/null
+++ b/.werks/7334
@@ -0,0 +1,14 @@
+Title: Prevent tag groups with a single choice (checkbox) and empty tag ID
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1554216866
+
+In previous versions it was possible to create tag groups that had a single
+choice (shown as checkbox) and an empty tag ID for this single choice. This
+was not intended and was not usable at all. The tag management GUI and API
+calls are now preventing this configuration.
diff --git a/cmk/gui/tags.py b/cmk/gui/tags.py
index 51da12c..7a194d9 100644
--- a/cmk/gui/tags.py
+++ b/cmk/gui/tags.py
@@ -467,10 +467,17 @@ class TagConfig(object):
if tag.id or tag.title:
if not tag.id:
tag.id = None
+
+ if len(tag_group.tags) == 1:
+ raise MKUserError("choices_%d_id" % (nr + 1),
+ _("Can not use an empty tag ID with a
single choice."))
+
if have_none_tag:
raise MKUserError("choices_%d_id" % (nr + 1),
_("Only one tag may be empty."))
+
have_none_tag = True
+
# Make sure tag ID is unique within this group
for (n, x) in enumerate(tag_group.tags):
if n != nr and x.id == tag.id: