diff --git a/operators/constellation-node-operator/internal/cloud/gcp/client/disks.go b/operators/constellation-node-operator/internal/cloud/gcp/client/disks.go index a8d244c20e..862de3f153 100644 --- a/operators/constellation-node-operator/internal/cloud/gcp/client/disks.go +++ b/operators/constellation-node-operator/internal/cloud/gcp/client/disks.go @@ -14,8 +14,8 @@ import ( ) var ( - diskSourceRegex = regexp.MustCompile(`^https://www.googleapis.com/compute/v1/projects/([^/]+)/zones/([^/]+)/disks/([^/]+)$`) - computeAPIBase = regexp.MustCompile(`^https://www.googleapis.com/compute/v1/(.+)$`) + diskSourceRegex = regexp.MustCompile(`^https://www\.googleapis\.com/compute/v1/projects/([^/]+)/zones/([^/]+)/disks/([^/]+)$`) + computeAPIBase = regexp.MustCompile(`^https://www\.googleapis\.com/compute/v1/(.+)$`) ) // diskSourceToDiskReq converts a disk source URI to a disk request. diff --git a/operators/constellation-node-operator/internal/cloud/gcp/client/disks_test.go b/operators/constellation-node-operator/internal/cloud/gcp/client/disks_test.go index f92ea8f633..fd2d6e8be4 100644 --- a/operators/constellation-node-operator/internal/cloud/gcp/client/disks_test.go +++ b/operators/constellation-node-operator/internal/cloud/gcp/client/disks_test.go @@ -36,6 +36,10 @@ func TestDiskSourceToDiskReq(t *testing.T) { diskSource: "invalid://www.googleapis.com/compute/v1/projects/project/zones/zone/disks/disk", wantErr: true, }, + "url dots in regex are escaped": { + diskSource: "https://wwwAgoogleapisAcom/compute/v1/projects/project/zones/zone/disks/disk", + wantErr: true, + }, } for name, tc := range testCases { @@ -67,6 +71,10 @@ func TestURINormalize(t *testing.T) { imageURI: "projects/project/global/images/image", wantNormalized: "projects/project/global/images/image", }, + "url dots in regex are escaped": { + imageURI: "https://wwwAgoogleapisAcom/compute/v1/projects/project/global/images/image", + wantNormalized: "https://wwwAgoogleapisAcom/compute/v1/projects/project/global/images/image", + }, } for name, tc := range testCases {