From 01ef659cff72013d90fc2834810c8dde5bd910f2 Mon Sep 17 00:00:00 2001 From: Dana Hoffman Date: Mon, 20 May 2019 16:04:39 -0700 Subject: [PATCH] Increase IAM custom role length validation to match API. (#1792) Merged PR #1792. --- build/terraform | 2 +- build/terraform-beta | 2 +- build/terraform-mapper | 2 +- third_party/terraform/utils/validation.go | 2 +- third_party/terraform/utils/validation_test.go | 11 ++++++----- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/build/terraform b/build/terraform index 57e36ef7b575..c5bbdce38eb1 160000 --- a/build/terraform +++ b/build/terraform @@ -1 +1 @@ -Subproject commit 57e36ef7b575653699b57b9a343346cfe84d9733 +Subproject commit c5bbdce38eb1a971c95691ee3d9f26efca1d595e diff --git a/build/terraform-beta b/build/terraform-beta index 2a3933ca174f..ab3f8a88fbfa 160000 --- a/build/terraform-beta +++ b/build/terraform-beta @@ -1 +1 @@ -Subproject commit 2a3933ca174ffb917840fabe7049c102d355f898 +Subproject commit ab3f8a88fbfa0ac25e5592b5a3972dd8f2918509 diff --git a/build/terraform-mapper b/build/terraform-mapper index 30d4358dc839..6b42deda02c7 160000 --- a/build/terraform-mapper +++ b/build/terraform-mapper @@ -1 +1 @@ -Subproject commit 30d4358dc8396b12218a2b2a3a978e2a6636e583 +Subproject commit 6b42deda02c70a538a9fb891361a8a1ee02d16df diff --git a/third_party/terraform/utils/validation.go b/third_party/terraform/utils/validation.go index 2ce56d2edee4..f176796157d5 100644 --- a/third_party/terraform/utils/validation.go +++ b/third_party/terraform/utils/validation.go @@ -29,7 +29,7 @@ const ( ComputeServiceAccountNameRegex = "[0-9]{1,20}-compute@developer.gserviceaccount.com" // https://cloud.google.com/iam/docs/understanding-custom-roles#naming_the_role - IAMCustomRoleIDRegex = "^[a-zA-Z0-9_\\.\\-]{1,30}$" + IAMCustomRoleIDRegex = "^[a-zA-Z0-9_\\.]{3,64}$" ) var ( diff --git a/third_party/terraform/utils/validation_test.go b/third_party/terraform/utils/validation_test.go index e1373fdbff19..59195e7503f0 100644 --- a/third_party/terraform/utils/validation_test.go +++ b/third_party/terraform/utils/validation_test.go @@ -324,19 +324,20 @@ func TestValidateIAMCustomRoleIDRegex(t *testing.T) { {TestName: "basic", Value: "foobar"}, {TestName: "with numbers", Value: "foobar123"}, {TestName: "with capipals", Value: "FooBar"}, - {TestName: "short", Value: "f"}, - {TestName: "long", Value: "foobarfoobarfoobarfoobarfoobar"}, - {TestName: "has a hyphen", Value: "foo-bar"}, + {TestName: "short", Value: "foo"}, + {TestName: "long", Value: strings.Repeat("f", 64)}, {TestName: "has a dot", Value: "foo.bar"}, {TestName: "has an underscore", Value: "foo_bar"}, - {TestName: "all of the above", Value: "foo.Bar-Baz_123"}, + {TestName: "all of the above", Value: "foo.BarBaz_123"}, // With errors {TestName: "empty", Value: "", ExpectError: true}, {TestName: "has an slash", Value: "foo/bar", ExpectError: true}, + {TestName: "has a hyphen", Value: "foo-bar", ExpectError: true}, {TestName: "has a dollar", Value: "foo$", ExpectError: true}, {TestName: "has a space", Value: "foo bar", ExpectError: true}, - {TestName: "too long", Value: strings.Repeat("f", 31), ExpectError: true}, + {TestName: "too short", Value: "fo", ExpectError: true}, + {TestName: "too long", Value: strings.Repeat("f", 65), ExpectError: true}, } es := testStringValidationCases(x, validateIAMCustomRoleID)