mirror of
https://github.com/browsermt/bergamot-translator.git
synced 2024-09-11 05:35:33 +03:00
Apply security update and formatting
This commit is contained in:
parent
6f2659fe59
commit
7d24908959
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@ -352,7 +352,7 @@ jobs:
|
|||||||
python3 -m pip install black isort pytype
|
python3 -m pip install black isort pytype
|
||||||
- name: "Formatting checks: black, isort"
|
- name: "Formatting checks: black, isort"
|
||||||
run: |
|
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
|
python3 -m isort --profile black --diff --check bindings/python setup.py doc/conf.py
|
||||||
- name: "Static typing checks: pytype"
|
- name: "Static typing checks: pytype"
|
||||||
run: |-
|
run: |-
|
||||||
|
2
3rd_party/ssplit-cpp
vendored
2
3rd_party/ssplit-cpp
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 8bc2f35b64f1012b8c31087610ab42f67aa70154
|
Subproject commit ad2c5a52a507ec5a1f58c6403fc674e76e92e185
|
@ -137,7 +137,26 @@ class TranslateLocallyLike(Repository):
|
|||||||
download_resource(model["url"], save_location)
|
download_resource(model["url"], save_location)
|
||||||
|
|
||||||
with tarfile.open(save_location) as model_archive:
|
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"])
|
fprefix = self._archive_name_without_extension(model["url"])
|
||||||
model_dir = os.path.join(self.dirs["models"], fprefix)
|
model_dir = os.path.join(self.dirs["models"], fprefix)
|
||||||
symlink = os.path.join(self.dirs["models"], model["code"])
|
symlink = os.path.join(self.dirs["models"], model["code"])
|
||||||
|
Loading…
Reference in New Issue
Block a user