generate-advisories-api: add advisory index generator - #23530
Conversation
1e97a5a to
ca977af
Compare
There was a problem hiding this comment.
Pull request overview
Adds a new developer-only command, brew generate-advisories-api, to generate a deterministic, formula-grouped advisory index JSON for formulae.brew.sh from a Homebrew/advisory-database checkout. This supports migrating the advisory index away from a raw git URL and towards being served via the formulae.brew.sh API.
Changes:
- Introduces
Homebrew::DevCmd::GenerateAdvisoriesApito buildapi/advisories.jsonfrom advisory-database records, including filtering/ordering and schema-version consistency checks. - Adds RSpec coverage for grouping/filtering/determinism and mixed schema-version failure.
- Updates shell completion scripts (bash/fish/zsh) and adds the Sorbet RBI for the new dev command.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| Library/Homebrew/dev-cmd/generate-advisories-api.rb | Implements the new advisory index generator command and filtering/ordering logic. |
| Library/Homebrew/test/dev-cmd/generate-advisories-api_spec.rb | Adds tests for deterministic grouped output and mixed schema-version failure. |
| Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/generate_advisories_api.rbi | Adds Tapioca-generated RBI for the new dev command’s dynamic args method. |
| completions/bash/brew | Registers the command and adds option completion for bash. |
| completions/fish/brew.fish | Registers the command and adds option completion for fish. |
| completions/zsh/_brew | Registers the command and adds option completion for zsh. |
Files not reviewed (1)
- Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/generate_advisories_api.rbi: File type not supported
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Builds the concatenated BREW-* advisory index from a checkout of Homebrew/advisory-database, mirroring that repository's AdvisoryIndex (kept in step): matched records without a comparable range are skipped, output is grouped by formula and deterministic, and mixed schema versions fail the build. This lets the formulae.brew.sh site build publish the index at /api/advisories.json so brew vulns can stop fetching it from a raw git URL. Signed-off-by: Patrick Linnane <patrick@linnane.io>
ca977af to
7b335b6
Compare
MikeMcQuaid
left a comment
There was a problem hiding this comment.
Makes sense! For both this and analytics: would be nice to be able to skip from regenerating every 15m and have a cache to fall back on? Not a blocker.
|
Good idea. I will add those in follow up PRs. |
brew generate-advisories-apibuilds the concatenatedBREW-*advisory index for formulae.brew.sh from a checkout of Homebrew/advisory-database, mirroring that repository'sAdvisoryIndex(kept in step): matched records without a comparable range are skipped, output is grouped by formula and deterministic, and mixed schema versions fail the build.This is the first half of serving the index from formulae.brew.sh/api instead of a raw git URL: the site's CI gains a generate-advisories job running this command, after which
brew vulnsflips itsDATA_URLand Homebrew/advisory-database stops committing the 67 MB generated file. Output was verified byte-identical to the existingrake advisories:concatover the full 20,918-record corpus.brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?AI disclosure: drafted with Claude Code under my direction. I reviewed the diff and verified it locally with
brew style,brew typecheckandbrew lgtm, including byte-identical output against the existing generator; commits are authored and signed off by me with no AI attribution, and review responses will be my own.