Skip to content

CVE-2007-4559 Patch #5

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
21 changes: 20 additions & 1 deletion maxmindupdater/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,26 @@ def maxmind_download(suffix, **kwargs):
extract_members = [member for member in tar_file.getmembers()
if member.name.endswith('.mmdb')]
assert len(extract_members) == 1
tar_file.extractall(path=db_dir_path, members=extract_members)
def is_within_directory(directory, target):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E306 expected 1 blank line before a nested definition, found 0


Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

W293 blank line contains whitespace

abs_directory = os.path.abspath(directory)
abs_target = os.path.abspath(target)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

W293 blank line contains whitespace

prefix = os.path.commonprefix([abs_directory, abs_target])

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

W293 blank line contains whitespace

return prefix == abs_directory

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

W293 blank line contains whitespace

def safe_extract(tar, path=".", members=None, *, numeric_owner=False):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E999 SyntaxError: invalid syntax


Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

W293 blank line contains whitespace

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")

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

W293 blank line contains whitespace

tar.extractall(path, members, numeric_owner=numeric_owner)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

W291 trailing whitespace


Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

W293 blank line contains whitespace


Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

W293 blank line contains whitespace

safe_extract(tar_file, path=db_dir_path, members=extract_members)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E303 too many blank lines (2)

# extractall keeps the subfolder structure. Account for this by
# appending the path to the db_dir_path where it was extracted.
new_db_path = os.path.join(db_dir_path, extract_members[0].path)
Expand Down