Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
zphang committed Oct 17, 2022
1 parent 132f07f commit 8d13a82
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions jiant/scripts/download_data/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,25 +91,25 @@ def download_and_untar(url, extract_location):
def untar_file(tar_path, extract_location, delete=False):
"""Untars a file, optionally deleting after"""
with tarfile.open(tar_path) as tar:

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, path=extract_location)
if delete:
os.remove(tar_path)
Expand Down
2 changes: 1 addition & 1 deletion jiant/shared/initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def get_seed(seed):
"""
if seed == -1:
return int(np.random.randint(0, 2**32 - 1))
return int(np.random.randint(0, 2 ** 32 - 1))
else:
return seed

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"datasets == 1.1.2",
"nltk >= 3.5",
"numexpr == 2.7.1",
"numpy == 1.18.4",
"numpy == 1.19",
"pandas == 1.0.3",
"python-Levenshtein == 0.12.0",
"sacremoses == 0.0.43",
Expand Down

0 comments on commit 8d13a82

Please sign in to comment.