Module: check_mk
Branch: master
Commit: c44b59c563da41691325fefc2792f2396a091692
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c44b59c563da41…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Mar 9 15:11:22 2016 +0100
3282 FIX Fixed missing validation of network scan properties
The intended validation of network scan properties was not performed correctly.
This was some kind general issue which might also have affected other attributes,
but maybe only the network scan properties were affected.
---
.werks/3282 | 12 ++++++++++++
ChangeLog | 1 +
web/htdocs/wato.py | 14 ++------------
web/htdocs/watolib.py | 19 ++++++++++++++++---
web/plugins/wato/builtin_attributes.py | 2 +-
5 files changed, 32 insertions(+), 16 deletions(-)
diff --git a/.werks/3282 b/.werks/3282
new file mode 100644
index 0000000..fae68c4
--- /dev/null
+++ b/.werks/3282
@@ -0,0 +1,12 @@
+Title: Fixed missing validation of network scan properties
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1457532610
+
+The intended validation of network scan properties was not performed correctly.
+This was some kind general issue which might also have affected other attributes,
+but maybe only the network scan properties were affected.
diff --git a/ChangeLog b/ChangeLog
index 283d591..31bc0ae 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -114,6 +114,7 @@
* 3091 FIX: fixed failure to rename hosts in raw edition...
* 3280 FIX: Fixed too often executed network scans...
* 3281 FIX: Fixed network scan overwriting folder modifications made during the scan
+ * 3282 FIX: Fixed missing validation of network scan properties...
Notifications:
* 3263 Notifications: allow users to restrict by their contact groups...
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 84c2e65..6fa1e64 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -15466,20 +15466,10 @@ def configure_attributes(new, hosts, for_what, parent,
myself=None, without_attr
if configured_host_tags():
topics.append(_("Host tags"))
- # Hide invisible attributes
- def hide_attribute(for_what, attr):
- if for_what in [ "host", "bulk" ] and not
attr.show_in_form():
- return True
- elif for_what == "folder" and not attr.show_in_folder():
- return True
- elif for_what == "host_search" and not attr.show_in_host_search():
- return True
- return False
-
# The remaining topics are shown in the order of the
# appearance of the attribute declarations:
for attr, topic in all_host_attributes():
- if topic not in topics and not hide_attribute(for_what, attr):
+ if topic not in topics and attr.is_visible(for_what):
topics.append(topic)
# Collect dependency mapping for attributes (attributes that are only
@@ -15512,7 +15502,7 @@ def configure_attributes(new, hosts, for_what, parent,
myself=None, without_attr
continue # e.g. needed to skip ipaddress in CSV-Import
# Determine visibility information if this attribute is not always hidden
- if not hide_attribute(for_what, attr):
+ if attr.is_visible(for_what):
depends_on_tags = attr.depends_on_tags()
depends_on_roles = attr.depends_on_roles()
# Add host tag dependencies, but only in host mode. In other
diff --git a/web/htdocs/watolib.py b/web/htdocs/watolib.py
index 1c4a052..b3bc60c 100644
--- a/web/htdocs/watolib.py
+++ b/web/htdocs/watolib.py
@@ -2310,11 +2310,24 @@ class Attribute:
# Check whether this attribute needs to be validated at all
# Attributes might be permanently hidden (show_in_form = False)
# or dynamically hidden by the depends_on_tags, editable features
- def needs_validation(self):
- if not self._show_in_form:
+ def needs_validation(self, for_what):
+ if not self.is_visible(for_what):
return False
return html.var('attr_display_%s' % self._name, "1") ==
"1"
+
+ # Gets the type of current view as argument and returns whether or not
+ # this attribute is shown in this type of view
+ def is_visible(self, for_what):
+ if for_what in [ "host", "bulk" ] and not
self.show_in_form():
+ return False
+ elif for_what == "folder" and not self.show_in_folder():
+ return False
+ elif for_what == "host_search" and not self.show_in_host_search():
+ return False
+ return True
+
+
# Check if the value entered by the user is valid.
# This method may raise MKUserError in case of invalid user input.
def validate_input(self, varprefix):
@@ -2807,7 +2820,7 @@ def collect_attributes(for_what, do_validate = True,
varprefix=""):
if not html.var(for_what + "_change_%s" % attrname, False):
continue
- if do_validate and attr.needs_validation():
+ if do_validate and attr.needs_validation(for_what):
attr.validate_input(varprefix)
host[attrname] = attr.from_html_vars(varprefix)
diff --git a/web/plugins/wato/builtin_attributes.py
b/web/plugins/wato/builtin_attributes.py
index 8657c19..b58d653 100644
--- a/web/plugins/wato/builtin_attributes.py
+++ b/web/plugins/wato/builtin_attributes.py
@@ -161,7 +161,7 @@ class NetworkScanAttribute(ValueSpecAttribute):
title = _("Scan interval"),
display = [ "days", "hours" ],
default_value = 60*60*24,
- min_value = 3600, # 1 hour
+ minvalue = 3600, # 1 hour
)),
("max_parallel_pings", Integer(
title = _("Parallel pings to send"),