Module: check_mk
Branch: master
Commit: 5b78bb4fb05e0df3a41386f4b00e801f4755a1bd
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5b78bb4fb05e0d…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Wed Feb 7 14:25:02 2018 +0100
Validation of performance data values: raise if one contains spaces
Change-Id: Ic5d15284a2587dd3208441f0fd013666c3b6b32a
---
cmk_base/checking.py | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/cmk_base/checking.py b/cmk_base/checking.py
index d5c696c..dc4764b 100644
--- a/cmk_base/checking.py
+++ b/cmk_base/checking.py
@@ -489,6 +489,7 @@ def _item_not_found(is_snmp):
def _sanitize_tuple_check_result(result, allow_missing_infotext=False):
if len(result) >= 3:
state, infotext, perfdata = result[:3]
+ _validate_perf_data_values(perfdata)
else:
state, infotext = result
perfdata = None
@@ -498,6 +499,15 @@ def _sanitize_tuple_check_result(result, allow_missing_infotext=False):
return state, infotext, perfdata
+def _validate_perf_data_values(perfdata):
+ if not isinstance(perfdata, list):
+ return
+ for v in [value for entry in perfdata for value in entry[1:]]:
+ if " " in str(v):
+ # See Nagios performance data spec for detailed information
+ raise MKGeneralException("Performance data values must not contain spaces")
+
+
def _sanitize_check_result_infotext(infotext, allow_missing_infotext):
if infotext == None and not allow_missing_infotext:
raise MKGeneralException("Invalid infotext from check: \"None\"")
Module: check_mk
Branch: master
Commit: 5bd5d70a296363bd0059583ce126842f91e0d71e
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5bd5d70a296363…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Wed Feb 7 13:31:30 2018 +0100
Check tests: Add some conditions to what constitutes a proper perfvalue key
Change-Id: I36f5fe58485587cae7c888afe306722f6036601b
---
tests/checks/checktestlib.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tests/checks/checktestlib.py b/tests/checks/checktestlib.py
index 86691f0..dbabbcc 100644
--- a/tests/checks/checktestlib.py
+++ b/tests/checks/checktestlib.py
@@ -29,6 +29,9 @@ class PerfValue(Tuploid):
# in what kind of values are allowed as metric names.
# I'm not too sure unicode should be allowed, either.
assert type(key) in [str, unicode]
+ assert " " not in key # This leads to serious errors
+ assert "=" not in key # The parsing around this is way too funky and doesn't work properly
+ assert "\n" not in key
self.key = key
# NOTE: The CMC as well as all other Nagios-compatible cores do accept a