Skip to content

Commit 8617507

Browse files
451 uris in parameters (#553)
* Allowing Hardcoded URLs within Parameters. Fixing #451 * Adding unit test for URIs in parameters (re #451) * Updating test (.Index, not .StartIndex) * Fixing unknown api version in deployments (false negative) Co-authored-by: James Brundage <@github.com>
1 parent 7b737cb commit 8617507

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

arm-ttk/testcases/deploymentTemplate/DeploymentTemplate-Must-Not-Contain-Hardcoded-Uri.test.ps1

+13
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ $preceededBySchema = # The exception to the rule is a schema reference,
5151

5252
# Exception Regexs (end)
5353

54+
$parametersSection = Resolve-JSONContent -JSONPath "parameters" -JSONText $TemplateText
55+
56+
5457
# Walk thru each host reference found
5558
foreach ($match in $HardcodedHostFinder.Matches($TemplateText)) {
5659

@@ -62,6 +65,16 @@ foreach ($match in $HardcodedHostFinder.Matches($TemplateText)) {
6265
$devOpsGalleryMatch = $IsDevOpsGalleryStorage.Match($templateText, $match.Index)
6366
$notTheDevOpsGallery = (-not $devOpsGalleryMatch.Success -or $devOpsGalleryMatch.Index + $devOpsGalleryMatch.Length -ne $match.Index)
6467

68+
69+
if ($parametersSection -and # If there was a parameters section,
70+
( # and the url occured within it
71+
$match.Index -ge $parametersSection.Index -and
72+
$match.Index -lt ( $parametersSection.Index + $parametersSection.Length)
73+
)
74+
) {
75+
continue # this is not a problem. Move onto the next match.
76+
}
77+
6578
if ($notTheDevOpsGallery -and
6679
$notTheSchema
6780
) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2019-08-01/managementGroupDeploymentTemplate.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"MicrosftDotCom": {
6+
"type": "string",
7+
"metadata": {
8+
"description": "https://graph.windows.net/"
9+
}
10+
}
11+
}
12+
}

0 commit comments

Comments
 (0)