File add-clean_id-function-to-salt.utils.verify.py.patch of Package salt

From 961288bc58795933d250fc13f21c10b66d4a7e36 Mon Sep 17 00:00:00 2001
From: Ch3LL <megan.wilhite@gmail.com>
Date: Mon, 31 Jul 2017 11:50:21 -0400
Subject: [PATCH] Add clean_id function to salt.utils.verify.py

---
 salt/utils/verify.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/salt/utils/verify.py b/salt/utils/verify.py
index 45581f02ce..3d606fe135 100644
--- a/salt/utils/verify.py
+++ b/salt/utils/verify.py
@@ -481,6 +481,15 @@ 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
@@ -488,7 +497,7 @@ def valid_id(opts, id_):
     try:
         if any(x in id_ for x in ('/', '\\', '\0')):
             return False
-        return bool(clean_path(opts['pki_dir'], id_))
+        return bool(clean_path(opts['pki_dir'], id_)) and clean_id(id_)
     except (AttributeError, KeyError, TypeError):
         return False
 
-- 
2.17.1


openSUSE Build Service is sponsored by