Apply security update and formatting

This commit is contained in:
Nikolay Bogoychev 2023-01-18 16:46:07 +00:00
parent 6f2659fe59
commit 7d24908959
4 changed files with 25 additions and 6 deletions

View File

@ -352,7 +352,7 @@ jobs:
python3 -m pip install black isort pytype
- name: "Formatting checks: black, isort"
run: |
python3 -m black --check bindings/python/ setup.py doc/conf.py
python3 -m black --diff --check bindings/python/ setup.py doc/conf.py
python3 -m isort --profile black --diff --check bindings/python setup.py doc/conf.py
- name: "Static typing checks: pytype"
run: |-

View File

@ -1,6 +1,6 @@
name: "Coding Style"
on:
on:
push:
branches: [ main, ci-sandbox ]
pull_request:
@ -18,7 +18,7 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get update
sudo apt-get install -y build-essential cmake
sudo apt-get install -y clang-format clang-tidy
@ -30,7 +30,7 @@ jobs:
- name: Prepare build, compilation database etc.
run: |
mkdir -p build
cd build
cd build
cmake \
-DUSE_WASM_COMPATIBLE_SOURCE=off -DCMAKE_EXPORT_COMPILE_COMMANDS=on \
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \

@ -1 +1 @@
Subproject commit 8bc2f35b64f1012b8c31087610ab42f67aa70154
Subproject commit ad2c5a52a507ec5a1f58c6403fc674e76e92e185

View File

@ -137,7 +137,26 @@ class TranslateLocallyLike(Repository):
download_resource(model["url"], save_location)
with tarfile.open(save_location) as model_archive:
model_archive.extractall(self.dirs["models"])
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)
safe_extract(model_archive, self.dirs["models"])
fprefix = self._archive_name_without_extension(model["url"])
model_dir = os.path.join(self.dirs["models"], fprefix)
symlink = os.path.join(self.dirs["models"], model["code"])