From 2fa44cb18b8338d7fa4f749bb798d6cbb3d9ba0c Mon Sep 17 00:00:00 2001 From: Dong Liu Date: Tue, 9 Aug 2022 01:37:45 +0800 Subject: [PATCH] Fix validation in resource id parsing (#704) Co-authored-by: Joel Hendrix --- autorest/azure/azure.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autorest/azure/azure.go b/autorest/azure/azure.go index 1328f1764..868345db6 100644 --- a/autorest/azure/azure.go +++ b/autorest/azure/azure.go @@ -214,7 +214,7 @@ func (r Resource) String() string { // See https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/template-functions-resource?tabs=json#resourceid. func ParseResourceID(resourceID string) (Resource, error) { - const resourceIDPatternText = `(?i)subscriptions/(.+)/resourceGroups/(.+)/providers/(.+?)/(.+?)/(.+)` + const resourceIDPatternText = `(?i)^/subscriptions/(.+)/resourceGroups/(.+)/providers/(.+?)/(.+?)/(.+)$` resourceIDPattern := regexp.MustCompile(resourceIDPatternText) match := resourceIDPattern.FindStringSubmatch(resourceID)