Skip to content

fix(html): fix HTML filter #1605

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/output/html/base_image_template.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
{{ if gt .Count.AnalysisCount.Regular 0 }}
{{ $hasVuln = true }}
{{ end }}
<div class="layer-entry {{ if $hasVuln }}clickable clickable-layer{{ end }}" {{ if $hasVuln }}onclick="quickFilterByLayer('{{ $diffID }}', {{ $command }})"{{ end }}>
<div class="layer-entry {{ if $hasVuln }}clickable clickable-layer{{ end }}" {{ if $hasVuln }}onclick="quickFilterByLayer('{{ $diffID }}', '{{ .Index }} {{ $command }}')"{{ end }}>
<div {{ if $longCommand }} class="tooltip" {{ end }}>
<p class="layer-command"><span class="base-image-title">{{ .Index }}</span> {{ $command }}</p>
{{ if $longCommand }}
Expand Down
20 changes: 14 additions & 6 deletions internal/output/html/package_table_template.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
</td>
<td {{ if eq $element.VulnCount.AnalysisCount.Regular 0 }}class="uncalled-text" {{ end }}>{{ $element.Name }}</td>
<td {{ if eq $element.VulnCount.AnalysisCount.Regular 0 }}class="uncalled-text" {{ end }}>{{ $element.InstalledVersion }}</td>
{{ if ne $element.VulnCount.AnalysisCount.Regular 0 }}
<td>
<div class="tooltip no-underline">
{{ if ne $element.VulnCount.FixableCount.UnFixed 0 }}
Expand All @@ -47,12 +48,19 @@
</div>
</td>
<td>
{{ if ne $element.VulnCount.AnalysisCount.Regular 0 }}
{{ template "severity_summary_template.gohtml" $element.VulnCount.SeverityCount }}
{{ else }}
</td>
{{ else }}
<td>
<p class="fixable-tag no-fix">Filtered out</p>
</td>
<td>
<p class="uncalled-text">{{ getFilteredVulnReasons $element.HiddenVulns }}</p>
{{ end }}
</td>
{{ end }}



</tr>
<tr class="table-tr-details">
<td colspan="100%">
Expand All @@ -75,19 +83,19 @@
{{ end }}
<div class="layer-command-container">
{{ if $longCommand }}
<p class="package-detail-title">Introduced in layer #{{ $index }}:&nbsp;</p>
<p class="package-detail-title">Introduced in layer # {{ $index }}:&nbsp;</p>
<div class="tooltip">
<p class="layer-command">{{ $command }}</p>
<span class="tooltiptext layer-tooltiptext">{{ $originalCommand }}</span>
</div>
{{ else if ne $commandDetail "" }}
<p class="package-detail-title">Introduced in layer #{{ $index }}:&nbsp;</p>
<p class="package-detail-title">Introduced in layer # {{ $index }}:&nbsp;</p>
<div class="tooltip">
<p class="layer-command">{{ $command }}</p>
<span class="tooltiptext layer-tooltiptext">{{ $commandDetail }}</span>
</div>
{{ else }}
<p class="package-detail-title">Introduced in layer #{{ $index }}:&nbsp;</p>
<p class="package-detail-title">Introduced in layer # {{ $index }}:&nbsp;</p>
<p class="layer-command">{{ $command }}</p>
{{ end }}
</div>
Expand Down
10 changes: 7 additions & 3 deletions internal/output/html/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ const selectedTypeFilterValue = new Set(["all"]);
let selectedLayer = "all";

function quickFilterByLayer(DiffID, layerCommand) {
resetFilterText();
applyFilters(selectedTypeFilterValue, DiffID);
selectedLayer = DiffID;
applyFilters(selectedTypeFilterValue, selectedLayer);
const selectedDisplay = document.getElementById("layer-filter-selected");
selectedDisplay.textContent = layerCommand;
}
Expand Down Expand Up @@ -162,7 +162,11 @@ function showAndHideParentSections() {
`${packageRow.id}-details`
);
const vulnRows = packageDetails.querySelectorAll(".vuln-tr");
if (vulnRows.some(row => !row.classList.contains("hide-block"))) {
if (
Array.from(vulnRows).some(
row => !row.classList.contains("hide-block")
)
) {
sourceHasVisibleRows = true;
packageRow.classList.remove("hide-block");
return;
Expand Down
Loading