Skip to content

formula: render vulnerabilities from the API JSON - #2245

Merged
andrew merged 2 commits into
mainfrom
formula-vulnerabilities
Jul 29, 2026
Merged

formula: render vulnerabilities from the API JSON#2245
andrew merged 2 commits into
mainfrom
formula-vulnerabilities

Conversation

@andrew

@andrew andrew commented Jul 28, 2026

Copy link
Copy Markdown
Member

Shows a Known vulnerabilities table on the formula page when _data/formula/<name>.json carries vulnerabilities.open, and a Homebrew ships patches for line when vulnerabilities.patched is non-empty. Nothing is rendered for formulae without the field.

The field is populated by brew generate-formula-api from Homebrew/advisory-database's data/advisories.json (Homebrew/brew#23341, Homebrew/advisory-database#30). Each entry links its first upstream id (or the BREW-* id when there is none) to https://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:

<p>Known vulnerabilities in the current version:</p>
<table class="full-width"><tr>
    <td><a rel="nofollow" href="https://osv.dev/vulnerability/CVE-2024-1111">CVE-2024-1111</a> (high)</td>
    <td>Something bad</td>
</tr><tr>
    <td><a rel="nofollow" href="https://osv.dev/vulnerability/BREW-testvuln-CPANSA-X">BREW-testvuln-CPANSA-X</a></td>
    <td>No CVE</td>
</tr></table>
<p><small>Data from <a href="https://github.com/Homebrew/advisory-database">Homebrew/advisory-database</a>. Run <code>brew vulns testvuln</code> for a live check.</small></p>
<p>Homebrew ships patches for: <a rel="nofollow" href="https://osv.dev/vulnerability/CVE-2014-0001">CVE-2014-0001</a>.</p>

Safe to merge before Homebrew/brew#23341: the field is absent until that lands, so both blocks are skipped.

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".
Copilot AI review requested due to automatic review settings July 28, 2026 16:22

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 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.open is non-empty.
  • Render a “Homebrew ships patches for” line when f.vulnerabilities.patched is 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 open block: f.vulnerabilities may be missing, so f.vulnerabilities.patched.size > 0 can error during rendering. Guard for f.vulnerabilities and check against empty.
{%- if f.vulnerabilities.patched.size > 0 %}

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

Comment thread _layouts/formula.html Outdated
f.vulnerabilities is absent for formulae with no advisory-database
records; verified a fixture without the key builds cleanly and renders
neither block.

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

🚀

@andrew
andrew merged commit 7c8b7ac into main Jul 29, 2026
16 checks passed
@andrew
andrew deleted the formula-vulnerabilities branch July 29, 2026 10:53
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