Skip to content

dev-cmd/generate-vulns-advisories: OSV advisory export for homebrew-advisory-database#23106

Merged
MikeMcQuaid merged 5 commits into
mainfrom
vulns-osv-export
Jul 14, 2026
Merged

dev-cmd/generate-vulns-advisories: OSV advisory export for homebrew-advisory-database#23106
MikeMcQuaid merged 5 commits into
mainfrom
vulns-osv-export

Conversation

@andrew

@andrew andrew commented Jul 14, 2026

Copy link
Copy Markdown
Member

Follow-up to #23080. Ports the OSV-record exporter from Homebrew/homebrew-brew-vulns as a hidden dev-cmd so Homebrew/homebrew-advisory-database can generate its BREW-* advisory feed without depending on the deprecated tap gem.

brew generate-vulns-advisories DIR iterates homebrew/core under SimulateSystem, collects each formula's serialized_patches unioned across every OS/arch variation from to_hash_with_variations (so a resolves inside on_linux/on_intel is not silently dropped), and writes one OSV 1.7 record per (formula, security id) pair. Upstream summary/severity/references are copied from OSV.dev where available. --dry-run lists the record ids without writing or querying the network.

The record generator itself lives in Homebrew::Vulns::OsvExport, reusing Scanner.resolved_ids and the OSV client from #23080. pkg:brew purls percent-encode @ and + in formula names.

A --dry-run against current homebrew/core produces the same 5 formulae as the existing advisory tree (glibc, libquicktime, lrzsz, unzip, zip) plus 6 additional libquicktime CVEs annotated since the last regenerate on 2026-06-28. The Homebrew ecosystem, BREW- prefix and pkg:brew purl type are now registered (ossf/osv-schema#576, package-url/purl-spec#796).

Background and migration plan: Homebrew/homebrew-brew-vulns#111, Homebrew/discussions#6869.


  • 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?

  • AI was used to generate or assist with generating this PR.

Ported with Claude Code from lib/brew/vulns/osv_export.rb in the tap, with a review pass from codex on each commit. I read both diffs, ran brew lgtm, and diffed a --dry-run against the current advisory database.


andrew added 2 commits July 14, 2026 09:35
Ports the OSV record exporter from Homebrew/homebrew-brew-vulns. Emits
one BREW-<formula>-<CVE> record per security id declared in a formula's
patch resolves list, under the registered Homebrew ecosystem with
pkg:brew purls, marking the currently shipped pkg_version as the fixed
boundary. Upstream summary/severity/references are copied from OSV.dev
where available.

This is the generator for Homebrew/homebrew-advisory-database; the
dev-cmd entry point follows in the next commit.
Replaces the tap's brew-vulns --osv-export DIR with a hidden dev-cmd
following the generate-formula-api pattern. Iterates homebrew/core under
with_no_api_env + SimulateSystem, unions each formula's serialized_patches
across all OS/arch variations from to_hash_with_variations so
platform-gated resolves annotations are not silently dropped, and hands
[formula, patches] pairs to Homebrew::Vulns::OsvExport.

--dry-run lists record ids without writing or querying OSV.dev.
Consumed by Homebrew/homebrew-advisory-database's regenerate workflow.
Copilot AI review requested due to automatic review settings July 14, 2026 16:39
andrew added a commit to Homebrew/homebrew-brew-vulns that referenced this pull request Jul 14, 2026
The exporter now lives in Homebrew/brew as a dev-cmd (Homebrew/brew#23106)
feeding Homebrew/homebrew-advisory-database, so split it out from the
"not available" list.

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

This PR adds a hidden developer command to generate OSV-schema advisory records for the Homebrew ecosystem from homebrew/core formula patch resolves annotations, enabling Homebrew/homebrew-advisory-database to build its BREW-* feed without the deprecated tap gem.

Changes:

  • Introduces Homebrew::Vulns::OsvExport to build/write OSV 1.7 records per (formula, vulnerability id) pair, optionally enriching from OSV.dev.
  • Adds brew generate-vulns-advisories DIR (hidden dev-cmd) that loads core formulae under SimulateSystem and unions patch annotations across OS/arch variations.
  • Adds unit tests, Sorbet RBI for args, and updates shell completions to expose the new dev command for developers.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Library/Homebrew/vulns/osv_export.rb Implements OSV record generation + writing and upstream enrichment.
Library/Homebrew/dev-cmd/generate-vulns-advisories.rb Adds hidden dev-cmd to enumerate core formulae, union variation patches, and invoke exporter (or --dry-run).
Library/Homebrew/test/vulns/osv_export_spec.rb Unit tests for record shape, patch filtering, purl encoding, and upstream merge behavior.
Library/Homebrew/test/dev-cmd/generate-vulns-advisories_spec.rb Unit tests for the command’s generation behavior, --dry-run, and variation patch unioning.
Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/generate_vulns_advisories.rbi Tapioca-generated RBI for args accessors (dry_run?, n?).
completions/zsh/_brew Adds zsh completion entry/function for the new dev command.
completions/fish/brew.fish Adds fish completion entry/flags for the new dev command.
completions/bash/brew Adds bash completion wiring and developer-command list entry.
Files not reviewed (1)
  • Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/generate_vulns_advisories.rbi: File type not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Library/Homebrew/vulns/osv_export.rb
Comment thread Library/Homebrew/dev-cmd/generate-vulns-advisories.rb
andrew added 2 commits July 14, 2026 09:52
When multiple formulae resolve the same CVE, fetch it from OSV.dev once
per run rather than once per (formula, id) pair. Uses Hash#fetch with a
block so a nil (fetch-failed) result is also cached.

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

Thanks! A few comments.

Comment thread Library/Homebrew/dev-cmd/generate-vulns-advisories.rb
Comment thread Library/Homebrew/vulns/osv_export.rb
Comment thread Library/Homebrew/vulns/osv_export.rb
Comment thread Library/Homebrew/vulns/osv_export.rb Outdated
Add a pointer to ossf.github.io/osv-schema above SCHEMA_VERSION and note
where the Homebrew ecosystem/prefix were registered. patch_ref now
returns T::Hash[Symbol, T.any(String, T::Array[String])] via a PatchRef
alias; the input side stays T.untyped to match Formula#serialized_patches.
@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue Jul 14, 2026
Merged via the queue into main with commit de84271 Jul 14, 2026
44 checks passed
@MikeMcQuaid MikeMcQuaid deleted the vulns-osv-export branch July 14, 2026 19:03
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