github.com/adevinta/lava@v0.7.2/internal/report/human.tmpl (about) 1 {{- /* report is the template used to render the full scan report. */ -}} 2 {{- define "report" -}} 3 {{template "status" .}} 4 {{template "summary" .}} 5 {{- if .Vulns}} 6 {{template "vulns" . -}} 7 {{end -}} 8 {{- end -}} 9 10 11 {{- /* status is the template used to render the status section of the report. */ -}} 12 {{- define "status" -}} 13 {{"STATUS" | bold | underline}} 14 {{if .Status -}} 15 {{template "checkStatus" .}} 16 {{else}} 17 No status updates received during the scan. 18 {{end}} 19 {{- end -}} 20 21 22 {{- /* checkStatus is the template used to render the checks and their status. */ -}} 23 {{- define "checkStatus" -}} 24 {{- range .Status}} 25 - {{.Checktype | bold}} → {{.Target|bold}}: {{.Status -}} 26 {{end}} 27 {{- end -}} 28 29 30 {{- /* summary is the template used to render the summary section of the report. */ -}} 31 {{- define "summary" -}} 32 {{"SUMMARY" | bold | underline}} 33 {{if .Total}} 34 {{template "vulnCount" .}} 35 {{else}} 36 No vulnerabilities found during the scan. 37 {{end}} 38 {{- end -}} 39 40 41 {{- /* vulnCount is the template used to render the vulnerability count. */ -}} 42 {{- define "vulnCount" -}} 43 {{"CRITICAL" | bold | magenta}}: {{index .Stats "critical"}} 44 {{"HIGH" | bold | red}}: {{index .Stats "high"}} 45 {{"MEDIUM" | bold | yellow}}: {{index .Stats "medium"}} 46 {{"LOW" | bold | cyan}}: {{index .Stats "low"}} 47 {{"INFO" | bold}}: {{index .Stats "info"}} 48 49 Number of excluded vulnerabilities not included in the summary table: {{.Excluded}} 50 {{- end -}} 51 52 53 {{- /* vulns is the template used to render the vulnerabilities section of the report. */ -}} 54 {{- define "vulns" -}} 55 {{"VULNERABILITIES" | bold | underline}} 56 {{range .Vulns}} 57 {{template "vuln" . -}} 58 {{end}} 59 {{- end -}} 60 61 62 {{- /* vuln is the template used to render one vulnerability report */ -}} 63 {{- define "vuln" -}} 64 {{template "vulnTitle" .}} 65 66 {{"TARGET" | bold}} 67 {{.CheckData.Target | trim}} 68 {{""}} 69 70 {{- $affectedResource:= .AffectedResourceString -}} 71 {{- if not $affectedResource -}} 72 {{- $affectedResource = .AffectedResource -}} 73 {{- end -}} 74 {{- if $affectedResource}} 75 {{"AFFECTED RESOURCE" | bold}} 76 {{$affectedResource | trim}} 77 {{end -}} 78 79 {{- if .Description}} 80 {{"DESCRIPTION" | bold}} 81 {{.Description | trim}} 82 {{end -}} 83 84 {{- if .Details}} 85 {{"DETAILS" | bold}} 86 {{.Details | trim}} 87 {{end -}} 88 89 {{- if .ImpactDetails}} 90 {{"IMPACT" | bold}} 91 {{.ImpactDetails | trim}} 92 {{end -}} 93 94 {{- if .Recommendations}} 95 {{template "vulnRecoms" .}} 96 {{end -}} 97 98 {{- if .References}} 99 {{template "vulnRefs" .}} 100 {{end -}} 101 102 {{- if .Resources}} 103 {{template "vulnRscs" .}} 104 {{end -}} 105 {{- end -}} 106 107 108 {{- /* vulnTitle is the template used to render the title of a vulnerability. */ -}} 109 {{- define "vulnTitle" -}} 110 {{- if eq .Severity.String "critical" -}} 111 {{printf "=== %v (%v) ===" (trim .Summary) (upper .Severity.String) | bold | magenta}} 112 {{- else if eq .Severity.String "high" -}} 113 {{printf "=== %v (%v) ===" (trim .Summary) (upper .Severity.String) | bold | red}} 114 {{- else if eq .Severity.String "medium" -}} 115 {{printf "=== %v (%v) ===" (trim .Summary) (upper .Severity.String) | bold | yellow}} 116 {{- else if eq .Severity.String "low" -}} 117 {{printf "=== %v (%v) ===" (trim .Summary) (upper .Severity.String) | bold | cyan}} 118 {{- else -}} 119 {{printf "=== %v (%v) ===" (trim .Summary) (upper .Severity.String) | bold}} 120 {{- end -}} 121 {{- end -}} 122 123 124 {{- /* vulnRecoms is the template used to render the recommendations to fix a vulnerability. */ -}} 125 {{- define "vulnRecoms" -}} 126 {{"RECOMMENDATIONS" | bold}} 127 {{- range .Recommendations}} 128 - {{. | trim -}} 129 {{end}} 130 {{- end -}} 131 132 133 {{- /* vulnRefs is the template used to render a list of references with more details about the vulnerability. */ -}} 134 {{- define "vulnRefs" -}} 135 {{"REFERENCES" | bold}} 136 {{- range .References}} 137 - {{. | trim -}} 138 {{end}} 139 {{- end -}} 140 141 142 {{- /* vulnRscs is the template used to render the list of affected resources. */ -}} 143 {{- define "vulnRscs" -}} 144 {{"RESOURCES" | bold}} 145 {{- range $resource := .Resources}} 146 {{template "vulnRsc" . -}} 147 {{end}} 148 {{- end -}} 149 150 151 {{- /* vulnRsc is the template used to render the details of a single resource. */ -}} 152 {{- define "vulnRsc" -}} 153 {{- $rsc := . -}} 154 - {{$rsc.Name | bold}}: 155 {{- range $row := $rsc.Rows}}{{range $header := $rsc.Header}} 156 {{$header | trim | bold}}: {{index $row $header | trim -}} 157 {{end}}{{end}} 158 {{- end -}} 159 160 161 {{- /* Render the report. */ -}} 162 {{- template "report" . -}}