Skip to content

Commit

Permalink
fix: Security Hotspot
Browse files Browse the repository at this point in the history
  • Loading branch information
devrimyatar committed Apr 29, 2022
1 parent 865647e commit 1899a39
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
8 changes: 4 additions & 4 deletions jans-linux-setup/jans_setup/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ def extract_setup():
jans_zip = zipfile.ZipFile(jans_zip_file)
parent_dir = jans_zip.filelist[0].orig_filename

with tempfile.TemporaryDirectory() as tmp_dir:
jans_zip.extractall(tmp_dir)
shutil.copytree(os.path.join(tmp_dir, parent_dir, 'jans-linux-setup/jans_setup'), argsp.setup_dir)

tmp_dir = os.path.join(jans_app_dir, os.urandom(4).hex())
jans_zip.extractall(tmp_dir)
shutil.copytree(os.path.join(tmp_dir, parent_dir, 'jans-linux-setup/jans_setup'), argsp.setup_dir)
jans_zip.close()
shutil.rmtree(tmp_dir)

target_setup = os.path.join(argsp.setup_dir, 'setup.py')
if not os.path.exists(target_setup):
Expand Down
4 changes: 3 additions & 1 deletion jans-linux-setup/jans_setup/setup_app/installers/fido.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ def copy_static(self):
)

#copy fido2 server metadata
target = os.path.join(self.fido2ConfigFolder, 'server_metadata')
self.copyTree(
os.path.join(Config.install_dir, 'static/fido2/server_metadata'),
os.path.join(self.fido2ConfigFolder, 'server_metadata')
os.path.join(self.fido2ConfigFolder, 'server_metadata'),
except_list=['.dontdelete']
)

# copy Apple_WebAuthn_Root_CA
Expand Down
11 changes: 6 additions & 5 deletions jans-linux-setup/jans_setup/setup_app/utils/setup_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,14 @@ def copyFile(self, inFile, destFolder, backup=True):
except:
self.logIt("Error copying %s to %s" % (inFile, destFolder), True)

def copyTree(self, src, dst, overwrite=False):
def copyTree(self, src, dst, overwrite=False, except_list=[]):
try:
if not os.path.exists(dst):
os.makedirs(dst)

for item in os.listdir(src):
if item in except_list:
continue
s = os.path.join(src, item)
d = os.path.join(dst, item)
if os.path.isdir(s):
Expand All @@ -263,13 +265,12 @@ def copyTree(self, src, dst, overwrite=False):
if not os.path.exists(d) or os.stat(s).st_mtime - os.stat(d).st_mtime > 1:
with open(s, 'rb') as fi:
cur_content = fi.read()
self.backupFile(s, d, cur_content=cur_content)
self.backupFile(s, d, cur_content=cur_content)
shutil.copy2(s, d)


self.logIt("Copied tree %s to %s" % (src, dst))
except:
self.logIt("Error copying tree %s to %s" % (src, dst), True)
except Exception as e:
self.logIt("Error copying tree {} to {}: {}".format(src, dst, e), True)

def createDirs(self, name):
try:
Expand Down

0 comments on commit 1899a39

Please sign in to comment.