two quick fixes for edgecase errors
@@ -439,6 +439,7 @@ class DevGet(object):
allowed_roles = []
if any(d['username'] == self._user for d in perm_dict['users']):
+ if perm_dict['user_roles'] is not None:
for user_role in perm_dict['user_roles']:
if user_role['username'] == self._user:
allowed_roles = user_role['roles']
@@ -506,12 +507,18 @@ class DevGet(object):
# pylint: disable=too-many-nested-blocks
+ # pylint: disable=too-many-branches
def can_run_cmd(self, cmd):
''' Return True/False for whether user is allowed to run the command
'''
can_run = False
+ try:
cmd_first_token = cmd.split()[0]
+ except IndexError:
+ log.exception('Cannot run command: %s', cmd)
+ return can_run
+
for commandbase, command in self._allowed_commands.iteritems():
# incoming command starts with one of the known command bases
if cmd_first_token == commandbase:
