fix: add filter to show packages with license violations but no vulnerabilities - #2919
fix: add filter to show packages with license violations but no vulnerabilities#2919summerpan688 wants to merge 7 commits into
Conversation
Fixes google#1643. Packages with license violations but no vulnerabilities were always hidden by showAndHideParentSections(), which only checked .vuln-tr rows. This adds a "Show license violations without vulnerabilities" checkbox that reveals these packages on demand, defaulting to off so existing report behavior is unchanged.
…ties Previously, clicking into a package with zero vulnerabilities (e.g. one with only a license violation) showed an empty vuln table, since vuln_table_template.gohtml renders a table with headers regardless of whether RegularVulns/HiddenVulns actually contain any entries. This now shows "No known vulnerabilities for this package." instead, reusing the existing .package-detail-title style.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
Looked into the failing Run unit tests checks — the failure is in TestDoScan/Test_curl_git_scanning, unrelated to the files changed in this PR (internal/output/html/*). The diff is a single modified timestamp on CVE-2025-63675 in the snapshot, which appears to just reflect the OSV DB updating that record between snapshot refreshes (saw the same pattern referenced in #2920). Confirmed locally that re-running with the latest main merged in still shows this as the only diff — happy to update the snapshot if preferred, just didn't want to bundle in an unrelated data-only diff without checking first. |
|
Hi @jess-lowe @another-rex , just checking in on this PR whenever you have a chance to take a look — no rush! Also wanted to flag that the CI test failures (Run unit tests) appear unrelated to this change; left a note with details above. Thanks so much! |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2919 +/- ##
==========================================
+ Coverage 79.37% 79.38% +0.01%
==========================================
Files 118 118
Lines 8077 8086 +9
==========================================
+ Hits 6411 6419 +8
- Misses 1309 1310 +1
Partials 357 357 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
another-rex
left a comment
There was a problem hiding this comment.
Thanks! Sorry for the late review, been a bit busy recently!
| {{template "vuln_table_entry_template.gohtml" $args}} | ||
| {{ end }} | ||
| </table> | ||
| +{{ end }} No newline at end of file |
There was a problem hiding this comment.
hmm... this looks weird, why is there a + here.
There was a problem hiding this comment.
Ah, that was a mistake and missing newline at end of file. Fixed — pushed in the latest commit.
| <input type="checkbox" id="uncalled-type-checkbox" data-type-uncalled-count="{{ .VulnTypeSummary.Hidden }}"> | ||
| Uncalled/Unimportant ({{ .VulnTypeSummary.Hidden }}) | ||
| </label> | ||
| {{ if .LicenseSummary.Summary }} |
There was a problem hiding this comment.
I think osv-scanner can have --license-violations without having the summary flag, LicenseSummary.ShowViolations is the bool here, we also need to show this.
There was a problem hiding this comment.
Good catch, thank you! You're right, updated to check LicenseSummary.ShowViolations instead of Summary so the checkbox shows up correctly even without the summary flag.
There was a problem hiding this comment.
Not sure if we need both the summary and license violations here or just a license violation check...
There was a problem hiding this comment.
I think just ShowViolations is enough here. Summary controls the separate license count summary, while ShowViolations is specifically set when an allowlist exists. Using both could also reintroduce the original issue where the checkbox disappears when violations exist but the summary isn't enabled.
| "license-violation-type-checkbox" | ||
| ); | ||
| if (licenseViolationCheckbox) { | ||
| licenseViolationCheckbox.addEventListener("change", () => { |
There was a problem hiding this comment.
do we need to add a stopPropagation here?
Actually we might not need applyFilers, since it's already being called by the parent listener. Please have a look.
There was a problem hiding this comment.
You're right — this checkbox lives inside type-filter-option-container, which already has a change listener that calls applyFilters. Removed the separate listener and folded the license-violation checkbox's state into the existing one, so applyFilters only runs once now.
- Use LicenseSummary.ShowViolations instead of Summary so the filter checkbox shows correctly when --licenses is set without a summary flag - Consolidate the license violation checkbox's change handling into the existing type-filter-option-container listener to avoid duplicate applyFilters calls - Fix missing newline at end of vuln_table_template.gohtml
Thanks for the thorough review! Pushed fixes for all three — replied inline on each. |
Fixes #1643
Summary
Packages with license violations but no vulnerabilities were always

hidden in the HTML report, since the filtering logic only checked
.vuln-trrows. This adds a "Show license violations withoutvulnerabilities" filter checkbox (default: off) that reveals these
packages on request.
Also fixed two related issues surfaced during testing:
(a label meant for packages whose vulns were filtered by call
analysis) — now shows "No known vulnerabilities" instead.
vuln table — now shows a placeholder message instead.
Design discussion
See discussion in the issue comment
"Show all packages“ vs. the more scoped "Show license violations without vulnerabilities"
(happy to adjust based on feedback)