Skip to content

Commit c0d79fa

Browse files
feat(report): update gitlab template to populate operating_system value (#7735)
1 parent f75c0d1 commit c0d79fa

File tree

4 files changed

+239
-7
lines changed

4 files changed

+239
-7
lines changed

contrib/gitlab.tpl

+10-3
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,18 @@
2424
"status": "success",
2525
"type": "container_scanning"
2626
},
27+
{{- $image := "Unknown" -}}
28+
{{- $os := "Unknown" -}}
29+
{{- range . }}
30+
{{- if eq .Class "os-pkgs" -}}
31+
{{- $target := .Target }}
32+
{{- $image = $target | regexFind "[^\\s]+" }}
33+
{{- $os = $target | splitList "(" | last | trimSuffix ")" }}
34+
{{- end }}
35+
{{- end }}
2736
"vulnerabilities": [
2837
{{- $t_first := true }}
2938
{{- range . }}
30-
{{- $target := .Target }}
31-
{{- $image := $target | regexFind "[^\\s]+" }}
3239
{{- range .Vulnerabilities -}}
3340
{{- if $t_first -}}
3441
{{- $t_first = false -}}
@@ -65,7 +72,7 @@
6572
"version": "{{ .InstalledVersion }}"
6673
},
6774
{{- /* TODO: No mapping available - https://github.com/aquasecurity/trivy/issues/332 */}}
68-
"operating_system": "Unknown",
75+
"operating_system": "{{ $os }}",
6976
"image": "{{ $image }}"
7077
},
7178
"identifiers": [

integration/client_server_test.go

+11
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,17 @@ func TestClientServerWithFormat(t *testing.T) {
323323
},
324324
golden: "testdata/alpine-310.gitlab.golden",
325325
},
326+
{
327+
name: "scan package-lock.json with gitlab template (Unknown os and image)",
328+
args: csArgs{
329+
Command: "fs",
330+
Format: "template",
331+
TemplatePath: "@../contrib/gitlab.tpl",
332+
Target: "testdata/fixtures/repo/npm/",
333+
ListAllPackages: true,
334+
},
335+
golden: "testdata/npm.gitlab.golden",
336+
},
326337
{
327338
name: "alpine 3.10 with gitlab-codequality template",
328339
args: csArgs{

integration/testdata/alpine-310.gitlab.golden

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
},
3838
"version": "1.1.1c-r0"
3939
},
40-
"operating_system": "Unknown",
40+
"operating_system": "alpine 3.10.2",
4141
"image": "testdata/fixtures/images/alpine-310.tar.gz"
4242
},
4343
"identifiers": [
@@ -104,7 +104,7 @@
104104
},
105105
"version": "1.1.1c-r0"
106106
},
107-
"operating_system": "Unknown",
107+
"operating_system": "alpine 3.10.2",
108108
"image": "testdata/fixtures/images/alpine-310.tar.gz"
109109
},
110110
"identifiers": [
@@ -191,7 +191,7 @@
191191
},
192192
"version": "1.1.1c-r0"
193193
},
194-
"operating_system": "Unknown",
194+
"operating_system": "alpine 3.10.2",
195195
"image": "testdata/fixtures/images/alpine-310.tar.gz"
196196
},
197197
"identifiers": [
@@ -258,7 +258,7 @@
258258
},
259259
"version": "1.1.1c-r0"
260260
},
261-
"operating_system": "Unknown",
261+
"operating_system": "alpine 3.10.2",
262262
"image": "testdata/fixtures/images/alpine-310.tar.gz"
263263
},
264264
"identifiers": [
+214
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
{
2+
"version": "15.0.7",
3+
"scan": {
4+
"analyzer": {
5+
"id": "trivy",
6+
"name": "Trivy",
7+
"vendor": {
8+
"name": "Aqua Security"
9+
},
10+
"version": "dev"
11+
},
12+
"end_time": "2021-08-25T12:20:30",
13+
"scanner": {
14+
"id": "trivy",
15+
"name": "Trivy",
16+
"url": "https://github.com/aquasecurity/trivy/",
17+
"vendor": {
18+
"name": "Aqua Security"
19+
},
20+
"version": "dev"
21+
},
22+
"start_time": "2021-08-25T12:20:30",
23+
"status": "success",
24+
"type": "container_scanning"
25+
},
26+
"vulnerabilities": [
27+
{
28+
"id": "CVE-2019-11358",
29+
"name": "jquery: Prototype pollution in object's prototype leading to denial of service, remote code execution, or property injection",
30+
"description": "jQuery before 3.4.0, as used in Drupal, Backdrop CMS, and other products, mishandles jQuery.extend(true, {}, ...) because of Object.prototype pollution. If an unsanitized source object contained an enumerable __proto__ property, it could extend the native Object.prototype.",
31+
"severity": "Medium",
32+
"solution": "Upgrade jquery to 3.4.0",
33+
"location": {
34+
"dependency": {
35+
"package": {
36+
"name": "jquery"
37+
},
38+
"version": "3.3.9"
39+
},
40+
"operating_system": "Unknown",
41+
"image": "Unknown"
42+
},
43+
"identifiers": [
44+
{
45+
"type": "cve",
46+
"name": "CVE-2019-11358",
47+
"value": "CVE-2019-11358",
48+
"url": "https://avd.aquasec.com/nvd/cve-2019-11358"
49+
}
50+
],
51+
"links": [{
52+
"url": "http://lists.opensuse.org/opensuse-security-announce/2019-08/msg00006.html"
53+
},{
54+
"url": "http://lists.opensuse.org/opensuse-security-announce/2019-08/msg00025.html"
55+
},{
56+
"url": "http://packetstormsecurity.com/files/152787/dotCMS-5.1.1-Vulnerable-Dependencies.html"
57+
},{
58+
"url": "http://packetstormsecurity.com/files/153237/RetireJS-CORS-Issue-Script-Execution.html"
59+
},{
60+
"url": "http://packetstormsecurity.com/files/156743/OctoberCMS-Insecure-Dependencies.html"
61+
},{
62+
"url": "http://seclists.org/fulldisclosure/2019/May/10"
63+
},{
64+
"url": "http://seclists.org/fulldisclosure/2019/May/11"
65+
},{
66+
"url": "http://seclists.org/fulldisclosure/2019/May/13"
67+
},{
68+
"url": "http://www.openwall.com/lists/oss-security/2019/06/03/2"
69+
},{
70+
"url": "http://www.securityfocus.com/bid/108023"
71+
},{
72+
"url": "https://access.redhat.com/errata/RHBA-2019:1570"
73+
},{
74+
"url": "https://access.redhat.com/errata/RHSA-2019:1456"
75+
},{
76+
"url": "https://access.redhat.com/errata/RHSA-2019:2587"
77+
},{
78+
"url": "https://access.redhat.com/errata/RHSA-2019:3023"
79+
},{
80+
"url": "https://access.redhat.com/errata/RHSA-2019:3024"
81+
},{
82+
"url": "https://access.redhat.com/security/cve/CVE-2019-11358"
83+
},{
84+
"url": "https://backdropcms.org/security/backdrop-sa-core-2019-009"
85+
},{
86+
"url": "https://blog.jquery.com/2019/04/10/jquery-3-4-0-released/"
87+
},{
88+
"url": "https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-11358"
89+
},{
90+
"url": "https://github.com/DanielRuf/snyk-js-jquery-174006?files=1"
91+
},{
92+
"url": "https://github.com/advisories/GHSA-6c3j-c64m-qhgq"
93+
},{
94+
"url": "https://github.com/jquery/jquery/commit/753d591aea698e57d6db58c9f722cd0808619b1b"
95+
},{
96+
"url": "https://github.com/jquery/jquery/pull/4333"
97+
},{
98+
"url": "https://github.com/rails/jquery-rails/blob/master/CHANGELOG.md#434"
99+
},{
100+
"url": "https://hackerone.com/reports/454365"
101+
},{
102+
"url": "https://kb.pulsesecure.net/articles/Pulse_Security_Advisories/SA44601"
103+
},{
104+
"url": "https://linux.oracle.com/cve/CVE-2019-11358.html"
105+
},{
106+
"url": "https://linux.oracle.com/errata/ELSA-2020-4847.html"
107+
},{
108+
"url": "https://lists.apache.org/thread.html/08720ef215ee7ab3386c05a1a90a7d1c852bf0706f176a7816bf65fc@%3Ccommits.airflow.apache.org%3E"
109+
},{
110+
"url": "https://lists.apache.org/thread.html/519eb0fd45642dcecd9ff74cb3e71c20a4753f7d82e2f07864b5108f@%3Cdev.drill.apache.org%3E"
111+
},{
112+
"url": "https://lists.apache.org/thread.html/5928aa293e39d248266472210c50f176cac1535220f2486e6a7fa844@%3Ccommits.airflow.apache.org%3E"
113+
},{
114+
"url": "https://lists.apache.org/thread.html/6097cdbd6f0a337bedd9bb5cc441b2d525ff002a96531de367e4259f@%3Ccommits.airflow.apache.org%3E"
115+
},{
116+
"url": "https://lists.apache.org/thread.html/88fb0362fd40e5b605ea8149f63241537b8b6fb5bfa315391fc5cbb7@%3Ccommits.airflow.apache.org%3E"
117+
},{
118+
"url": "https://lists.apache.org/thread.html/b0656d359c7d40ec9f39c8cc61bca66802ef9a2a12ee199f5b0c1442@%3Cdev.drill.apache.org%3E"
119+
},{
120+
"url": "https://lists.apache.org/thread.html/b736d0784cf02f5a30fbb4c5902762a15ad6d47e17e2c5a17b7d6205@%3Ccommits.airflow.apache.org%3E"
121+
},{
122+
"url": "https://lists.apache.org/thread.html/ba79cf1658741e9f146e4c59b50aee56656ea95d841d358d006c18b6@%3Ccommits.roller.apache.org%3E"
123+
},{
124+
"url": "https://lists.apache.org/thread.html/bcce5a9c532b386c68dab2f6b3ce8b0cc9b950ec551766e76391caa3@%3Ccommits.nifi.apache.org%3E"
125+
},{
126+
"url": "https://lists.apache.org/thread.html/f9bc3e55f4e28d1dcd1a69aae6d53e609a758e34d2869b4d798e13cc@%3Cissues.drill.apache.org%3E"
127+
},{
128+
"url": "https://lists.apache.org/thread.html/r2041a75d3fc09dec55adfd95d598b38d22715303f65c997c054844c9@%3Cissues.flink.apache.org%3E"
129+
},{
130+
"url": "https://lists.apache.org/thread.html/r2baacab6e0acb5a2092eb46ae04fd6c3e8277b4fd79b1ffb7f3254fa@%3Cissues.flink.apache.org%3E"
131+
},{
132+
"url": "https://lists.apache.org/thread.html/r38f0d1aa3c923c22977fe7376508f030f22e22c1379fbb155bf29766@%3Cdev.syncope.apache.org%3E"
133+
},{
134+
"url": "https://lists.apache.org/thread.html/r41b5bfe009c845f67d4f68948cc9419ac2d62e287804aafd72892b08@%3Cissues.flink.apache.org%3E"
135+
},{
136+
"url": "https://lists.apache.org/thread.html/r7aac081cbddb6baa24b75e74abf0929bf309b176755a53e3ed810355@%3Cdev.flink.apache.org%3E"
137+
},{
138+
"url": "https://lists.apache.org/thread.html/r7d64895cc4dff84d0becfc572b20c0e4bf9bfa7b10c6f5f73e783734@%3Cdev.storm.apache.org%3E"
139+
},{
140+
"url": "https://lists.apache.org/thread.html/r7e8ebccb7c022e41295f6fdb7b971209b83702339f872ddd8cf8bf73@%3Cissues.flink.apache.org%3E"
141+
},{
142+
"url": "https://lists.apache.org/thread.html/rac25da84ecdcd36f6de5ad0d255f4e967209bbbebddb285e231da37d@%3Cissues.flink.apache.org%3E"
143+
},{
144+
"url": "https://lists.apache.org/thread.html/rca37935d661f4689cb4119f1b3b224413b22be161b678e6e6ce0c69b@%3Ccommits.nifi.apache.org%3E"
145+
},{
146+
"url": "https://lists.debian.org/debian-lts-announce/2019/05/msg00006.html"
147+
},{
148+
"url": "https://lists.debian.org/debian-lts-announce/2019/05/msg00029.html"
149+
},{
150+
"url": "https://lists.debian.org/debian-lts-announce/2020/02/msg00024.html"
151+
},{
152+
"url": "https://lists.fedoraproject.org/archives/list/[email protected]/message/4UOAZIFCSZ3ENEFOR5IXX6NFAD3HV7FA/"
153+
},{
154+
"url": "https://lists.fedoraproject.org/archives/list/[email protected]/message/5IABSKTYZ5JUGL735UKGXL5YPRYOPUYI/"
155+
},{
156+
"url": "https://lists.fedoraproject.org/archives/list/[email protected]/message/KYH3OAGR2RTCHRA5NOKX2TES7SNQMWGO/"
157+
},{
158+
"url": "https://lists.fedoraproject.org/archives/list/[email protected]/message/QV3PKZC3PQCO3273HAT76PAQZFBEO4KP/"
159+
},{
160+
"url": "https://lists.fedoraproject.org/archives/list/[email protected]/message/RLXRX23725JL366CNZGJZ7AQQB7LHQ6F/"
161+
},{
162+
"url": "https://lists.fedoraproject.org/archives/list/[email protected]/message/WZW27UCJ5CYFL4KFFFMYMIBNMIU2ALG5/"
163+
},{
164+
"url": "https://nvd.nist.gov/vuln/detail/CVE-2019-11358"
165+
},{
166+
"url": "https://seclists.org/bugtraq/2019/Apr/32"
167+
},{
168+
"url": "https://seclists.org/bugtraq/2019/Jun/12"
169+
},{
170+
"url": "https://seclists.org/bugtraq/2019/May/18"
171+
},{
172+
"url": "https://security.netapp.com/advisory/ntap-20190919-0001/"
173+
},{
174+
"url": "https://snyk.io/vuln/SNYK-JS-JQUERY-174006"
175+
},{
176+
"url": "https://www.debian.org/security/2019/dsa-4434"
177+
},{
178+
"url": "https://www.debian.org/security/2019/dsa-4460"
179+
},{
180+
"url": "https://www.drupal.org/sa-core-2019-006"
181+
},{
182+
"url": "https://www.oracle.com//security-alerts/cpujul2021.html"
183+
},{
184+
"url": "https://www.oracle.com/security-alerts/cpuApr2021.html"
185+
},{
186+
"url": "https://www.oracle.com/security-alerts/cpuapr2020.html"
187+
},{
188+
"url": "https://www.oracle.com/security-alerts/cpujan2020.html"
189+
},{
190+
"url": "https://www.oracle.com/security-alerts/cpujan2021.html"
191+
},{
192+
"url": "https://www.oracle.com/security-alerts/cpujul2020.html"
193+
},{
194+
"url": "https://www.oracle.com/security-alerts/cpuoct2020.html"
195+
},{
196+
"url": "https://www.oracle.com/security-alerts/cpuoct2021.html"
197+
},{
198+
"url": "https://www.oracle.com/technetwork/security-advisory/cpujul2019-5072835.html"
199+
},{
200+
"url": "https://www.oracle.com/technetwork/security-advisory/cpuoct2019-5072832.html"
201+
},{
202+
"url": "https://www.privacy-wise.com/mitigating-cve-2019-11358-in-old-versions-of-jquery/"
203+
},{
204+
"url": "https://www.synology.com/security/advisory/Synology_SA_19_19"
205+
},{
206+
"url": "https://www.tenable.com/security/tns-2019-08"
207+
},{
208+
"url": "https://www.tenable.com/security/tns-2020-02"
209+
}
210+
]
211+
}
212+
],
213+
"remediations": []
214+
}

0 commit comments

Comments
 (0)