From 1ba3faffbc2c170f69cde7149b3a16965fb8ddf5 Mon Sep 17 00:00:00 2001 From: "Gross, Lukas" Date: Wed, 18 Sep 2024 10:26:29 +0200 Subject: [PATCH] Added check that azure secret contains valid GUIDs, see https://github.com/gardener/gardener-extension-provider-azure/blob/master/pkg/apis/azure/validation/secrets.go#L19 --- frontend/src/components/Secrets/GSecretDialogAzure.vue | 8 +++++++- frontend/src/utils/validators.js | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/Secrets/GSecretDialogAzure.vue b/frontend/src/components/Secrets/GSecretDialogAzure.vue index 4d0d589beb..6caf37a95a 100644 --- a/frontend/src/components/Secrets/GSecretDialogAzure.vue +++ b/frontend/src/components/Secrets/GSecretDialogAzure.vue @@ -115,7 +115,10 @@ import { required } from '@vuelidate/validators' import GSecretDialog from '@/components/Secrets/GSecretDialog' import GExternalLink from '@/components/GExternalLink' -import { withFieldName } from '@/utils/validators' +import { + withFieldName, + guid, +} from '@/utils/validators' import { getErrorMessages } from '@/utils' export default { @@ -157,15 +160,18 @@ export default { return { clientId: withFieldName('Client ID', { required, + guid, }), clientSecret: withFieldName('Client Secret', { required, }), tenantId: withFieldName('Tenant ID', { required, + guid, }), subscriptionId: withFieldName('Subscription ID', { required, + guid, }), } }, diff --git a/frontend/src/utils/validators.js b/frontend/src/utils/validators.js index 2413ee2011..8d13712074 100644 --- a/frontend/src/utils/validators.js +++ b/frontend/src/utils/validators.js @@ -17,6 +17,7 @@ const lowerCaseAlphaNumHyphenPattern = /^[-a-z0-9]*$/ const consecutiveHyphenPattern = /.?-{2,}.?/ const startEndHyphenPattern = /^-.*.|.*-$/ const numberOrPercentagePattern = /^[\d]+[%]?$/ +const guidPattern = /^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$/ export const timezonePattern = /^([+-])(\d{2}):(\d{2})$/ const base64 = withMessage('Must be a valid base64 string', regex(base64Pattern)) @@ -31,6 +32,7 @@ const noStartEndHyphen = withMessage('Must not start or end with a hyphen', valu const numberOrPercentage = withMessage('Must be a number or percentage', value => { return numberOrPercentagePattern.test(value) }) +const guid = withMessage('Must be a valid GUID', regex(guidPattern)) const isTimezone = withMessage('TimeZone must have format [+|-]HH:mm', value => { return timezonePattern.test(value) @@ -111,4 +113,5 @@ export { includesIfAvailable, numberOrPercentage, isTimezone, + guid, }