Skip to content

fix: set SARIF helpUri to vulnerability advisory URL#3351

Open
will-bates11 wants to merge 1 commit intoanchore:mainfrom
will-bates11:fix/sarif-helpuri-vulnerability-link
Open

fix: set SARIF helpUri to vulnerability advisory URL#3351
will-bates11 wants to merge 1 commit intoanchore:mainfrom
will-bates11:fix/sarif-helpuri-vulnerability-link

Conversation

@will-bates11
Copy link
Copy Markdown

@will-bates11 will-bates11 commented Apr 4, 2026

Problem

Every rule in the SARIF output has helpUri hardcoded to https://github.com/anchore/grype, regardless of which vulnerability is being reported. Tools that surface helpUri, such as GitHub Code Scanning, link users back to the Grype repository instead of the actual advisory for that CVE or GHSA.

Reported in #2874.

Fix

Add a helpURI() helper in presenter.go that resolves the best available link for a vulnerability in priority order:

  1. Vulnerability.DataSource, the direct advisory link (e.g. https://nvd.nist.gov/vuln/detail/CVE-… or https://github.com/advisories/GHSA-…)
  2. Vulnerability.URLs[0], first reference URL if no DataSource is set
  3. https://github.com/anchore/grype, fallback when neither field is populated

The sarifRules() function already computes a link string using the same source fields for the help text body; helpURI() applies the same priority to populate the helpUri field with the raw URL.

Tests

Added Test_helpURI with four subtests covering all resolution paths: DataSource takes precedence over URLs, first URL used when no DataSource, DataSource-only, and the no-data fallback.

Fixes #2874

The helpUri field on each SARIF rule was hardcoded to
https://github.com/anchore/grype regardless of the vulnerability being
reported. This means tooling that surfaces helpUri (e.g. GitHub Code
Scanning) links users back to the Grype repository instead of the
actual advisory.

Fix: add a helpURI() helper that resolves the best available link in
priority order:
  1. Vulnerability.DataSource (e.g. NVD or GHSA direct link)
  2. First entry in Vulnerability.URLs
  3. Fall back to https://github.com/anchore/grype if neither is set

Add Test_helpURI covering all three resolution paths.

Fixes anchore#2874
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.

HelpURI missing information in SARIF output

1 participant