Skip to content

Commit

Permalink
Merge pull request #42944 from Ch3LL/2016.11.6_follow_up
Browse files Browse the repository at this point in the history
[2016.11] Add clean_id function to salt.utils.verify.py
  • Loading branch information
Nicole Thomas committed Aug 15, 2017
2 parents 49d339c + 7e0a20a commit 6366e05
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion salt/utils/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,12 +481,21 @@ def clean_path(root, path, subdir=False):
return ''


def clean_id(id_):
'''
Returns if the passed id is clean.
'''
if re.search(r'\.\.{sep}'.format(sep=os.sep), id_):
return False
return True


def valid_id(opts, id_):
'''
Returns if the passed id is valid
'''
try:
return bool(clean_path(opts['pki_dir'], id_))
return bool(clean_path(opts['pki_dir'], id_)) and clean_id(id_)
except (AttributeError, KeyError) as e:
return False

Expand Down

0 comments on commit 6366e05

Please sign in to comment.