Repository navigation
keep wheel namespace package dirs inside the egg directory - #5340
Open
sahvx655-wq wants to merge 1 commit into
Open
sahvx655-wq wants to merge 1 commit into
sahvx655-wq wants to merge 1 commit into
Conversation
Entries in a wheel's namespace_packages.txt were joined onto the egg directory unchecked, so an absolute or drive-qualified entry made install_as_egg create a directory and write __init__.py elsewhere on disk. Resolve each entry through _resolve_dest, which archive members already go through, so such entries raise UnsafeMember.
Contributor
|
Tick the box to add this pull request to the merge queue (same as
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary of changes
Wheel._fix_namespace_packagesreadsnamespace_packages.txtout of the wheel being installed and builds each directory withos.path.join(destination_eggdir, *mod.split('.')). Nothing checks the entry first, so an absolute name throws away the egg directory, and a drive-qualified one does the same on Windows. I traced it frominstall_as_egg, whichfetch_build_eggscalls forsetup_requires. A wheel whose entry was an absolute path under a scratch directory got a directory and an__init__.pycreated outside the egg on main, with no warning or trace logged. The member names were already contained by GHSA-grgh-hr87-3jpw, but this path comes from metadata and never went through that check. Left as is, an untrusted wheel can drop a file anywhere the installing user can write.Routing the entry through
archive_util._resolve_destgives it the same absolute, drive, UNC and realpath containment that archive members already get, and it raisesUnsafeMemberthe same way. Doing it where the path is built covers the one caller that matters and keeps dotted names likefoo.barmapping exactly as before. The new test fails on main withDID NOT RAISE UnsafeMemberand passes here. The full suite passes when run serially, and ruff is clean.Pull Request Checklist
newsfragments/.(See documentation for details)