@@ -14,12 +14,15 @@ var (
14
14
Namespace : "default" ,
15
15
Kind : "Deploy" ,
16
16
Name : "orion" ,
17
- Metadata : types.Metadata {
18
- RepoTags : []string {
19
- "alpine:3.14" ,
20
- },
21
- RepoDigests : []string {
22
- "alpine:3.14@sha256:8fe1727132b2506c17ba0e1f6a6ed8a016bb1f5735e43b2738cd3fd1979b6260" ,
17
+ Metadata : []types.Metadata {
18
+ {
19
+ ImageID : "123" ,
20
+ RepoTags : []string {
21
+ "alpine:3.14" ,
22
+ },
23
+ RepoDigests : []string {
24
+ "alpine:3.14@sha256:8fe1727132b2506c17ba0e1f6a6ed8a016bb1f5735e43b2738cd3fd1979b6260" ,
25
+ },
23
26
},
24
27
},
25
28
Results : types.Results {
@@ -69,12 +72,15 @@ var (
69
72
Namespace : "default" ,
70
73
Kind : "Deploy" ,
71
74
Name : "orion" ,
72
- Metadata : types.Metadata {
73
- RepoTags : []string {
74
- "alpine:3.14" ,
75
- },
76
- RepoDigests : []string {
77
- "alpine:3.14@sha256:8fe1727132b2506c17ba0e1f6a6ed8a016bb1f5735e43b2738cd3fd1979b6260" ,
75
+ Metadata : []types.Metadata {
76
+ {
77
+ ImageID : "123" ,
78
+ RepoTags : []string {
79
+ "alpine:3.14" ,
80
+ },
81
+ RepoDigests : []string {
82
+ "alpine:3.14@sha256:8fe1727132b2506c17ba0e1f6a6ed8a016bb1f5735e43b2738cd3fd1979b6260" ,
83
+ },
78
84
},
79
85
},
80
86
Results : types.Results {
@@ -113,16 +119,117 @@ var (
113
119
},
114
120
}
115
121
122
+ image1WithVulns = Resource {
123
+ Namespace : "default" ,
124
+ Kind : "Pod" ,
125
+ Name : "multi-image-pod" ,
126
+ Metadata : []types.Metadata {
127
+ {
128
+ ImageID : "image1" ,
129
+ RepoTags : []string {
130
+ "alpine:3.14" ,
131
+ },
132
+ RepoDigests : []string {
133
+ "alpine:3.14@sha256:8fe1727132b2506c17ba0e1f6a6ed8a016bb1f5735e43b2738cd3fd1979b6260" ,
134
+ },
135
+ },
136
+ },
137
+ Results : types.Results {
138
+ {
139
+ Vulnerabilities : []types.DetectedVulnerability {
140
+ {
141
+ VulnerabilityID : "CVE-2022-1111" ,
142
+ Vulnerability : dbTypes.Vulnerability {Severity : "LOW" },
143
+ },
144
+ },
145
+ },
146
+ },
147
+ }
148
+
149
+ image2WithVulns = Resource {
150
+ Namespace : "default" ,
151
+ Kind : "Pod" ,
152
+ Name : "multi-image-pod" ,
153
+ Metadata : []types.Metadata {
154
+ {
155
+ ImageID : "image2" ,
156
+ RepoTags : []string {
157
+ "alpine:3.17.3" ,
158
+ },
159
+ RepoDigests : []string {
160
+ "alpine@sha256:124c7d2707904eea7431fffe91522a01e5a861a624ee31d03372cc1d138a3126" ,
161
+ },
162
+ },
163
+ },
164
+ Results : types.Results {
165
+ {
166
+ Vulnerabilities : []types.DetectedVulnerability {
167
+ {
168
+ VulnerabilityID : "CVE-2022-2222" ,
169
+ Vulnerability : dbTypes.Vulnerability {Severity : "MEDIUM" },
170
+ },
171
+ },
172
+ },
173
+ },
174
+ }
175
+
176
+ multiImagePodWithVulns = Resource {
177
+ Namespace : "default" ,
178
+ Kind : "Pod" ,
179
+ Name : "multi-image-pod" ,
180
+ Metadata : []types.Metadata {
181
+ {
182
+ ImageID : "image1" ,
183
+ RepoTags : []string {
184
+ "alpine:3.14" ,
185
+ },
186
+ RepoDigests : []string {
187
+ "alpine:3.14@sha256:8fe1727132b2506c17ba0e1f6a6ed8a016bb1f5735e43b2738cd3fd1979b6260" ,
188
+ },
189
+ },
190
+ {
191
+ ImageID : "image2" ,
192
+ RepoTags : []string {
193
+ "alpine:3.17.3" ,
194
+ },
195
+ RepoDigests : []string {
196
+ "alpine@sha256:124c7d2707904eea7431fffe91522a01e5a861a624ee31d03372cc1d138a3126" ,
197
+ },
198
+ },
199
+ },
200
+ Results : types.Results {
201
+ {
202
+ Vulnerabilities : []types.DetectedVulnerability {
203
+ {
204
+ VulnerabilityID : "CVE-2022-1111" ,
205
+ Vulnerability : dbTypes.Vulnerability {Severity : "LOW" },
206
+ },
207
+ },
208
+ },
209
+ {
210
+ Vulnerabilities : []types.DetectedVulnerability {
211
+ {
212
+ VulnerabilityID : "CVE-2022-2222" ,
213
+ Vulnerability : dbTypes.Vulnerability {Severity : "MEDIUM" },
214
+ },
215
+ },
216
+ },
217
+ },
218
+ }
219
+
116
220
deployOrionWithBothVulnsAndMisconfigs = Resource {
117
221
Namespace : "default" ,
118
222
Kind : "Deploy" ,
119
223
Name : "orion" ,
120
- Metadata : types.Metadata {
121
- RepoTags : []string {
122
- "alpine:3.14" ,
123
- },
124
- RepoDigests : []string {
125
- "alpine:3.14@sha256:8fe1727132b2506c17ba0e1f6a6ed8a016bb1f5735e43b2738cd3fd1979b6260" ,
224
+ Metadata : []types.Metadata {
225
+ {
226
+ ImageID : "123" ,
227
+ RepoTags : []string {
228
+ "alpine:3.14" ,
229
+ },
230
+ RepoDigests : []string {
231
+ "alpine:3.14@sha256:8fe1727132b2506c17ba0e1f6a6ed8a016bb1f5735e43b2738cd3fd1979b6260" ,
232
+ },
126
233
},
127
234
},
128
235
Results : types.Results {
@@ -204,12 +311,15 @@ var (
204
311
Namespace : "default" ,
205
312
Kind : "Cronjob" ,
206
313
Name : "hello" ,
207
- Metadata : types.Metadata {
208
- RepoTags : []string {
209
- "alpine:3.14" ,
210
- },
211
- RepoDigests : []string {
212
- "alpine:3.14@sha256:8fe1727132b2506c17ba0e1f6a6ed8a016bb1f5735e43b2738cd3fd1979b6260" ,
314
+ Metadata : []types.Metadata {
315
+ {
316
+ ImageID : "123" ,
317
+ RepoTags : []string {
318
+ "alpine:3.14" ,
319
+ },
320
+ RepoDigests : []string {
321
+ "alpine:3.14@sha256:8fe1727132b2506c17ba0e1f6a6ed8a016bb1f5735e43b2738cd3fd1979b6260" ,
322
+ },
213
323
},
214
324
},
215
325
Results : types.Results {
@@ -221,12 +331,15 @@ var (
221
331
Namespace : "default" ,
222
332
Kind : "Pod" ,
223
333
Name : "prometheus" ,
224
- Metadata : types.Metadata {
225
- RepoTags : []string {
226
- "alpine:3.14" ,
227
- },
228
- RepoDigests : []string {
229
- "alpine:3.14@sha256:8fe1727132b2506c17ba0e1f6a6ed8a016bb1f5735e43b2738cd3fd1979b6260" ,
334
+ Metadata : []types.Metadata {
335
+ {
336
+ ImageID : "123" ,
337
+ RepoTags : []string {
338
+ "alpine:3.14" ,
339
+ },
340
+ RepoDigests : []string {
341
+ "alpine:3.14@sha256:8fe1727132b2506c17ba0e1f6a6ed8a016bb1f5735e43b2738cd3fd1979b6260" ,
342
+ },
230
343
},
231
344
},
232
345
Results : types.Results {
@@ -358,6 +471,18 @@ func TestReport_consolidate(t *testing.T) {
358
471
"default/cronjob/hello" : cronjobHelloWithVulns ,
359
472
},
360
473
},
474
+ {
475
+ name : "report with multi image pod containing vulnerabilities" ,
476
+ report : Report {
477
+ Resources : []Resource {
478
+ image1WithVulns ,
479
+ image2WithVulns ,
480
+ },
481
+ },
482
+ expectedFindings : map [string ]Resource {
483
+ "default/pod/multi-image-pod" : multiImagePodWithVulns ,
484
+ },
485
+ },
361
486
}
362
487
363
488
for _ , tt := range tests {
0 commit comments