diff --git a/pkg/sbombastic-image-vulnerability-scanner/constants/scan-interval-options.ts b/pkg/sbombastic-image-vulnerability-scanner/constants/scan-interval-options.ts new file mode 100644 index 0000000..0e50839 --- /dev/null +++ b/pkg/sbombastic-image-vulnerability-scanner/constants/scan-interval-options.ts @@ -0,0 +1,17 @@ +import { + RegistryTypeOptions, + ScanIntervalOptions +} from '@sbombastic-image-vulnerability-scanner/types/sbombastic-image-vulnerability-scanner'; + +export const SCAN_INTERVAL_OPTIONS: { label: string; value: ScanIntervalOptions }[] = [ + { label: 'Every 1 hour', value: '1h' }, + { label: 'Every 3 hours', value: '3h' }, + { label: 'Every 6 hours', value: '6h' }, + { label: 'Every 12 hours', value: '12h' }, + { label: 'Every 24 hours', value: '24h' }, + { label: 'Manual Scan', value: '0s' } // backend disables auto-scan +]; + +export const REGISTRY_TYPE_OPTIONS: {label: string; value: RegistryTypeOptions }[] = [ + { label: 'Docker Hub', value: 'dockerhub'} +]; diff --git a/pkg/sbombastic-image-vulnerability-scanner/edit/sbombastic.rancher.io.registry.vue b/pkg/sbombastic-image-vulnerability-scanner/edit/sbombastic.rancher.io.registry.vue index 67f8e95..7a4a5c3 100644 --- a/pkg/sbombastic-image-vulnerability-scanner/edit/sbombastic.rancher.io.registry.vue +++ b/pkg/sbombastic-image-vulnerability-scanner/edit/sbombastic.rancher.io.registry.vue @@ -9,9 +9,12 @@ import SelectOrCreateAuthSecret from '@shell/components/form/SelectOrCreateAuthS import LabeledSelect from '@shell/components/form/LabeledSelect'; import Banner from '@components/Banner/Banner.vue'; import { Checkbox } from '@components/Form/Checkbox'; -import { MANAGEMENT, NAMESPACE, CLUSTER_REPO_TYPES } from '@shell/config/types'; +import { MANAGEMENT, NAMESPACE } from '@shell/config/types'; import UnitInput from '@shell/components/form/UnitInput.vue'; -import {ref} from "vue"; +import { + REGISTRY_TYPE_OPTIONS, + SCAN_INTERVAL_OPTIONS +} from "@sbombastic-image-vulnerability-scanner/constants/scan-interval-options"; export default { name: 'CruRegistry', @@ -32,7 +35,6 @@ export default { mixins: [CreateEditView], data() { - if (!this.value.spec) { this.value.spec = { insecure: true, @@ -49,8 +51,6 @@ export default { }; } - console.log('this.value after:',this.value); - return { selectedRegistryType: this.value.type || 'ecr', secretNamespace: this.$store.getters['defaultNamespace'], @@ -60,19 +60,6 @@ export default { }, computed: { - registryTypeOptions(){ - return [ - { - label: this.t('imageScanner.registries.configuration.cru.registry.type.ecr'), - value: 'ecr', - }, - { - label: this.t('imageScanner.registries.configuration.cru.registry.type.azure'), - value: 'azure', - }, - ]; - }, - namespace(){ console.log('this.value.spec.type:',this.value.spec.type); return this.value.spec.type === 'ecr'?"kube-system":"" @@ -93,6 +80,14 @@ export default { return this.$store.getters[`${ this.inStore }/all`](NAMESPACE)[0]?.id; }, + SCAN_INTERVAL_OPTIONS: function() { + return SCAN_INTERVAL_OPTIONS; + }, + + REGISTRY_TYPE_OPTIONS: function() { + return REGISTRY_TYPE_OPTIONS; + }, + useProxy: { get() { return !this.value.spec.insecure; @@ -111,103 +106,102 @@ export default { {{t('imageScanner.registries.configuration.cru.description')}} - - -
- {{ t('imageScanner.registries.configuration.cru.registry.label') }} -
- -
-
- -
-
- -
-
- - - -
-
- {{ t('imageScanner.registries.configuration.cru.authLabel') }} -
- + -
- {{ t('imageScanner.registries.configuration.cru.scan.label') }} +
+ {{ t('imageScanner.registries.configuration.cru.registry.label') }}
- + data-testid="registry-type-select" + :label="t('imageScanner.registries.configuration.cru.registry.type.label')" + :options="REGISTRY_TYPE_OPTIONS" + option-key="value" + option-label="label" + value="dockerhub" + required + />
-
- +
-
+ + +
+
+ {{ t('imageScanner.registries.configuration.cru.authLabel') }} +
+ + +
+ {{ t('imageScanner.registries.configuration.cru.scan.label') }} +
+ +
+
+ + +
+
+ +
+
+ +
- +
diff --git a/pkg/sbombastic-image-vulnerability-scanner/l10n/en-us.yaml b/pkg/sbombastic-image-vulnerability-scanner/l10n/en-us.yaml index 8aa067b..d6e399c 100644 --- a/pkg/sbombastic-image-vulnerability-scanner/l10n/en-us.yaml +++ b/pkg/sbombastic-image-vulnerability-scanner/l10n/en-us.yaml @@ -1,5 +1,5 @@ product: - imageScanner: Image Vulnerability Scanner + imageScanner: Image Vulnerability Scanner imageScanner: registries: title: Registries configuration @@ -30,13 +30,12 @@ imageScanner: label: Registry type: label: Type - ecr: Amazon ECR Registry - azure: Azure Container Registry + ecr: Docker Hub Registry custom: Custom Registry placeholder: Choose a registry type - namespace: - label: Namespace - placeholder: "Choose the registry first" + uri: + label: URI + placeholder: "The registry address URI" proxy: enable: Use the embedded proxy tooltip: "When enabled, Rancher routes all registry traffic through its secure proxy instead of direct connections." @@ -45,8 +44,7 @@ imageScanner: label: Scanning type: Repositories to scan schedule: - label: Refresh Interval - placeholder: 'default: {hours}' + label: Scan Interval scan: Start Scan meta: registry: Registry diff --git a/pkg/sbombastic-image-vulnerability-scanner/types/sbombastic-image-vulnerability-scanner.ts b/pkg/sbombastic-image-vulnerability-scanner/types/sbombastic-image-vulnerability-scanner.ts index 35abba8..51cc3aa 100644 --- a/pkg/sbombastic-image-vulnerability-scanner/types/sbombastic-image-vulnerability-scanner.ts +++ b/pkg/sbombastic-image-vulnerability-scanner/types/sbombastic-image-vulnerability-scanner.ts @@ -17,3 +17,7 @@ export interface MetadataProperty { value?: string; tags?: string[]; } + +export type ScanIntervalOptions = "1h" | "3h" | "6h" | "12h" | "24h" | "0s"; + +export type RegistryTypeOptions = "dockerhub" | "custom"; \ No newline at end of file