-
Notifications
You must be signed in to change notification settings - Fork 543
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
[pylint] re-enable consider-using-{with, f-string} #3729
Merged
TurboTurtle
merged 1 commit into
sosreport:main
from
pponnuvel:re-enable-consider-using-with
Aug 8, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Extracting files one-by-one here. Had to check if the extracted path of files don't have relative paths and stay within the directory to handle "Arbitrary file write during tarfile extraction".
https://codeql.github.com/codeql-query-help/python/py-tarslip/
#3729 (review)
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.
Interesting: I was afraid of negative runtime impact of this change so I run cleaner on some sosreport tarball twice: once without the patch and once with the patch. The difference was statistically insignificant (a fraction of a second from 3m cleaner run).
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.
Thanks. I think that's a reasonable.
If we want to fix "Arbitrary file write during tarfile extraction", I think this is the only way (check each file and confirm). Alternative is to ignore it altogether (i.e. keep this code as before without this change) if we think the source tar file is always trustable.
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.
Looking at https://github.com/python/cpython/blob/main/Lib/tarfile.py#L2265,
extract()
andextractall()
pretty much work in the same way.The major difference between previous and the change in this PR is one additional syscall (
getcwd
) due toos.path.abspath
call. Cost of a singlegetcwd
call varies depending on few factors.A quick test on my system:
(a relatively low-spec system: 4CPU, i7-6500U CPU @ 2.50GHz, 12G memory)
So it takes about 4.5ms to 5.5ms on my system.
Let's round it up to 6ms per call. On a large sosreport I've (1.5GB), it contains ~180K file:
6ms (per getcwd call) * 180k files ~= 1.08 seconds extra time on my system. I'd think most servers where sosreports are manipulated/extracted are more powerful than my 2016 laptop (where I ran this test). So the extra cost would liekly be less than 1 second for a reasonably sized sosreport on a production server.
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.
I should add: please don't think I am trying to justify the change. I am simply too curious and woken up early on a Sunday morning ;-)
I am totally fine to revert this change if the conclusion is "we can always trust the source tar files here".