Skip to content

Screen downloads from a PyPI mirror listed only under pypi - #91

Merged
ian-at-strix merged 1 commit into
mainfrom
registries/pypi-mirror-files
Oct 23, 2026
Merged

ian-at-strix merged 1 commit into
mainfrom
registries/pypi-mirror-files

Conversation

@ian-at-strix

Copy link
Copy Markdown
Collaborator

What

The pypi registry now also matches wheel and sdist paths (packages/…) and has the PyPI age lookup, sharing both with pypi-files.

Why

A PyPI mirror such as https://pypi.tuna.tsinghua.edu.cn/ serves its index and its files from one host. When it was listed only under pypi, its downloads matched no pattern, so they went through unscreened.

How

WHEEL, SDIST and PUBLISHED are consts in pypi.rs, used by both PYPI and PYPI_FILES. In PYPI the file patterns come before the catch-all and have no rewrite, so the package bytes are never touched. pypi.org serves nothing under /packages/, so the change makes no difference there. Index pages carry no version, so the age check still skips them.

Tested

  • cargo test and cargo fmt --check pass. cargo clippy --all-targets is clean, with and without --features machine-wide.
  • New test: a wheel on a pypi-only mirror under a path prefix resolves to six@1.16.0. It fails without the fix.
  • Prefix mode with only {"registries": {"pypi": ["https://pypi.tuna.tsinghua.edu.cn/"]}}: firewall pip install six==1.16.0 logs screening eco="pypi" pkg=six@1.16.0 url=https://pypi.tuna.tsinghua.edu.cn/packages/…/six-1.16.0-py2.py3-none-any.whl and installs. With min_age_hours: 100000 the same wheel is blocked … was published 47930 hours ago and pip gets a 403.

Untested

  • Machine-wide (MITM) mode.
  • Mirrors that serve files outside packages/…, such as devpi's +f/…, still match no pattern.

A PyPI mirror serves its files from the index host, so the pypi registry
now names packages in /packages/ paths too, and checks their age.
@ian-at-strix
ian-at-strix merged commit c16be8d into main Oct 23, 2026
7 checks passed
@ian-at-strix ian-at-strix mentioned this pull request Oct 23, 2026
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