Repository navigation
Fix: Query the package index without pip - #181
Merged
keanjapesan merged 1 commit intoNov 3, 2026
Merged
keanjapesan merged 1 commit into
keanjapesan merged 1 commit into
Conversation
ModeSevenIndustrialSolutions
requested review from
a team
and
a balanced review from Copilot
November 2, 2026 17:01
ModeSevenIndustrialSolutions
force-pushed
the
feat/stdlib-index-query
branch
from
November 2, 2026 17:10
b08d39d to
662efeb
Compare
ModeSevenIndustrialSolutions
force-pushed
the
feat/stdlib-index-query
branch
from
November 2, 2026 17:21
662efeb to
605e005
Compare
ModeSevenIndustrialSolutions
force-pushed
the
feat/stdlib-index-query
branch
from
November 3, 2026 08:43
605e005 to
6a18389
Compare
ModeSevenIndustrialSolutions
force-pushed
the
feat/stdlib-index-query
branch
from
November 3, 2026 08:50
6a18389 to
fb866ca
Compare
ModeSevenIndustrialSolutions
force-pushed
the
feat/stdlib-index-query
branch
from
November 3, 2026 10:37
fb866ca to
c17c017
Compare
ModeSevenIndustrialSolutions
force-pushed
the
feat/stdlib-index-query
branch
from
November 3, 2026 14:18
c17c017 to
3b6ff33
Compare
This was referenced Nov 3, 2026
Merged
Merged
Merged
Merged
Closed
Closed
Merged
This was referenced Nov 5, 2026
This was referenced Nov 5, 2026
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
Replaces #173. The action ran
python3 -m pip indexwith whicheverpython3the caller'sPATHheld, from the caller's workspace, inside pypi-publish-action's publish job. Apip/orensurepip/package in the checkout, a workspace.venvonPATH, orPYTHONPATH,PYTHONHOMEand user-site settings reaching the workspace could all run checkout code. #173 closed those routes one at a time and grew to ~3,000 lines that each review round found more gaps in. This removes the routes instead: the action no longer runs pip,ensurepip, or any Python fromPATH.Changes
scripts/check_index.py(standard library only) reads the project's page from the simple API, asking for PEP 691 JSON and accepting PEP 503 HTML, takes versions from wheel and sdist filenames, and compares them as PEP 440 defines (1.0.0RC1matches1.0.0rc1;1.0matches1.0.0).setup-uvruns in the action's directory withUV_NO_CONFIG/UV_NO_PROJECT, the pattern the other setup-uv PRs merged. uv then installs its own pinned, hash-checked Python underrunner.temp, and the script runs aspython -Ifrom the action's directory.-IignoresPYTHON*variables and the user site and keeps the working directory offsys.path.env -iwith an explicit allow-list: its own install and cache directories underrunner.temp,UV_NO_CONFIG/UV_NO_PROJECT, and proxy, certificate andUV_NATIVE_TLSsettings for self-hosted runners. No caller variable (PATH,VIRTUAL_ENV,CONDA_PREFIX, anyUV_*orPYTHON*) reaches it, so none can choose the interpreter or redirect the download. It also refuses an interpreter path outside its install directory.setup-uvstep. setup-uv itself runsuv python findand then executes the interpreter it finds (--version, for its cache key), whether or not caching is on. Caller variables can steer that lookup into the checkout: CI caught a plantedpython3onPATH, and review foundVIRTUAL_ENV,CONDA_PREFIX,UV_INTERNAL__PARENT_INTERPRETERand macOS'sPYTHONEXECUTABLE. Rather than chase each, the step setsUV_PYTHON_PREFERENCEto an invalid value, so uv refuses its arguments before any lookup and nothing runs. setup-uv then reports the Python version asunknown, which the action never reads; setup-uv v10.3.3 makes no other uv call for these inputs. An inheritedUV_PYTHON_ARCHwould make setup-uv probe uv first, a probe the invalid preference would fail, so the step sets it empty. The step also setstool-bin-dirunderrunner.temp: setup-uv would otherwise add the caller'sHOMEorXDG_*bin directory toPATHfor later steps, where a plantedbashorenvwould run. Every directory setup-uv adds toPATHis then the action's own. (UV_NO_MODIFY_PATHis deliberately not set: setup-uv's own bareuvcall would then resolve on the caller'sPATH, which the isolation job caught.) The action's own uv calls use setup-uv's absoluteuv-pathoutput. The other merged setup-uv PRs share this lookup; their tests planted interpreters in the workspace, not viaPATHor these variables, so they would not have seen it.requirements/uv.txtpins uv for Dependabot (newpipecosystem entry), as python-twine-check-action does. The pin also fixes which Python builds and hashes uv accepts.releases.astral.sh, already in the organisation's harden-runner allow-list.Behaviour changes
EXIT_ON_FAILsays, where it used to report the package missing.filename, HTML cut inside a tag or with an unparsable link, a body shorter than itsContent-Lengthor chunking, an unknown character set, or JSON nested past the parser's limit.INDEX_URL(https://user:token@host/simple) go as HTTP Basic auth to that host alone (never across a redirect) and are never printed. Redirects stay within http(s), never https to http.PACKAGE_MATCHis true when the project page lists any distribution, pre-releases included.Scope
The action trusts the caller's
PATH, as any composite action must: the runner findsbashthere for every step, and setup-uv runslddandtarfrom it. A job that puts a directory from its checkout onPATHruns that checkout's code whatever any action does. What the action guards is the interpreter it runs, which nothing onPATHor in the caller'sPYTHON*/UV_*settings decides.The inputs and outputs are unchanged; pypi-publish-action, the one caller, needs no change.
Tests
tests/test_check_index.py(101 cases, replacingtests/test_pip_fallback.py): PEP 440 normalisation and rejection, filename parsing, credentials and log redaction, and end-to-end runs of the script as the action runs it against a local HTTP index serving JSON and HTML pages: every case the integration job checks, plus HTTP 500, malformed JSON and file entries, truncated HTML, short and cut-chunked bodies, an unknown charset, an unexpected content type, a redirect tofile://, an unreachable host, authentication, and invalid inputs (no request is made). A workspace holdingjson.py,base64.py,urllib/,sitecustomize.pyandusercustomize.py, withPYTHONPATH,PYTHONSTARTUPandPYTHONUSERBASEpointing at it, imports none of them. The install step's own script runs against a stub uv to check what environment reaches it and that an outside path is refused.test_setup_uv_lookup_refuses_before_running_anythingruns the real uv with every interpreter selector uv 0.13.5's Python crates read, planted at once: a control lookup executes the bait, and the setup-uv step's env runs nothing.test_install_step_gives_uv_nothing_from_the_callerchecks the exact environment the install step hands uv.Workspace Isolation(Ubuntu and macOS, each with arequestleg and anactive-environmentleg, soUV_PYTHONcannot mask active-environment discovery) runs the action twice, cold then warm, against a workspace planted with those modules, a fakepython3,pythonanduvfirst onPATH, a.venvwithpyvenv.cfgandconda-meta,pyproject.toml/uv.toml/.python-version, and hostilePYTHONPATH,PYTHONHOME,PYTHONUSERBASE,PYTHONSTARTUP,PYTHONEXECUTABLE,__PYVENV_LAUNCHER__,UV_NO_CACHE,UV_PYTHON_ARCH,UV_PYTHON_INSTALL_MIRRORand anXDG_BIN_HOMEholding baitenvandbash, plus eitherUV_PYTHON,UV_PYTHON_SEARCH_PATH,UV_PYTHON_INSTALL_DIRandUV_PYTHON_PREFERENCE, orVIRTUAL_ENV,CONDA_PREFIX,CONDA_DEFAULT_ENV,UV_INTERNAL__PARENT_INTERPRETER,UV_INTERNAL__TEST_PYTHON_MANAGEDandUV_CACHE_DIR. A control shows the bait runs for a Python that is not isolated; the job then checks no bait ran, no checkout directory reachedPATH, and both runs returned the right outputs.Action Testingjob against TestPyPI is unchanged and its expectations hold.Validation
Local, before push: 101 tests pass; a local run of the isolation job's planted workspace through the action's own step scripts on macOS runs no bait (and, with the location-variable unset removed, the install step refuses the planted interpreter); live queries against PyPI and TestPyPI match every integration expectation.
prekhooks pass,aislopscores 100 with no findings, andzizmor --persona auditorreports nothing. In CI, the isolation job passes on Ubuntu and macOS with its control showing the bait live.