formula: render vulnerabilities from the API JSON - #2245
Merged
Conversation
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".
Contributor
There was a problem hiding this comment.
Pull request overview
Adds rendering of vulnerability information from the formula API JSON onto the formula detail page, surfacing both currently open vulnerabilities and vulnerabilities patched by Homebrew when present in _data/formula/<name>.json.
Changes:
- Render a “Known vulnerabilities” table when
f.vulnerabilities.openis non-empty. - Render a “Homebrew ships patches for” line when
f.vulnerabilities.patchedis non-empty. - Link vulnerability IDs to OSV and display severity + a truncated summary.
Comments suppressed due to low confidence (1)
_layouts/formula.html:283
- Same issue as the
openblock:f.vulnerabilitiesmay be missing, sof.vulnerabilities.patched.size > 0can error during rendering. Guard forf.vulnerabilitiesand check againstempty.
{%- if f.vulnerabilities.patched.size > 0 %}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
f.vulnerabilities is absent for formulae with no advisory-database records; verified a fixture without the key builds cleanly and renders neither block.
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.
Shows a Known vulnerabilities table on the formula page when
_data/formula/<name>.jsoncarriesvulnerabilities.open, and a Homebrew ships patches for line whenvulnerabilities.patchedis non-empty. Nothing is rendered for formulae without the field.The field is populated by
brew generate-formula-apifrom Homebrew/advisory-database'sdata/advisories.json(Homebrew/brew#23341, Homebrew/advisory-database#30). Each entry links its firstupstreamid (or theBREW-*id when there is none) tohttps://osv.dev/vulnerability/<id>with severity and truncated summary.Rendered output for a fixture with two open (one CVE-linked, one without) and one patched:
Safe to merge before Homebrew/brew#23341: the field is absent until that lands, so both blocks are skipped.