Skip to content

generate-advisories-api: add advisory index generator - #23530

Merged
p-linnane merged 1 commit into
mainfrom
generate-advisories-api
Aug 15, 2026
Merged

generate-advisories-api: add advisory index generator#23530
p-linnane merged 1 commit into
mainfrom
generate-advisories-api

Conversation

@p-linnane

@p-linnane p-linnane commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

brew generate-advisories-api builds the concatenated BREW-* advisory index for formulae.brew.sh 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 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 vulns flips its DATA_URL and Homebrew/advisory-database stops committing the 67 MB generated file. Output was verified byte-identical to the existing rake advisories:concat over the full 20,918-record corpus.


  • 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 Hyperfine benchmarks.
  • 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.

AI disclosure: drafted with Claude Code under my direction. I reviewed the diff and verified it locally with brew style, brew typecheck and brew 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.


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.

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::GenerateAdvisoriesApi to build api/advisories.json from 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.

Comment thread Library/Homebrew/dev-cmd/generate-advisories-api.rb Outdated
Comment thread Library/Homebrew/test/dev-cmd/generate-advisories-api_spec.rb
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>
@p-linnane
p-linnane force-pushed the generate-advisories-api branch from ca977af to 7b335b6 Compare August 14, 2026 22:35

@MikeMcQuaid MikeMcQuaid 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.

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.

@p-linnane

Copy link
Copy Markdown
Contributor Author

Good idea. I will add those in follow up PRs.

@p-linnane
p-linnane added this pull request to the merge queue Aug 15, 2026
Merged via the queue into main with commit ff4c18d Aug 15, 2026
46 checks passed
@p-linnane
p-linnane deleted the generate-advisories-api branch August 15, 2026 14:59
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.

3 participants