Module: check_mk
Branch: master
Commit: 511ca69dd06065a1bdceb7a5b9fd59884b277e1e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=511ca69dd06065…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Mar 5 15:34:57 2018 +0100
5887 FIX Protect against checks overriding Check_MK internal config variables
When a check declares a Check_MK internal configuration variable in it's global
namespace, for example "service_descriptions", it was overrding Check_MK
internal
configuration variables with this statement in previous Check_MK versions.
Check_MK now prevents the checks from overriding already known configuration
variables.
Change-Id: I132a2d651d3a3b8e69bfb97a806cae53f1fccb4b
---
.werks/5887 | 15 +++++++++++++++
cmk_base/checks.py | 7 +++++++
2 files changed, 22 insertions(+)
diff --git a/.werks/5887 b/.werks/5887
new file mode 100644
index 0000000..53cdf4e
--- /dev/null
+++ b/.werks/5887
@@ -0,0 +1,15 @@
+Title: Protect against checks overriding Check_MK internal config variables
+Level: 1
+Component: core
+Compatible: compat
+Edition: cre
+Version: 1.5.0i4
+Date: 1520260398
+Class: fix
+
+When a check declares a Check_MK internal configuration variable in it's global
+namespace, for example "service_descriptions", it was overrding Check_MK
internal
+configuration variables with this statement in previous Check_MK versions.
+
+Check_MK now prevents the checks from overriding already known configuration
+variables.
diff --git a/cmk_base/checks.py b/cmk_base/checks.py
index e84da07..debe872 100644
--- a/cmk_base/checks.py
+++ b/cmk_base/checks.py
@@ -106,6 +106,8 @@ def load_checks(filelist):
# Initialize some data structures which are populated while loading the checks
_check_variables.clear()
+ cmk_global_vars = set(config.get_variable_names())
+
loaded_files = set()
check_variable_defaults = {}
ignored_variable_types = [ type(lambda: None), type(os) ]
@@ -164,6 +166,11 @@ def load_checks(filelist):
# Save check variables for e.g. after config loading that the config can
# be added to the check contexts
for varname, value in new_check_vars.items():
+ # Do not allow checks to override Check_MK builtin global variables.
Silently
+ # skip them here. The variables will only be locally available to the
checks.
+ if varname in cmk_global_vars:
+ continue
+
if varname[0] != '_' and type(value) not in ignored_variable_types:
check_variable_defaults[varname] = value