mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add clean_id function to salt.utils.verify.py
This commit is contained in:
parent
c0ff69f88c
commit
63823f8c3e
1 changed files with 10 additions and 1 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue