Skip to content

check: read the index settings beside a looked-up file, and keep it private without them - #235

Merged
patrickballard merged 3 commits into
mainfrom
checker-reads-nearby-index-config
Nov 22, 2026
Merged

patrickballard merged 3 commits into
mainfrom
checker-reads-nearby-index-config

Conversation

@patrickballard

@patrickballard patrickballard commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

The bug

wheelgap 0.13.0 counts a requirements file, a pyproject.toml or a Pipfile.lock as PyPI-only partly from files on disk: sources._nearby_config_names_an_index reads every uv.toml, pyproject.toml and pdm.toml in the file's folder and each folder above it, up to the first one with a .git. One that names an index ([[tool.uv.index]], [tool.uv] index-url/sources/find-links/no-index, [tool.uv.pip], Poetry or PDM sources, pixi's pypi-options, a pdm.toml [pypi]), or one it can't parse, means the file isn't PyPI-only. The browser never fetched those files, and dropOtherProjects() deleted any pyproject.toml it had fetched. So requirements.txt with corp-secret-lib==1.0 next to a pyproject.toml naming a private index came out pypi_only True in the browser (False on a real disk), and the private name was looked up on pypi.org. On main this happens with no click: plan() puts a root requirements.txt before the root pyproject.toml, and uv export writes no index lines.

The fix (fails closed)

  • driver.py

    • plan() returns configs, every uv.toml/pyproject.toml/pdm.toml in the tree.
    • The new configs_for(path, configs) returns the ones wheelgap would read for a file: those in its folder or a folder above it. It returns nothing for a file whose reader doesn't call _nearby_config_names_an_index (offline lockfiles, pixi.lock).
    • needs() and check() take that list as configs_json. If a listed nearby config isn't on disk (its fetch failed), or there's no list (a truncated tree, or a caller that didn't pass one), the file is treated as not PyPI-only. Nothing in it is looked up, and the result says why: configs_unread or configs_unknown, with configs listing the files that were read.
  • worker.mjs

    • Before the lookups, fetchConfigs() fetches the files configs_for names. A failed fetch is left off disk, so the driver keeps the file private.
    • dropOtherProjects(py, repo, keep) now keeps the file being checked and its own settings files. It removes every other fetched pyproject.toml/uv.toml/pdm.toml, so it still does its job: each file reads as it would if it were checked first, and a uv.lock checked after a requirements.txt still never sees the pyproject.toml that check fetched.
    • A truncated tree sets repo.configs to null.
    • load() creates an empty .git folder at the repo's root in Pyodide's filesystem, so wheelgap's walk up stops there, as it does in a checkout.
  • check.mjs / check-logic.mjs: the "Not checked" alert now comes from a pure privateText(r). It names the settings files read, or says which one couldn't be fetched, or that GitHub cut the file list short. A pyproject.toml that is all private only for that reason still falls back as in Repo checker: fall back from an all-private pyproject.toml #223 (to an offline lock, or a file outside its folder). privatePyprojectReason now gives that reason instead of "its index or source settings don't identify which packages are from PyPI".

  • A second leak, already on main: loadLab() fetched ../data/packages/<name>.json for every gap row. A package that a uv.lock, poetry.lock or pylock.toml pins to a private index therefore had its name requested from the tracker's own pages. It now asks only for rows that check() marked as PyPI packages (row.lookup). That is the same rule Repo checker: link tracker page and issue tracker for dead-end fixes (#214) #231's renderTable and fixLinks already use, so such rows also get no PyPI link.

  • Settings files named in another case (Pyproject.toml, UV.TOML) are now in configs. wheelgap reads them on a case-insensitive disk such as a macOS or Windows checkout, but never on the browser's disk. So they're never fetched, they count as unread, and the file stays private.

Keeping a nearby pyproject.toml doesn't change which file is checked. check() still reads lockfile directly, and a test covers this: lockfile, listed and the rows still come from requirements.txt. For a requirements file, a pyproject.toml or a Pipfile.lock, wheelgap reads nothing else near the input.

Tests

  • tests/test_check_driver.py:
    • The reviewer's repro: requirements.txt plus a pyproject.toml with [[tool.uv.index]] is private and nothing is looked up.
    • Every index setting wheelgap reads, in a root pyproject.toml/uv.toml/pdm.toml above app/requirements.txt, app/pyproject.toml and app/Pipfile.lock.
    • A uv.toml in a folder above the file is read. One in a folder that isn't above it is neither read nor fetched.
    • A config listed in the tree but not fetched keeps the file private.
    • A truncated, missing or malformed list keeps the file private, and offline lockfiles are unchanged.
    • Regression: a requirements file with no nearby config, or with one that names no index, is still looked up on PyPI.
    • CONFIG_NAMES, the readers that call the function, the worker's list, and the walk itself (the folder and its parents, stopping at a .git) must match the pinned release, so these tests fail when the pin moves and the release reads other files.
    • A Pyproject.toml beside the file keeps it private.
    • Existing calls, including the ones Repo checker: fall back from an all-private pyproject.toml #223, fix(check): check named file from GitHub blob URLs instead of falling back silently #226 and feat(check): discover and prioritize additional requirements*.txt files in plan() #229 added, now pass the repo's list, as the worker does. With no list the driver now fails closed.
  • tests/test_check_parity.py: the driver gets the same list, so the CLI parity cases still match.
  • tests/site/check-page.test.mjs: the worker fetches the nearby configs, keeps them, drops another check's, and hands the driver the list. A failed fetch isn't written and is retried on the next check. A truncated tree is handed over as "null".
  • tests/site/check-page.test.mjs also checks that loadLab() requests nothing for a private gap row, and feat(check): offer README badge in clean verdict and add plain-text share button #225's badge test now passes privateText to renderVerdict.
  • tests/site/check-logic.test.mjs: the privateText wording, and unreadableReason for an all-private pyproject.toml whose settings couldn't all be read.

On top of main at b45adad (after #231 and #225), brought in by a merge commit. I ran every command in the README's Tests section locally, all green, with the pinned wheelgap 0.13.0 for the driver and parity tests. Not tried end to end in a browser against a live repo.

Not in this PR

pip.conf/pip.ini in the repo are not made a reason to keep a file private. wheelgap 0.13.0 doesn't read them: the function's docstring says user and system settings aren't read, and a test asserts they aren't in _CONFIG_FILES. pip doesn't read a repo-local pip.conf unless PIP_CONFIG_FILE points to it. That's a follow-up if wheelgap ever starts reading them.

With #233

#233 adds the same configs key to plan() and the same configs_json parameter to needs()/check(), with the same meaning, including null meaning unknown. Merged on top, the two should fit together. _public_extra_hosts can keep its own check that no listed config is nearby, which is stricter and safe. It can also drop that check and rely on this PR's _unread_configs plus _nearby_config_names_an_index, since the files are now on disk.

🤖 Generated with Claude Code

@patrickballard
patrickballard force-pushed the checker-reads-nearby-index-config branch from 1805ac1 to 80312db Compare November 22, 2026 12:11
…rivate without them

wheelgap 0.13.0 calls a requirements file, pyproject.toml or Pipfile.lock PyPI-only only if no uv.toml, pyproject.toml or pdm.toml in its folder or a folder above it (up to the repo root) names another index. The browser never fetched those files, and dropOtherProjects() deleted any pyproject.toml it had, so requirements.txt beside a pyproject.toml with [[tool.uv.index]] was looked up on pypi.org, private names included. The worker now fetches the ones the repo has there before the check and keeps them for it; a listed one that fails to fetch, or a truncated tree, keeps the file private and the page says why.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
patrickballard and others added 2 commits November 22, 2026 12:29
Brings in #231 and #225. The import lists conflicted; #225's badge test now passes privateText to renderVerdict, which calls it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… the file private

loadLab() fetched ../data/packages/<name>.json for every gap row, so a package a uv.lock, poetry.lock or pylock.toml pins to a private index had its name requested from the tracker's pages. It now asks only for rows check() marked as PyPI packages (row.lookup), the rule renderTable and fixLinks already use. A settings file named in another case (Pyproject.toml) is read by wheelgap on a macOS or Windows checkout but never on the browser's disk, so it now counts as unread and the file stays private. The drift test also pins the walk (the folder and its parents, up to a .git).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@patrickballard
patrickballard merged commit 88886e1 into main Nov 22, 2026
1 check passed
patrickballard added a commit to dev-burnern/tracker that referenced this pull request Nov 22, 2026
Resolved with wheelgap#235 as its reviewer set out. Main's CONFIG_NAMES, plan() configs (any case), configs_for, configsJson, fetchConfigs, dropOtherProjects(py, repo, keep) and the truncated-tree null replace wheelgap#233's own; worker.mjs is now main's. check() uses main's _reads_offline. _public_extra_hosts() now starts with _unread_configs(), since _private() returns before it reads source.pypi_only for a file taken as public and would otherwise skip wheelgap#235's fail-closed check; it still refuses any settings file listed beside or above the file, read or not; its docstring no longer says the browser doesn't fetch them. The reader-based advice moved into privateText()'s names-an-index branch, so unread or unknown settings keep their own text; renderTable's Fix text shows an unknown row's reason. Tests: main's harnesses taken, wheelgap#233's tests kept with the renderVerdict harness given privateText, privatePyprojectReason and cliCommand, plus driver tests that an extra-index file is never looked up when a nearby settings file couldn't be fetched, the list is unknown or a read one sits beside it, and privateText's reader cases.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
patrickballard added a commit to dev-burnern/tracker that referenced this pull request Nov 22, 2026
…a plain uvx wheelgap for withheld names

pip shlex-splits an option line and expands ${VAR} in it, but wheelgap 0.13.0's collector splits on whitespace. So -'i' URL, --"index-url" URL, --ext\\ra-index-url URL, --no-ind''ex and -${OPT} URL are index options to pip (checked with pip 25.3's own parser), but the collector misses them, and the PyTorch line beside one made the file public. Now any option line in the file or its includes with a quote, a backslash or a $ keeps it private. The 'uvx wheelgap FILE in a checkout checks them on PyPI's files' advice is gone too: wheelgap's CLI looks a requirements file's packages up on PyPI unless --index-url names another index, so following it would send the withheld names there. The names-an-index branch is main's --index-url sentence again, and the unread and unknown branches (wheelgap#235) now say to pass --index-url with the project's index, and why.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
patrickballard added a commit that referenced this pull request Nov 22, 2026
…s PyTorch's index (#233)

* fix(check): check PyPI packages when requirements use PyTorch --extra-index-url

Closes #219

* Extra index: read option lines with wheelgap's own reader and fail closed

_public_extra_indexes() matched exact flag names, so lines pip and wheelgap 0.13.0 read as another index (-ihttps://corp, -f./wheels, --index URL, --extra URL, --no-i), includes it didn't follow (-rcorp.txt, --requirem corp.txt) and a first-line option behind a byte-order mark left the file public, and its names went to pypi.org. It now takes the lines sources._read_requirements() collects as index options (the file and its includes, utf-8-sig, pip's line joining and abbreviations) and accepts only a whole '--extra-index-url URL' line on a listed https host with a plain path; anything else, or any error, keeps the file private. Checked against pip 25.3's own requirements parser on the same files. The browser never fetches a uv.toml, pyproject.toml or pdm.toml beside the file, so plan() now lists them and the worker passes the list: one in the file's folder or above, or no list, keeps it private too. A row's reason is now its Fix text and is named in the alert, and the 'uvx wheelgap FILE checks PyPI's files' advice is kept to requirements files and pyproject.toml (the CLI skips a Pipfile.lock's or pixi.lock's pinned index too).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Extra index: no settings-file list from a truncated tree

When GitHub truncates the tree, plan()'s configs can miss a root uv.toml or pyproject.toml, so an --extra-index-url file could be taken as public. The worker now passes null then, which the driver treats as uncertain and keeps the file private.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Extra index: refuse option lines pip reads differently; never advise a plain uvx wheelgap for withheld names

pip shlex-splits an option line and expands ${VAR} in it, but wheelgap 0.13.0's collector splits on whitespace. So -'i' URL, --"index-url" URL, --ext\\ra-index-url URL, --no-ind''ex and -${OPT} URL are index options to pip (checked with pip 25.3's own parser), but the collector misses them, and the PyTorch line beside one made the file public. Now any option line in the file or its includes with a quote, a backslash or a $ keeps it private. The 'uvx wheelgap FILE in a checkout checks them on PyPI's files' advice is gone too: wheelgap's CLI looks a requirements file's packages up on PyPI unless --index-url names another index, so following it would send the withheld names there. The names-an-index branch is main's --index-url sentence again, and the unread and unknown branches (#235) now say to pass --index-url with the project's index, and why.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Patrick Ballard <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant