Skip to content
Open
6 changes: 6 additions & 0 deletions internal/output/html/filter_template.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@
<input type="checkbox" id="uncalled-type-checkbox" data-type-uncalled-count="{{ .VulnTypeSummary.Hidden }}">
Uncalled/Unimportant ({{ .VulnTypeSummary.Hidden }})
</label>
{{ if .LicenseSummary.ShowViolations }}
<label class="filter-option" for="license-violation-type-checkbox">
<input type="checkbox" id="license-violation-type-checkbox">
Show license violations without vulnerabilities
</label>
{{ end }}
</div>
</div>
</div>
Expand Down
19 changes: 17 additions & 2 deletions internal/output/html/package_table_template.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,21 @@
{{ range $rowIndex, $element := .Packages }}
{{ $index := uniqueID }}
{{ $isUncalled := false }}
{{ if eq $element.VulnCount.AnalysisCount.Regular 0 }}
{{ if and (eq $element.VulnCount.AnalysisCount.Regular 0) (gt (len $element.HiddenVulns) 0) }}
{{ $isUncalled = true }}
{{ end }}
{{ $hasNoVulns := false }}
{{ if and (eq $element.VulnCount.AnalysisCount.Regular 0) (eq (len $element.HiddenVulns) 0) }}
{{ $hasNoVulns = true }}
{{ end }}
{{ $hasLicenseViolations := false }}
{{ if gt (len .LicenseViolations) 0 }}
{{ $hasLicenseViolations = true }}
{{ end }}
<tr class="table-tr package-tr {{if $element.LayerDetail }}has-layer-info"
data-layer="{{ $element.LayerDetail.LayerInfo.LayerMetadata.DiffID }}{{ end }}" id="table-tr-{{ $index }}" onclick="showPackageDetails('{{ $index }}')">
data-layer="{{ $element.LayerDetail.LayerInfo.LayerMetadata.DiffID }}{{ end }}"
data-has-license-violation="{{ $hasLicenseViolations }}"
id="table-tr-{{ $index }}" onclick="showPackageDetails('{{ $index }}')">
<td class="icon-td">
<div class="expand-icon">
<i class="material-icons">play_arrow</i>
Expand All @@ -56,6 +62,14 @@
{{ end }}
</td>
{{ if not $isUncalled }}
{{ if $hasNoVulns }}
<td>
<p class="fixable-tag has-fix">No known vulnerabilities</p>
</td>
<td>
<p>--</p>
</td>
{{ else }}
<td>
<div class="tooltip no-underline">
{{ if ne $element.VulnCount.FixableCount.UnFixed 0 }}
Expand All @@ -76,6 +90,7 @@
<td>
{{ template "severity_summary_template.gohtml" $element.VulnCount.SeverityCount }}
</td>
{{ end }}
{{ else }}
<td>
<p class="fixable-tag no-fix">Filtered out</p>
Expand Down
28 changes: 23 additions & 5 deletions internal/output/html/script.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const selectedTypeFilterValue = new Set(["all"]);
let selectedLayer = "all";
let showLicenseViolations = false;
const tabScrollPositions = {};

function toggleDetails(summaryID) {
Expand Down Expand Up @@ -213,11 +214,13 @@ function showAndHideParentSections() {
`${packageRow.id}-details`
);
const vulnRows = packageDetails.querySelectorAll(".vuln-tr");
if (
Array.from(vulnRows).some(
row => !row.classList.contains("hide-block")
)
) {
const hasVisibleVuln = Array.from(vulnRows).some(
row => !row.classList.contains("hide-block")
);
const hasLicenseViolation =
packageRow.getAttribute("data-has-license-violation") === "true";

if (hasVisibleVuln || (showLicenseViolations && hasLicenseViolation)) {
sourceHasVisibleRows = true;
packageRow.classList.remove("hide-block");
return;
Expand Down Expand Up @@ -409,6 +412,13 @@ function resetTypeCheckbox() {
}
uncalledTypeCheckbox.checked = false;
}
const licenseViolationCheckbox = document.getElementById(
"license-violation-type-checkbox"
);
if (licenseViolationCheckbox) {
licenseViolationCheckbox.checked = false;
}
showLicenseViolations = false;
}

document.addEventListener("DOMContentLoaded", () => {
Expand All @@ -427,6 +437,10 @@ document.addEventListener("DOMContentLoaded", () => {
const projectCheckbox = document.getElementById("project-type-checkbox"); // Project vulnerabilities
const osCheckbox = document.getElementById("os-type-checkbox"); // OS vulnerabilities
const uncalledCheckbox = document.getElementById("uncalled-type-checkbox"); // OS vulnerabilities
const licenseViolationCheckbox = document.getElementById(
"license-violation-type-checkbox"
);

selectedTypeFilterValue.clear();

if (allTypesCheckbox !== null) {
Expand Down Expand Up @@ -454,6 +468,10 @@ document.addEventListener("DOMContentLoaded", () => {
selectedTypeFilterValue.add("uncalled");
}

if (licenseViolationCheckbox) {
showLicenseViolations = licenseViolationCheckbox.checked;
}

applyFilters(selectedTypeFilterValue, selectedLayer);
});

Expand Down
4 changes: 4 additions & 0 deletions internal/output/html/vuln_table_template.gohtml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{{ if and (eq (len .RegularVulns) 0) (eq (len .HiddenVulns) 0) }}
<p class="package-detail-title">No known vulnerabilities for this package.</p>
{{ else }}
<table class="inner-table">
<tr>
<th>Vulnerability ID</th>
Expand All @@ -17,3 +20,4 @@
{{template "vuln_table_entry_template.gohtml" $args}}
{{ end }}
</table>
{{ end }}
Loading