Skip to content

Commit

Permalink
fix(html): fix HTML filter (#1605)
Browse files Browse the repository at this point in the history
converts NodeList to Array before using `.some()`

Co-authored-by: Rex P <[email protected]>
  • Loading branch information
hogo6002 and another-rex authored Feb 12, 2025
1 parent e7d6a48 commit 6437180
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
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

0 comments on commit 6437180

Please sign in to comment.