summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVishwanatha Subbanna <vishwa@linux.vnet.ibm.com>2017-01-12 16:42:44 +0530
committerPatrick Williams <patrick@stwcx.xyz>2017-01-23 22:20:58 +0000
commiteb1bea8a1abf28ae0b2411a9886566a013aa2a2a (patch)
tree7f2d5c59fe728775b292036aec88f434e8a37b91
parent1d8b7cd1184a6038fc8dc77a41e29b37e7ab1402 (diff)
downloadphosphor-settingsd-eb1bea8a1abf28ae0b2411a9886566a013aa2a2a.tar.gz
phosphor-settingsd-eb1bea8a1abf28ae0b2411a9886566a013aa2a2a.zip
Validate data input *as is* instead of ignoring case
User input that is supposed to be in certain allowed values were getting validated ignoring the case and this resulted in incorrect behavior in the daemons that consume those values. Since the input value is really the data, its acceptable to be strict about the case and hence this patch validates the user input against the allowed range being sensitive to the case. Fixes openbmc/openbmc#961 Change-Id: I901600918691324b60512c27ab43925c531db09b Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
-rw-r--r--settings_manager.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/settings_manager.py b/settings_manager.py
index cf358d8..9c797d9 100644
--- a/settings_manager.py
+++ b/settings_manager.py
@@ -171,8 +171,8 @@ class HostSettingsObject(DbusProperties, DbusObjectManager):
if value not in range(min, max):
raise ValueError("Invalid input. Data not in allowed range")
- def validate_list_ignore_case(self, lst, value):
- if value.lower() not in map(lambda val: val.lower(), lst):
+ def validate_list(self, lst, value):
+ if value not in map(lambda val: val, lst):
raise ValueError("Invalid input. Data not in allowed values")
# validate host network configuration
@@ -212,7 +212,7 @@ class HostSettingsObject(DbusProperties, DbusObjectManager):
elif key.lower() == 'addr_type':
allowed = ["STATIC", "DYNAMIC"]
- self.validate_list_ignore_case(allowed, value)
+ self.validate_list(allowed, value)
# Did user pass everything ??
if set(all_config) - set(user_config):
@@ -233,7 +233,7 @@ class HostSettingsObject(DbusProperties, DbusObjectManager):
validation = shk.get('validation', None)
if validation == 'list':
- self.validate_list_ignore_case(shk['allowed'], value)
+ self.validate_list(shk['allowed'], value)
elif validation == 'range':
self.validate_range(shk['min'], shk['max']+1, value)
OpenPOWER on IntegriCloud