Module: check_mk
Branch: master
Commit: fad8ae06e20c448b8a2c61e7ac9b5a57fb690ed4
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=fad8ae06e20c44…
Author: Andreas <ab(a)mathias-kettner.de>
Date: Wed Jun 20 15:20:11 2018 +0200
6231 FIX WATO GUI rule matching: Fixed broken evaluation of negated WATO rules
The rule matching algorithm failed, if there was a negated service or item specified.
Instead of a negative match, a positive match was returned. This has been fixed.
Note: This was a GUI only bug, it didn't have any effect on the actual monitoring.
Change-Id: Id9d737f10df4536db5ab250e3015812b86278c98
---
.werks/6231 | 16 ++++++++++++++++
web/htdocs/watolib.py | 9 +++++++--
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/.werks/6231 b/.werks/6231
new file mode 100644
index 0000000..0ad7689
--- /dev/null
+++ b/.werks/6231
@@ -0,0 +1,16 @@
+Title: WATO GUI rule matching: Fixed broken evaluation of negated WATO rules
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1529500572
+
+The rule matching algorithm failed, if there was a negated service or item specified.
+Instead of a negative match, a positive match was returned. This has been fixed.
+Note: This was a GUI only bug, it didn't have any effect on the actual monitoring.
+
+
+
diff --git a/web/htdocs/watolib.py b/web/htdocs/watolib.py
index a570767..e3f1493 100644
--- a/web/htdocs/watolib.py
+++ b/web/htdocs/watolib.py
@@ -8428,8 +8428,13 @@ class Rule(object):
def matches_item(self, item):
for item_spec in self.item_list:
- if re.match(item_spec, "%s" % item):
- return True
+ do_negate = False
+ compare_item = item_spec
+ if compare_item and compare_item[0] == ENTRY_NEGATE_CHAR:
+ compare_item = compare_item[1:]
+ do_negate = True
+ if re.match(compare_item, "%s" % item):
+ return not do_negate
return False