Merge pull request #42945 from Ch3LL/2017.7.0_follow_up

[2017.7] Add clean_id function to salt.utils.verify.py
This commit is contained in:
Nicole Thomas 2017-08-15 14:04:19 -04:00 committed by GitHub
commit 95645d49f9

View file

@ -480,12 +480,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, TypeError) as e:
return False