Skip to content

Commit 1870f28

Browse files
authored
fix(report): don't include empty strings in .vulnerabilities[].identifiers[].url when gitlab.tpl is used (aquasecurity#6348)
1 parent 6c81e55 commit 1870f28

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

contrib/gitlab.tpl

+9-2
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,11 @@
7373
{{- /* TODO: Type not extractable - https://github.com/aquasecurity/trivy-db/pull/24 */}}
7474
"type": "cve",
7575
"name": "{{ .VulnerabilityID }}",
76-
"value": "{{ .VulnerabilityID }}",
76+
"value": "{{ .VulnerabilityID }}"
77+
{{- /* cf. https://gitlab.com/gitlab-org/security-products/security-report-schemas/-/blob/e3d280d7f0862ca66a1555ea8b24016a004bb914/dist/container-scanning-report-format.json#L157-179 */}}
78+
{{- if .PrimaryURL | regexMatch "^(https?|ftp)://.+" -}},
7779
"url": "{{ .PrimaryURL }}"
80+
{{- end }}
7881
}
7982
],
8083
"links": [
@@ -85,9 +88,13 @@
8588
{{- else -}}
8689
,
8790
{{- end -}}
91+
{{- if . | regexMatch "^(https?|ftp)://.+" -}}
8892
{
89-
"url": "{{ regexFind "[^ ]+" . }}"
93+
"url": "{{ . }}"
9094
}
95+
{{- else -}}
96+
{{- $l_first = true }}
97+
{{- end -}}
9198
{{- end }}
9299
]
93100
}

0 commit comments

Comments
 (0)