Skip to content
This repository was archived by the owner on Feb 16, 2023. It is now read-only.

Commit e5600ec

Browse files
Verify components in GCP keyring and key are at least one char long
Co-authored-by: Joris Coenen <jpcoenen@users.noreply.github.com>
1 parent 0163ea0 commit e5600ec

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

internals/secrethub/service_gcp_init.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,14 +305,14 @@ func (l *gcpKMSKeyOptionLister) KeyringOptions() ([]ui.Option, bool, error) {
305305
}
306306

307307
func validateGCPKeyring(keyring string) error {
308-
if !regexp.MustCompile("^projects/[a-zA-Z0-9-]*/locations/[a-zA-Z0-9-]*/keyRings/[a-zA-Z0-9-_]*$").MatchString(keyring) {
308+
if !regexp.MustCompile("^projects/[a-zA-Z0-9-]+/locations/[a-zA-Z0-9-]+/keyRings/[a-zA-Z0-9-_]+$").MatchString(keyring) {
309309
return errors.New("GCP keyring should be in the form \"projects/<project-id>/locations/<location>/keyRings/<key-ring>\"")
310310
}
311311
return nil
312312
}
313313

314314
func validateGCPCryptoKey(cryptoKey string) error {
315-
if !regexp.MustCompile("^projects/[a-zA-Z0-9-]*/locations/[a-zA-Z0-9-]*/keyRings/[a-zA-Z0-9-_]*/cryptoKeys/[a-zA-Z0-9-_]*$").MatchString(cryptoKey) {
315+
if !regexp.MustCompile("^projects/[a-zA-Z0-9-]+/locations/[a-zA-Z0-9-]+/keyRings/[a-zA-Z0-9-_]+/cryptoKeys/[a-zA-Z0-9-_]+$").MatchString(cryptoKey) {
316316
return errors.New("GCP crypto key should be in the form \"projects/<project-id>/locations/<location>/keyRings/<key-ring>/cryptoKeys/<key>\"")
317317
}
318318
return nil

0 commit comments

Comments
 (0)