Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DeprecationWarning] Resolve Warnings for Extraction Filters. #7832

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions python/dgl/data/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def check_sha1(filename, sha1_hash):
return sha1.hexdigest() == sha1_hash


def extract_archive(file, target_dir, overwrite=True):
def extract_archive(file, target_dir, overwrite=True, filter="data"):
"""Extract archive file.

Parameters
Expand Down Expand Up @@ -282,7 +282,9 @@ def safe_extract(
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, filter=filter
)

safe_extract(archive, path=target_dir)
elif file.endswith(".gz"):
Expand Down
6 changes: 4 additions & 2 deletions python/dgl/graphbolt/internal_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ def check_sha1(filename, sha1_hash):
return sha1.hexdigest() == sha1_hash


def extract_archive(file, target_dir, overwrite=True):
def extract_archive(file, target_dir, overwrite=True, filter="data"):
"""Extract archive file.

Parameters
Expand Down Expand Up @@ -351,7 +351,9 @@ def safe_extract(
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, filter=filter
)

safe_extract(archive, path=target_dir)
elif file.endswith(".gz"):
Expand Down
Loading