Skip to content

Commit

Permalink
[CR] internal/report/human.tmpl: fix stale exclusions formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jroimartin committed Aug 23, 2024
1 parent 58948df commit 2f7bb5a
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions internal/report/human.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{{template "vulns" . -}}
{{end -}}
{{- if not .AllExclMatched}}
{{template "exclsNotMatched" . -}}
{{template "staleExcls" . -}}
{{end -}}
{{- end -}}

Expand Down Expand Up @@ -161,39 +161,41 @@ Number of excluded vulnerabilities not included in the summary table: {{.Exclude
{{- $rsc := . -}}
- {{$rsc.Name | bold}}:
{{- range $row := $rsc.Rows}}{{range $i, $header := $rsc.Header}}
{{if eq $i 0}}- {{else}} {{end}}{{ $header | trim | bold}}: {{index $row $header | trim -}}
{{if eq $i 0}}- {{else}} {{end}}{{$header | trim | bold}}: {{index $row $header | trim -}}
{{end}}{{end}}
{{- end -}}

{{- /* exclsNotMatched is the template used to render the details of a the not matched exclusions. */ -}}
{{define "exclsNotMatched" -}}
{{"The following exclusions don't match any finding:" | red }}
{{- /* staleExcls is the template used to render the details of the stale exclusions. */ -}}
{{- define "staleExcls" -}}
{{"STALE EXCLUSIONS" | bold | underline}}

{{range $excl := .Exclusions}}
{{- if not $excl.Matched -}}
{{template "excl" .}}
{{end -}}
{{- if not $excl.Matched}}
{{- template "excl" . -}}
{{end -}}
{{end}}
{{- end -}}

{{- /* excl is the template used to render an exclusion. */ -}}
{{- define "excl" -}}
{{- $pref := "- " -}}
{{- if .Target}}
{{"Target: " | bold}}{{.Target | trim -}}
{{- $pref}}{{"Target" | bold}}: {{.Target | trim}}{{$pref = " "}}
{{end -}}
{{- if .Description}}
{{"Description: " | bold}}{{.Description | trim -}}
{{- $pref}}{{"Description" | bold}}: {{.Description | trim}}{{$pref = " "}}
{{end -}}
{{- if .Resource}}
{{"Resource: " | bold}}{{.Resource | trim -}}
{{- $pref}}{{"Resource" | bold}}: {{.Resource | trim}}{{$pref = " "}}
{{end -}}
{{- if .Fingerprint}}
{{"Fingerprint: " | bold}}{{.Fingerprint | trim -}}
{{- $pref}}{{"Fingerprint" | bold}}: {{.Fingerprint | trim}}{{$pref = " "}}
{{end -}}
{{- if .Summary}}
{{"Summary: " | bold}}{{.Summary | trim -}}
{{- $pref}}{{"Summary" | bold}}: {{.Summary | trim}}{{$pref = " "}}
{{end -}}
{{- if not .ExpirationDate.IsZero}}
{{"Expiration Date: " | bold}}{{.ExpirationDate.String | trim -}}
{{- $pref}}{{"Expiration Date" | bold}}: {{.ExpirationDate.String | trim}}{{$pref = " "}}
{{end -}}
{{- end -}}

Expand Down

0 comments on commit 2f7bb5a

Please sign in to comment.