Skip to content

Recognize legacy PyPI resource URLs - #24142

Merged
p-linnane merged 1 commit into
mainfrom
advisory-legacy-pypi-urls
Oct 1, 2026
Merged

p-linnane merged 1 commit into
mainfrom
advisory-legacy-pypi-urls

Conversation

@p-linnane

Copy link
Copy Markdown
Contributor

Vulns::Identify.registry_purl only recognized files.pythonhosted.org resource URLs, but formula revisions from before 2018 download PyPI resources from pypi.python.org. History walks treated those revisions as not shipping the package, so matched advisories started too late. Both hosts use the same packages/<a>/<b>/<hash>/ and packages/source/<letter>/<name>/ layouts, so this accepts either host.

To reproduce, brew advisory-match --json gitup | jq -r '.[] | select(.id == "BREW-gitup-CVE-2026-87817") | .affected[0].ranges[0].events' gives introduced: 0.4.1 on main, which is gitup's first revision on the new host. With this change it gives 0.2.3, the formula's first version, which already bundled GitPython 1.0.1.

Fresh record generation can now fail closed instead of emitting a boundary when older revisions become visible. legit's 0.1.0 label covers both a binary with no declared GitPython resource and a mislabelled 0.2.0 build that declares one, so new legit GitPython candidates report "affected introduction cannot be established" rather than starting at 0.2.1. That is the existing safeguard working as intended. Ordinary ingest preserves existing reviewed introductions, so this neither corrects already-published records nor stops their metadata updates; those need explicit correction.


  • Have you followed our Contributing guidelines?
  • Have you checked for other open Pull Requests for the same change?
  • Have you explained what your changes do? Performance claims (e.g. "this is faster") must include brew benchmark results.
  • Have you explained why you'd like these changes included, not just what they do?
  • For bug fixes, have you given step-by-step brew commands to reproduce the bug?
  • Have you written new tests (excluding integration tests)? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) locally?

  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

Claude Code found this while independently verifying Homebrew/advisory-database Ingest output against full homebrew-core history, then wrote the change and specs and compared brew advisory-match output for gitup and legit with and without it. I reviewed the diff and the before/after results.


Copilot AI lite review requested due to automatic review settings October 1, 2026 01:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The change is narrowly scoped and covered by tests; the remaining issue is only a minor nit.

Review effort: Lite
Findings: None

What changed in this PR

Updates vulnerability matching to recognize legacy pypi.python.org resource URLs used by older formula revisions.

Changes:

  • Supports both current and legacy PyPI hosts.
  • Adds coverage for hashed, source, and wheel URLs.
File Summary
Library/​Homebrew/​vulns/​identify.rb Expands PyPI URL matching.
Library/​Homebrew/​test/​vulns/​identify_spec.rb Tests legacy URL handling.

Review note (nit): Split the legacy-wheel assertion into a separate example.


💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@p-linnane
p-linnane force-pushed the advisory-legacy-pypi-urls branch from 057bd81 to d637eed Compare October 1, 2026 01:48

@dduugg dduugg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! One small non-blocking edge case inline.

Comment thread Library/Homebrew/vulns/identify.rb Resolved
Older formula revisions download PyPI resources from pypi.python.org
rather than files.pythonhosted.org. `registry_purl` only matched the
newer host, so history walks treated those revisions as not shipping
the package and set `introduced` too late: gitup's GitPython
advisories started at 0.4.1, its first revision on the new host,
instead of 0.2.3.

Both hosts serve the same `packages/<a>/<b>/<hash>/` and
`packages/source/<letter>/<name>/` layouts, so accept either host.
Strip URL fragments first: some legacy URLs carry an `#md5=` digest,
which would otherwise end up in the version or let a wheel past the
extension check.

Signed-off-by: Patrick Linnane <patrick@linnane.io>
@p-linnane
p-linnane force-pushed the advisory-legacy-pypi-urls branch from d637eed to 5302dbf Compare October 1, 2026 04:28
@p-linnane
p-linnane enabled auto-merge October 1, 2026 04:29
@p-linnane
p-linnane added this pull request to the merge queue Oct 1, 2026
Merged via the queue into main with commit 6d50b44 Oct 1, 2026
81 of 82 checks passed
@p-linnane
p-linnane deleted the advisory-legacy-pypi-urls branch October 1, 2026 08:27
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.

4 participants

⌂ 换网址