Move rust-sdk wasm artifact into bundles directory

This commit is contained in:
Richard van der Hoff 2024-12-03 13:49:02 +00:00
parent a2a066d8b4
commit 91c6e0e07e
2 changed files with 34 additions and 16 deletions

View file

@ -53,11 +53,15 @@ def move_bundles(source, dest):
renames = {}
for f in os.listdir(source):
dst = os.path.join(dest, f)
# If this bundle already exists, then likely the same bundle is used in multiple
# versions of the app. There's no need to copy the bundle again; however we do
# update the mtime so that the cleanup script knows that the bundle is still used.
if os.path.exists(dst):
print(
"Skipping bundle. The bundle includes '%s' which we have previously deployed."
"Skipping bundle '%s' which we have previously deployed."
% f
)
os.utime(dst)
else:
renames[os.path.join(source, f)] = dst
@ -101,20 +105,20 @@ class Deployer:
def is_within_directory(directory, target):
abs_directory = os.path.abspath(directory)
abs_target = os.path.abspath(target)
prefix = os.path.commonprefix([abs_directory, abs_target])
return prefix == abs_directory
def safe_extract(tar, path=".", members=None, *, numeric_owner=False):
for member in tar.getmembers():
member_path = os.path.join(path, member.name)
if not is_within_directory(path, member_path):
raise Exception("Attempted Path Traversal in Tar File")
tar.extractall(path, members, numeric_owner=numeric_owner)
tar.extractall(path, members, numeric_owner=numeric_owner)
safe_extract(tar, extract_path)
finally:
if self.should_clean and downloaded: