Skip to content

Commit

Permalink
Added check that azure secret contains valid GUIDs, see https://githu…
Browse files Browse the repository at this point in the history
  • Loading branch information
grolu committed Sep 18, 2024
1 parent daed519 commit 1ba3faf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion frontend/src/components/Secrets/GSecretDialogAzure.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
}),
}
},
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/utils/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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)
Expand Down Expand Up @@ -111,4 +113,5 @@ export {
includesIfAvailable,
numberOrPercentage,
isTimezone,
guid,
}

0 comments on commit 1ba3faf

Please sign in to comment.