-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Set safe default extraction filter for tar archives #19406
Set safe default extraction filter for tar archives #19406
Conversation
@nsoranzo Would it make sense to factor out all the |
d67c1a1
to
c71f410
Compare
That was a good idea suggestion, I've extended the existing |
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.
Looks great, thank you!
EDIT: test failures seem relevant.
[PEP 706](https://peps.python.org/pep-0706/), first implemented in Python 3.11.4, mitigates some of the security issues of `TarFile.extract()` and `TarFile.extractall()` by allowing to specify a `filter` keyword-only parameter. Set a safe default (`data_filter`) for the filter if available, reverting to Python 3.11 behavior ('fully_trusted') otherwise, see https://docs.python.org/3/library/tarfile.html#supporting-older-python-versions Also: - Remove unused `tar` parameter from `upload_tar()`
to ensure that the archive is closed.
c71f410
to
54df792
Compare
Fixed, thanks for the review! |
This PR was merged without a "kind/" label, please correct. |
PEP 706, first implemented in Python 3.11.4, mitigates some of the security issues of
TarFile.extract()
andTarFile.extractall()
by allowing to specify afilter
keyword-only parameter.Set a safe default (
data_filter
) for the filter if available, reverting to Python 3.11 behavior ('fully_trusted') otherwise, see https://docs.python.org/3/library/tarfile.html#supporting-older-python-versionsHow to test the changes?
(Select all options that apply)
License