Skip to content

Instantly share code, notes, and snippets.

@ashishmadeti
Created November 12, 2021 05:42
Show Gist options
  • Save ashishmadeti/8459320844dcdb882bc42b64cf373552 to your computer and use it in GitHub Desktop.
Save ashishmadeti/8459320844dcdb882bc42b64cf373552 to your computer and use it in GitHub Desktop.
Template for generating a trivy report in CSV format
Image,PackageName,VulnerabilityID,Severity,Score,InstalledVersion,FixedVersion,Title
{{ range . }}
{{- $target := .Target -}}
{{- if (eq (len .Vulnerabilities) 0) }}
{{- $target }},,,,,,,
{{- else }}
{{- range .Vulnerabilities }}
{{- $description := .Title }}
{{- if not $description }}
{{- $description = .Description -}}
{{- if gt (len $description ) 150 -}}
{{- $description = (slice $description 0 150) | printf "%v..." -}}
{{- end}}
{{- end }}
{{- $target }},
{{- .PkgName }},
{{- .VulnerabilityID }},
{{- .Vulnerability.Severity }},
{{- $score := (index .CVSS "nvd").V3Score -}}
{{- if not $score -}}
{{- $score = (index .CVSS "redhat").V3Score -}}
{{- end -}}
{{- $score }},
{{- .InstalledVersion }},
{{- .FixedVersion }},
{{- replace "," ";" $description }}
{{ end }}
{{ end -}}
{{- end }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment