From 1f34299a84ebc657c6c1cf1b2cac4aa3404cc960 Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Wed, 20 Jul 2016 16:20:58 -0600 Subject: [PATCH] Check if a valid value is passed to unlyif/unless --- salt/state.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/salt/state.py b/salt/state.py index 446e292d2e27..19e671f12975 100644 --- a/salt/state.py +++ b/salt/state.py @@ -51,6 +51,7 @@ # pylint: disable=import-error,no-name-in-module,redefined-builtin import salt.ext.six as six from salt.ext.six.moves import map, range +from salt.ext.six import string_types # pylint: enable=import-error,no-name-in-module,redefined-builtin log = logging.getLogger(__name__) @@ -786,6 +787,9 @@ def _run_check(self, low_data): else: low_data_onlyif = low_data['onlyif'] for entry in low_data_onlyif: + if not isinstance(entry, string_types): + ret.update({'comment': 'onlyif execution failed, bad type passed', 'result': False}) + return ret cmd = self.functions['cmd.retcode']( entry, ignore_retcode=True, python_shell=True, **cmd_opts) log.debug('Last command return code: {0}'.format(cmd)) @@ -804,6 +808,9 @@ def _run_check(self, low_data): else: low_data_unless = low_data['unless'] for entry in low_data_unless: + if not isinstance(entry, string_types): + ret.update({'comment': 'unless execution failed, bad type passed', 'result': False}) + return ret cmd = self.functions['cmd.retcode']( entry, ignore_retcode=True, python_shell=True, **cmd_opts) log.debug('Last command return code: {0}'.format(cmd))