-
Notifications
You must be signed in to change notification settings - Fork 3
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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): | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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]) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. W293 blank line contains whitespace |
||
return prefix == abs_directory | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. E999 SyntaxError: invalid syntax |
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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") | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. W291 trailing whitespace |
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. W293 blank line contains whitespace |
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
|
There was a problem hiding this comment.
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