Skip to content

fix: add filter to show packages with license violations but no vulnerabilities - #2919

Open
summerpan688 wants to merge 7 commits into
google:mainfrom
summerpan688:fix/1643-license-violation-filter
Open

fix: add filter to show packages with license violations but no vulnerabilities#2919
summerpan688 wants to merge 7 commits into
google:mainfrom
summerpan688:fix/1643-license-violation-filter

Conversation

@summerpan688

@summerpan688 summerpan688 commented Jul 8, 2026

Copy link
Copy Markdown

Fixes #1643

Summary

Packages with license violations but no vulnerabilities were always
hidden in the HTML report, since the filtering logic only checked
.vuln-tr rows. This adds a "Show license violations without
vulnerabilities" filter checkbox (default: off) that reveals these
packages on request.
image

Also fixed two related issues surfaced during testing:

  • Packages with zero vulnerabilities were mislabeled "Filtered out"
    (a label meant for packages whose vulns were filtered by call
    analysis) — now shows "No known vulnerabilities" instead.
image
  • Clicking into these packages' details previously showed an empty
    vuln table — now shows a placeholder message instead.
image

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)

summerpan688 and others added 3 commits July 5, 2026 22:00
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.
@google-cla

google-cla Bot commented Jul 8, 2026

Copy link
Copy Markdown

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.

@summerpan688 summerpan688 changed the title Fix/1643 Add filter to show packages with license violations but no vulnerabilities fix: add filter to show packages with license violations but no vulnerabilities Jul 8, 2026
@summerpan688

Copy link
Copy Markdown
Author

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.

@summerpan688

Copy link
Copy Markdown
Author

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!
(Also, apologies for the gap in activity — my account was temporarily suspended and I just got access back)

@another-rex
another-rex self-requested a review August 5, 2026 01:57
@codecov-commenter

codecov-commenter commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.38%. Comparing base (d54ee37) to head (e068ab7).
⚠️ Report is 11 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@another-rex another-rex left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm... this looks weird, why is there a + here.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 }}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we need both the summary and license violations here or just a license violation check...

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread internal/output/html/script.js Outdated
"license-violation-type-checkbox"
);
if (licenseViolationCheckbox) {
licenseViolationCheckbox.addEventListener("change", () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@summerpan688

Copy link
Copy Markdown
Author

Thanks! Sorry for the late review, been a bit busy recently!

Thanks for the thorough review! Pushed fixes for all three — replied inline on each.

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.

Add a "Show all packages" filter to the HTML output

3 participants