@@ -118,6 +118,58 @@ var (
118
118
},
119
119
},
120
120
}
121
+ deployOrionWithThirdVulns = Resource {
122
+ Namespace : "default" ,
123
+ Kind : "Deploy" ,
124
+ Name : "orion" ,
125
+ Metadata : []types.Metadata {
126
+ {
127
+ ImageID : "123" ,
128
+ RepoTags : []string {
129
+ "alpine:3.14" ,
130
+ },
131
+ RepoDigests : []string {
132
+ "alpine:3.14@sha256:8fe1727132b2506c17ba0e1f6a6ed8a016bb1f5735e43b2738cd3fd1979b6260" ,
133
+ },
134
+ },
135
+ },
136
+ Results : types.Results {
137
+ {},
138
+ {},
139
+ {
140
+ Vulnerabilities : []types.DetectedVulnerability {
141
+ {
142
+ VulnerabilityID : "CVE-2022-1111" ,
143
+ Vulnerability : dbTypes.Vulnerability {Severity : "LOW" },
144
+ },
145
+ {
146
+ VulnerabilityID : "CVE-2022-2222" ,
147
+ Vulnerability : dbTypes.Vulnerability {Severity : "MEDIUM" },
148
+ },
149
+ {
150
+ VulnerabilityID : "CVE-2022-3333" ,
151
+ Vulnerability : dbTypes.Vulnerability {Severity : "HIGH" },
152
+ },
153
+ {
154
+ VulnerabilityID : "CVE-2022-4444" ,
155
+ Vulnerability : dbTypes.Vulnerability {Severity : "CRITICAL" },
156
+ },
157
+ {
158
+ VulnerabilityID : "CVE-2022-5555" ,
159
+ Vulnerability : dbTypes.Vulnerability {Severity : "UNKNOWN" },
160
+ },
161
+ {
162
+ VulnerabilityID : "CVE-2022-6666" ,
163
+ Vulnerability : dbTypes.Vulnerability {Severity : "CRITICAL" },
164
+ },
165
+ {
166
+ VulnerabilityID : "CVE-2022-7777" ,
167
+ Vulnerability : dbTypes.Vulnerability {Severity : "MEDIUM" },
168
+ },
169
+ },
170
+ },
171
+ },
172
+ }
121
173
122
174
orionDeployWithAnotherMisconfig = Resource {
123
175
Namespace : "default" ,
@@ -492,6 +544,17 @@ func TestReport_consolidate(t *testing.T) {
492
544
"default/cronjob/hello" : cronjobHelloWithVulns ,
493
545
},
494
546
},
547
+ {
548
+ name : "report with vulnerabilities in the third result" ,
549
+ report : Report {
550
+ Resources : []Resource {
551
+ deployOrionWithThirdVulns ,
552
+ },
553
+ },
554
+ expectedFindings : map [string ]Resource {
555
+ "default/deploy/orion" : deployOrionWithThirdVulns ,
556
+ },
557
+ },
495
558
{
496
559
name : "report with misconfigs in image and pod" ,
497
560
report : Report {
@@ -521,6 +584,11 @@ func TestReport_consolidate(t *testing.T) {
521
584
for _ , tt := range tests {
522
585
t .Run (tt .name , func (t * testing.T ) {
523
586
consolidateReport := tt .report .consolidate ()
587
+
588
+ if len (consolidateReport .Findings ) != len (tt .expectedFindings ) {
589
+ t .Errorf ("expected %d findings, got %d" , len (tt .expectedFindings ), len (consolidateReport .Findings ))
590
+ }
591
+
524
592
for _ , f := range consolidateReport .Findings {
525
593
key := f .fullname ()
526
594
0 commit comments