-
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
Fix PEP706 warning #3319
Comments
The more I read about the Therefore I would go for Any objections or thoughts, @TurboTurtle , @arif-ali or @mhradile ? |
No objections. Definitely for closing that security hole. |
No objections here. |
Since Python 3.12, archive.extractall would require setting an extraction filter otherwise an exception is raised. See PEP 706 for more. Since sos extracts just tarballs that should be compliant with safe extraction (no extracted file outside the target directory etc.), we should stick to the data filter. Relevant: sosreport#3319 Closes: sosreport#3330 Signed-off-by: Pavel Moravec <[email protected]>
makes sense |
Since Python 3.12, archive.extractall would require setting an extraction filter otherwise an exception is raised. See PEP 706 for more. Since Python 3.10 and 3.11 can raise false alarms as exceptions (see sosreport#3330 for examples), we must use the legacy fully_trusted filter. Relevant: sosreport#3319 Closes: sosreport#3330 Signed-off-by: Pavel Moravec <[email protected]>
Since Python 3.12, archive.extractall would require setting an extraction filter otherwise an exception is raised. See PEP 706 for more. Since Python 3.10 and 3.11 can raise false alarms as exceptions (see #3330 for examples), we must use the legacy fully_trusted filter. Relevant: #3319 Closes: #3330 Signed-off-by: Pavel Moravec <[email protected]>
Can we close this in favor of PR #3330 ? |
Indeed we can. |
Since Python 3.12, a new warning will be raised in
sos/cleaner/archives/__init__.py
:archive.extractall(path)
. The call will emit a warning by default. See https://peps.python.org/pep-0706/ for background / rationale.To prevent that, we can add something like this before the call:
This is compatible with unpatched versions of Python, and for patched Python it is equivalent to the call:
archive.extractall(path, filter='data')
.The 'data' filter above attempts a "safe" extraction, intended for pure data archives. For example:
See PEP 706 for details: https://peps.python.org/pep-0706/#filters
If we trust the tarball, we should use
'fully_trusted_filter'
(orfilter='fully_trusted'
) instead. That will preserve the existing behavior.I feel we shall stick on the current behaviour (which still means a code change but with
fully_trusted_filter
attr option) since the extracted archive might(?) break some assumptions (i.e. the symlinks?) imposed to the safe extraction in some use cases - I am afraid usingdata_filter
could end up in raising uncaught warnings in some use cases (or should we be more strict and fix issues behind those use cases, rather?)The text was updated successfully, but these errors were encountered: