diff --git a/pkg/sbombastic-image-vulnerability-scanner/components/common/BarChart.vue b/pkg/sbombastic-image-vulnerability-scanner/components/common/BarChart.vue index f0ed57b..c5530d7 100644 --- a/pkg/sbombastic-image-vulnerability-scanner/components/common/BarChart.vue +++ b/pkg/sbombastic-image-vulnerability-scanner/components/common/BarChart.vue @@ -6,8 +6,8 @@
-
{{ t(`imageScanner.enum.${ colorPrefix }.${ key }`) }}
- +
{{ t(`imageScanner.enum.${ colorPrefix }.${ key.toLowerCase() }`) }}
+
{{ value }}
@@ -38,7 +38,7 @@ export default { }, methods: { percentage(value) { - return (value / this.total) * 100; + return this.total > 0 ? (value / this.total) * 100 : 0; } }, computed: { @@ -128,8 +128,8 @@ export default { --status-pending: #DCDEE7; --status-scheduled: #0FCFF0; - --status-in_progress: #3D98D3; - --status-completed: #5BB04F; + --status-inprogress: #3D98D3; + --status-complete: #5BB04F; --status-failed: #DE2136; } \ No newline at end of file diff --git a/pkg/sbombastic-image-vulnerability-scanner/components/common/RegisterStatusBadge.vue b/pkg/sbombastic-image-vulnerability-scanner/components/common/RegisterStatusBadge.vue index 2f5fcbf..0cdcc0e 100644 --- a/pkg/sbombastic-image-vulnerability-scanner/components/common/RegisterStatusBadge.vue +++ b/pkg/sbombastic-image-vulnerability-scanner/components/common/RegisterStatusBadge.vue @@ -22,10 +22,10 @@ return "pending"; case REGISTRY_STATUS.SCHEDULED: return "scheduled"; - case REGISTRY_STATUS.IN_PPROGRESS: + case REGISTRY_STATUS.IN_PROGRESS: return "in-progress"; - case REGISTRY_STATUS.COMPLETED: - return "completed"; + case REGISTRY_STATUS.COMPLETE: + return "complete"; case REGISTRY_STATUS.FAILED: return "failed"; default: @@ -60,7 +60,7 @@ color: #1C577D; } - &.completed { + &.complete { background: #DEEFDC; color: #376930; } diff --git a/pkg/sbombastic-image-vulnerability-scanner/components/common/RegistryStatusUpdate.vue b/pkg/sbombastic-image-vulnerability-scanner/components/common/RegistryStatusUpdate.vue index 25be85a..5e49238 100644 --- a/pkg/sbombastic-image-vulnerability-scanner/components/common/RegistryStatusUpdate.vue +++ b/pkg/sbombastic-image-vulnerability-scanner/components/common/RegistryStatusUpdate.vue @@ -1,17 +1,24 @@ diff --git a/pkg/sbombastic-image-vulnerability-scanner/formatters/ProgressCell.vue b/pkg/sbombastic-image-vulnerability-scanner/formatters/ProgressCell.vue new file mode 100644 index 0000000..16b9d26 --- /dev/null +++ b/pkg/sbombastic-image-vulnerability-scanner/formatters/ProgressCell.vue @@ -0,0 +1,28 @@ + + + \ No newline at end of file diff --git a/pkg/sbombastic-image-vulnerability-scanner/formatters/RegistryStatusCellBadge.vue b/pkg/sbombastic-image-vulnerability-scanner/formatters/RegistryStatusCellBadge.vue index 743229a..cb1c1c2 100644 --- a/pkg/sbombastic-image-vulnerability-scanner/formatters/RegistryStatusCellBadge.vue +++ b/pkg/sbombastic-image-vulnerability-scanner/formatters/RegistryStatusCellBadge.vue @@ -14,5 +14,5 @@ export default { diff --git a/pkg/sbombastic-image-vulnerability-scanner/formatters/ScanNameCell.vue b/pkg/sbombastic-image-vulnerability-scanner/formatters/ScanNameCell.vue new file mode 100644 index 0000000..58fe7f6 --- /dev/null +++ b/pkg/sbombastic-image-vulnerability-scanner/formatters/ScanNameCell.vue @@ -0,0 +1,25 @@ + + \ No newline at end of file diff --git a/pkg/sbombastic-image-vulnerability-scanner/l10n/en-us.yaml b/pkg/sbombastic-image-vulnerability-scanner/l10n/en-us.yaml index 8be6b3d..d98504c 100644 --- a/pkg/sbombastic-image-vulnerability-scanner/l10n/en-us.yaml +++ b/pkg/sbombastic-image-vulnerability-scanner/l10n/en-us.yaml @@ -11,13 +11,13 @@ imageScanner: subTitle: registry scans registrytable: header: - scan: scan + scan: Scan registry: Registry - namespace: namespace - repos: repositories + namespace: Namespace + repos: Repositories schedule: Scheduled status: Status - progress: progress + progress: Progress prevScan: Previous scan configuration: scan: Start Scan @@ -55,11 +55,17 @@ imageScanner: low: Low none: None status: - pending: pending + pending: Pending scheduled: Scheduled - in_progress: In progress - completed: completed + inprogress: In progress + complete: Complete failed: Failed + prevScan: + none: n/a + scheduled: Scheduled + inprogress: In progress + complete: Finished at + failed: Failed at general: refresh: Refresh data ago: ago diff --git a/pkg/sbombastic-image-vulnerability-scanner/pages/c/_cluster/sbombastic-image-vulnerability-scanner/Registries.vue b/pkg/sbombastic-image-vulnerability-scanner/pages/c/_cluster/sbombastic-image-vulnerability-scanner/Registries.vue index eef1e0c..e3c6fae 100644 --- a/pkg/sbombastic-image-vulnerability-scanner/pages/c/_cluster/sbombastic-image-vulnerability-scanner/Registries.vue +++ b/pkg/sbombastic-image-vulnerability-scanner/pages/c/_cluster/sbombastic-image-vulnerability-scanner/Registries.vue @@ -14,7 +14,6 @@ class="btn role-secondary" aria-label="Refresh data" type="button" - :disabled="disabled" @click="refresh()"> {{ t('imageScanner.registries.button.refresh') }} @@ -25,7 +24,6 @@ class="btn role-primary" aria-label="Add new" type="button" - :disabled="disabled" @click="openAddEditRegistry()"> {{ t('imageScanner.registries.button.addNew') }} @@ -40,14 +38,11 @@ :schema="schema" :rows="rows" :namespaced="false" + :groupable="false" + :hasAdvancedFiltering="true" :headers="headers" :use-query-params-for-simple-filtering="true" /> -

- - {{ row.id }} - -

@@ -74,49 +69,14 @@ return { content: ref("Registries"), PRODUCT_NAME: PRODUCT_NAME, - registryStatusList: [ - { - scan_name: "prod repo", - registry_name: "https://registry.hub.com", - prev_status: "in_progress", - curr_status: "completed", - last_update_time: 1752491022 - }, - { - scan_name: "cfl-ctf", - registry_name: "https://registry.docker.com", - prev_status: "pending", - curr_status: "in_progress", - last_update_time: 1752735822 - }, - { - scan_name: "fed.kubewarden", - registry_name: "https://registry.hub.docker.com", - prev_status: "in_progress", - curr_status: "failed", - last_update_time: 1752840334 - }, - { - scan_name: "fed.onlinebutique", - registry_name: "https://registry.hub.com", - prev_status: "in_progress", - curr_status: "scheduled", - last_update_time: 1750262909 - }, - { - scan_name: "sys reg", - registry_name: "https://reg.docker..com", - prev_status: "scheduled", - curr_status: "in_progress", - last_update_time: 1745525244 - }, - ], + rows: [], + registryStatusList: [], statusSummary: { - pending: 39, - scheduled: 8, - in_progress: 46, - completed: 187, - failed: 35 + scheduled: 0, + pending: 0, + inprogress: 0, + complete: 0, + failed: 0 }, headers: REGISTRY_SCAN_TABLE, } @@ -124,55 +84,63 @@ async fetch() { await this.$store.dispatch('cluster/findAll', { type: RESOURCE.REGISTRY }); + let registriesCRD = this.$store.getters['cluster/all'](RESOURCE.REGISTRY); + + let registryMap = {}; + registriesCRD.forEach((rec) => { + rec.status.conditions[0].type = rec.status.conditions[0].type.toLowerCase() === "discovering" ? "InProgress" : rec.status.conditions[0].type; + registryMap[rec.id] = rec; + }); + if (this.$store.getters['cluster/canList'](RESOURCE.SCAN_JOB)) { - this.$store.dispatch('cluster/findAll', { type: RESOURCE.SCAN_JOB }); + await this.$store.dispatch('cluster/findAll', { type: RESOURCE.SCAN_JOB }); + } + + let scanJobCRD = this.$store.getters['cluster/all'](RESOURCE.SCAN_JOB); + + this.rows = scanJobCRD.map((rec) => { + const key = `${rec.metadata.namespace}/${rec.spec.registry}`; + const reg = registryMap[key]; + + if (rec.spec && rec.spec.registry && reg) { + rec.registry = reg; + const status = rec.status.conditions?.[0]?.type?.toLowerCase(); + const prevStatus = rec.status.conditions?.[1]?.type?.toLowerCase(); + this.registryStatusList.push({ + scan_name: rec.metadata.name, + registry_name: reg.id, + namespace: rec.metadata.namespace, + prev_status: prevStatus, + curr_status: status, + last_update_time: rec.status.conditions?.[0]?.lastUpdateTime + }); + + if (status && this.statusSummary.hasOwnProperty(status)) { + this.statusSummary[status]++; + } + } + return rec; + }); + + this.registryStatusList.sort((a, b) => new Date(b.last_update_time) - new Date(a.last_update_time)).slice(0, 5) + while (this.registryStatusList.length < 5) { + this.registryStatusList.push({ + scan_name: "", + registry_name: "", + prev_status: "", + curr_status: "", + last_update_time: new Date().toISOString() + }); } }, methods: { refresh() {}, - openAddEditRegistry() {} + openAddEditRegistry() {}, }, computed: { - rows() { - let registriesCRD = this.$store.getters['cluster/all'](RESOURCE.REGISTRY); - //Make mock data for UI test - registriesCRD = registriesCRD.map((rec, index) => { - if (index === 0) { - rec.schedule = 3; - rec._status = "failed"; - rec.errors = [ - { - message: "Not enough resources to complete the scan. Could not connect to proxyu", - }, - ]; - rec.progress = 35; - rec.previous = { - _status: "scheduled", - errors: [], - progress: 0 - }; - } else { - rec.schedule = 29; - rec._status = "completed"; - rec.errors = []; - rec.progress = 100; - rec.previous = { - _status: "Failed", - errors: [ - { - message: "Not enough resources to complete the scan. Could not connect to proxyu", - }, - ], - progress: 49 - }; - } - return rec; - }); - return registriesCRD; - }, schema() { - return this.$store.getters['cluster/schemaFor'](RESOURCE.REGISTRY); - } + return this.$store.getters['cluster/schemaFor'](RESOURCE.SCAN_JOB); + }, } } diff --git a/pkg/sbombastic-image-vulnerability-scanner/types/registry.ts b/pkg/sbombastic-image-vulnerability-scanner/types/registry.ts index c87654e..cab4170 100644 --- a/pkg/sbombastic-image-vulnerability-scanner/types/registry.ts +++ b/pkg/sbombastic-image-vulnerability-scanner/types/registry.ts @@ -1,7 +1,7 @@ export const REGISTRY_STATUS = { PENDING: "pending", SCHEDULED: "scheduled", - IN_PPROGRESS: "in_progress", - COMPLETED: "completed", + IN_PROGRESS: "inprogress", + COMPLETE: "complete", FAILED: "failed", }; \ No newline at end of file