generate-formula-api: attach vulnerabilities from advisory-database - #23341
Merged
Conversation
Vulns::AdvisoryDatabase reads Homebrew/advisory-database's published
data/advisories.json (built by that repository's rake advisories:concat)
via the same CachedFeed mechanism as Vulns::Repology, and evaluates each
BREW-* record's ECOSYSTEM range against a given pkg_version using
Vulnerability#range_status.
generate-formula-api loads it once per build and attaches
hash["vulnerabilities"] = {open:, patched:, fixed_count:} to each
formula's public API JSON (_data/formula/<name>.json and
api/formula/<name>.json). open is records whose range still contains
pkg_version; patched is records with ecosystem_specific.fix: patch that
pkg_version is past; fixed_count is bump-fixed records that no longer
apply. The key is absent for formulae with no records so consumers can
tell checked-and-clean from not-covered. A feed load failure is
opoo'd and the field is omitted so an advisory-database outage does not
break the API build.
The internal API (FormulaStruct) is unchanged; brew info reading the
field from there is a follow-up.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds vulnerability metadata from Homebrew/advisory-database to the public formula API JSON generated by brew generate-formula-api, avoiding per-build live OSV.dev queries.
Changes:
- Introduces
Homebrew::Vulns::AdvisoryDatabaseas a cached feed reader fordata/advisories.json. - Extends
generate-formula-apito attach a per-formulavulnerabilitiesobject (when available) and to gracefully omit it on feed load failure. - Adds unit tests for the new feed reader and updates the generate-formula-api command spec to cover the new behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| Library/Homebrew/vulns/advisory_database.rb | New cached feed reader + status_for API returning the public JSON shape. |
| Library/Homebrew/test/vulns/advisory_database_spec.rb | New unit tests for feed validation, record wrapping, and status partitioning. |
| Library/Homebrew/dev-cmd/generate-formula-api.rb | Loads advisory feed once per run and attaches vulnerabilities into public formula JSON. |
| Library/Homebrew/test/dev-cmd/generate-formula-api_spec.rb | Updates command spec to cover presence/absence/omission-on-error of vulnerabilities. |
馃挕 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
A record whose ECOSYSTEM range starts above pkg_version returns state :not_applicable from range_status; that was falling through to patched (if fix: patch) or fixed_count. Drop it instead so a version the advisory never applied to is not counted either way. Also distinguish a missing advisories key from a wrong-type value in the load error.
pull Bot
pushed a commit
to arc675/formulae.brew.sh
that referenced
this pull request
Jul 29, 2026
Shows a Known vulnerabilities table when the formula's API JSON carries vulnerabilities.open (populated by brew generate-formula-api from Homebrew/advisory-database, Homebrew/brew#23341): each entry links its first upstream id (or the BREW-* id when there is none) to osv.dev/vulnerability/<id> with severity and truncated summary. When vulnerabilities.patched is non-empty, lists the CVEs Homebrew ships a resolves-annotated patch for. Nothing is rendered for formulae without the field so "no records" is not misread as "no vulnerabilities".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Attaches a
vulnerabilitiesfield to each formula's public API JSON (_data/formula/<name>.json,api/formula/<name>.json) sourced from Homebrew/advisory-database rather than a live OSV.dev query per API build.Vulns::AdvisoryDatabaseis aCachedFeedreader for advisory-database'sdata/advisories.json(built nightly byrake advisories:concat, Homebrew/advisory-database#30).#status_for(name, pkg_version)evaluates everyBREW-*record'sECOSYSTEMrange against the givenpkg_versionviaVulnerability#range_statusand returns:{ "open": [{"id": "BREW-...", "upstream": ["CVE-..."], "summary": "...", "severity": "high", "fix": null, "fixed_in": null}], "patched": [{"id": "BREW-...", "upstream": ["CVE-..."], "fix": "patch", "fixed_in": "6.0_29"}], "fixed_count": 3 }openis records whose range still containspkg_version;patchedis records withecosystem_specific.fix: "patch"(Homebrew ships aresolves-annotated patch) thatpkg_versionis past;fixed_countcounts bump-fixed records that no longer apply. The key is absent for formulae with no records so consumers can distinguish "checked, clean" from "not covered".generate-formula-apiloads the feed once per build (24h cache TTL) and attaches the field per formula. A feed load failureopoos and the field is omitted so an advisory-database outage does not break the API build.The internal API (
FormulaStruct) andbrew infoare unchanged; those read from a fixed-field struct that does not carry this key yet and are a follow-up. formulae.brew.sh rendering is a separate PR to that repository.brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?Claude Code assisted with implementation and tests; verified via
brew lgtmand fullbrew style.