Skip to content

Commit

Permalink
test(file): fix safe_extract()
Browse files Browse the repository at this point in the history
  • Loading branch information
breakthewall committed Dec 7, 2023
1 parent 984d706 commit f8dbe01
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion brs_utils/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,12 @@ def safe_extract(tar, path=".", members=None, *, numeric_owner=False):
if not is_within_directory(path, member_path):
raise Exception("Attempted Path Traversal in Tar File")

tar.extractall(path, members, numeric_owner=numeric_owner)
if members:
_members = [x for x in tar.getmembers() if x.name in members]
else:
_members = None

tar.extractall(path, _members, numeric_owner=numeric_owner)


def extract_tar_gz(
Expand Down

0 comments on commit f8dbe01

Please sign in to comment.