Skip to content

Commit 4e41efd

Browse files
rushk014xingzhang-suse
authored andcommitted
feat(vulnerabilities): Add Vulnerabilities overview table based on mock data
1 parent 44575fd commit 4e41efd

File tree

5 files changed

+198
-7
lines changed

5 files changed

+198
-7
lines changed

pkg/sbombastic-image-vulnerability-scanner/config/table-headers.ts

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ export const IMAGE_LIST_TABLE = [
173173
labelKey: "imageScanner.images.listTable.headers.registry",
174174
value: "spec.registry",
175175
sort: "spec.registry",
176-
}
176+
},
177177
];
178178

179179
export const REPO_BASED_TABLE = [
@@ -230,3 +230,46 @@ export const REPO_BASED_IMAGE_LIST_TABLE = [
230230
width: 450,
231231
},
232232
];
233+
234+
export const VULNERABILITIES_TABLE = [
235+
{
236+
name: "cve",
237+
labelKey: "imageScanner.vulnerabilities.table.headers.cve",
238+
value: "cve",
239+
sort: "cve",
240+
width: 140,
241+
},
242+
{
243+
name: "score",
244+
labelKey: "imageScanner.vulnerabilities.table.headers.score",
245+
value: "scoreV3",
246+
formatter: "ScoreBadgeCell",
247+
sort: "severity",
248+
width: 100,
249+
},
250+
{
251+
name: "affectedImages",
252+
labelKey: "imageScanner.vulnerabilities.table.headers.affectedImages",
253+
value: "impactedImages",
254+
formatter: "ImpactedCell",
255+
formatterParams: { ticks: 23 },
256+
sort: "impactedImages",
257+
width: 200,
258+
},
259+
{
260+
name: "severity",
261+
labelKey: "imageScanner.vulnerabilities.table.headers.severity",
262+
value: "severity",
263+
sort: "severity",
264+
width: 120,
265+
},
266+
{
267+
name: "identifiedImages",
268+
labelKey: "imageScanner.vulnerabilities.table.headers.identifiedImages",
269+
value: "identifiedImages",
270+
formatter: "ImpactedCell",
271+
formatterParams: { ticks: 45 },
272+
sort: "identifiedImages",
273+
width: 300,
274+
},
275+
];
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<template>
2+
<div class="impacted-container">
3+
<div class="impacted">
4+
<span>{{ value }}</span>
5+
<BlockPercentageBarAlt
6+
:ticks="col.formatterParams?.ticks || 10"
7+
:percentage="(row.totalImages && value) ? (value / row.totalImages) * 100 : 0"
8+
/>
9+
</div>
10+
</div>
11+
</template>
12+
13+
<script>
14+
import BlockPercentageBarAlt from '@sbombastic-image-vulnerability-scanner/components/common/BlockPercentageBarAlt.vue';
15+
16+
export default {
17+
components: {
18+
BlockPercentageBarAlt
19+
},
20+
props: {
21+
value: {
22+
type: String,
23+
required: true
24+
},
25+
row: {
26+
type: Object,
27+
required: true
28+
},
29+
col: {
30+
type: Object,
31+
required: true
32+
}
33+
},
34+
computed: {
35+
vulnerability() {
36+
console.log('col', this.col);
37+
return this.value;
38+
}
39+
}
40+
};
41+
</script>
42+
43+
<style lang="scss" scoped>
44+
.impacted-container {
45+
display: flex;
46+
padding: 0 16px;
47+
align-items: center;
48+
justify-content: end;
49+
}
50+
51+
.impacted {
52+
display: flex;
53+
align-items: center;
54+
justify-content: end;
55+
gap: 16px;
56+
flex: 1 0 0;
57+
align-self: stretch;
58+
}
59+
</style>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<template>
2+
<ScoreBadge :score="value" scoreType="v3" />
3+
</template>
4+
5+
<script>
6+
import ScoreBadge from '@sbombastic-image-vulnerability-scanner/components/common/ScoreBadge.vue';
7+
8+
export default {
9+
components: {
10+
ScoreBadge
11+
},
12+
props: {
13+
value: {
14+
type: String,
15+
required: true
16+
}
17+
},
18+
};
19+
</script>

pkg/sbombastic-image-vulnerability-scanner/l10n/en-us.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,13 @@ imageScanner:
104104
severityDistribution:
105105
title: Severity distribution
106106
subTitle: vulnerabilities in total
107+
table:
108+
headers:
109+
cve: CVE ID
110+
score: Score
111+
affectedImages: Affected images
112+
severity: Severity
113+
identifiedImages: Images identified in
107114
vexManagement:
108115
title: VEX management
109116
description: Configure the security scanner to use up-to-date VEX reports. This will prioritize remediation efforts, focusing on vulnerabilities that are confirmed to be exploitable and reducing the noise coming from false positives.

pkg/sbombastic-image-vulnerability-scanner/pages/c/_cluster/sbombastic-image-vulnerability-scanner/Vulnerabilities.vue

Lines changed: 69 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,54 +11,112 @@
1111
<SeverityDistribution :chartData="severityDistribution" />
1212
</div>
1313
<div class="table">
14+
<SortableTable
15+
:has-advanced-filtering="false"
16+
:namespaced="false"
17+
:row-actions="false"
18+
:force-update-live-and-delayed="0"
19+
:use-query-params-for-simple-filtering="true"
20+
:rows="vulnerabilities"
21+
:headers="VULNERABILITIES_TABLE"
22+
/>
1423
</div>
1524
</div>
1625
</template>
1726

1827
<script>
28+
import SortableTable from '@shell/components/SortableTable';
1929
import SeverityDistribution from '@sbombastic-image-vulnerability-scanner/components/SeverityDistribution.vue';
2030
import TopSevereVulnerabilitiesChart from '@sbombastic-image-vulnerability-scanner/components/TopSevereVulnerabilitiesChart.vue';
31+
import { VULNERABILITIES_TABLE } from '@sbombastic-image-vulnerability-scanner/config/table-headers';
2132
2233
export default {
2334
name: 'vulnerabilities',
2435
components: {
2536
SeverityDistribution,
2637
TopSevereVulnerabilitiesChart,
38+
SortableTable,
2739
},
2840
data() {
2941
return {
42+
VULNERABILITIES_TABLE,
3043
severityDistribution: {
3144
critical: 120,
3245
high: 54,
3346
medium: 23,
3447
low: 65,
3548
none: 200,
3649
},
37-
topSevereVulnerabilities: [
50+
cves: [
3851
{
3952
cve: 'CVE-2017-5337',
4053
scoreV3: '9.9',
54+
identifiedImages: 106,
4155
impactedImages: 103,
56+
severity: 'Critical',
4257
},
4358
{
4459
cve: 'CVE-2017-5336',
4560
scoreV3: '9.6',
61+
identifiedImages: 234,
4662
impactedImages: 98,
63+
severity: 'Critical',
4764
},
4865
{
4966
cve: 'CVE-2017-5335',
5067
scoreV3: '8.8',
68+
identifiedImages: 321,
5169
impactedImages: 95,
70+
severity: 'High',
5271
},
5372
{
5473
cve: 'CVE-2017-5334',
5574
scoreV3: '8.6',
75+
identifiedImages: 450,
5676
impactedImages: 92,
77+
severity: 'High',
5778
},
5879
{
5980
cve: 'CVE-2017-5333',
6081
scoreV3: '8.5',
82+
identifiedImages: 300,
6183
impactedImages: 90,
84+
severity: 'High',
85+
},
86+
{
87+
cve: 'CVE-2017-5332',
88+
scoreV3: '7.5',
89+
identifiedImages: 250,
90+
impactedImages: 85,
91+
severity: 'Medium',
92+
},
93+
{
94+
cve: 'CVE-2017-5331',
95+
scoreV3: '7.2',
96+
identifiedImages: 200,
97+
impactedImages: 80,
98+
severity: 'Medium',
99+
},
100+
{
101+
cve: 'CVE-2017-5330',
102+
scoreV3: '6.8',
103+
identifiedImages: 150,
104+
impactedImages: 75,
105+
severity: 'Medium',
106+
},
107+
{
108+
cve: 'CVE-2017-5329',
109+
scoreV3: '5.5',
110+
identifiedImages: 100,
111+
impactedImages: 70,
112+
severity: 'Low',
113+
},
114+
{
115+
cve: 'CVE-2017-5328',
116+
scoreV3: '4.3',
117+
identifiedImages: 50,
118+
impactedImages: 65,
119+
severity: 'Low',
62120
},
63121
],
64122
};
@@ -67,6 +125,15 @@
67125
totalVulnerabilities() {
68126
return Object.values(this.severityDistribution).reduce((sum, value) => sum + value, 0);
69127
},
128+
vulnerabilities() {
129+
return this.cves.map(vul => ({
130+
...vul,
131+
totalImages: this.totalVulnerabilities
132+
}));
133+
},
134+
topSevereVulnerabilities() {
135+
return this.vulnerabilities.sort((a, b) => Number(b.scoreV3) - Number(a.scoreV3)).slice(0, 5);
136+
},
70137
},
71138
}
72139
</script>
@@ -100,10 +167,6 @@
100167
}
101168
102169
.table {
103-
display: flex;
104-
flex-direction: column;
105-
align-items: flex-start;
106-
gap: 24px;
107-
align-self: stretch;
170+
width: 100%;
108171
}
109172
</style>

0 commit comments

Comments
 (0)