Skip to content

Commit

Permalink
Merge branch 'master' into CacheUpdate-2023-01-21
Browse files Browse the repository at this point in the history
  • Loading branch information
Pallavi Sah committed Jun 16, 2023
2 parents a08c8ac + 40ed1a0 commit b2c9b1c
Show file tree
Hide file tree
Showing 13 changed files with 533 additions and 263 deletions.
441 changes: 227 additions & 214 deletions arm-ttk/cache/AllAzureResources.cache.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,17 @@ $passwordBoxes = $CreateUIDefinitionObject |
foreach ($pwb in $passwordBoxes) { # Loop over each password box
$controlName = $pwb.Name # and find the output it maps to.
$theOutput = foreach ($out in $CreateUIDefinitionObject.parameters.outputs.psobject.properties) {
if (($out.Value -like "*steps(*$controlName*") -or ($out.Value -like "*basics(*$controlName*")) {
$out; break
$outputValueType = $out.Value.GetType().Name
if ($outputValueType -eq "PSCustomObject") {
$outputJson = $out.Value | ConvertTo-Json -Compress
if (($outputJson -like "*steps(*$controlName*") -or ($outputJson -like "*basics(*$controlName*")) {
$out; break
}
}
else {
if (($out.Value -like "*steps(*$controlName*") -or ($out.Value -like "*basics(*$controlName*")) {
$out; break
}
}
}

Expand All @@ -39,13 +48,13 @@ foreach ($pwb in $passwordBoxes) { # Loop over each password box

# If we couldn't find it, write an error.
if (-not $MainTemplateParam) {
Write-Error "Password box $($pwb.Name) is missing from main template parameters "-TargetObject $pwb
Write-Error "Password box $($pwb.Name) linked to output $($theOutput.Name) is missing from main template parameters "-TargetObject $pwb
continue
}

# If the main template parameter type is neither a Secure String nor a Secure Object
if (($MainTemplateParam.type -ne 'SecureString') -and ($MainTemplateParam.type -ne 'SecureObject')) {
# write an error.
Write-Error "PasswordBox controls must use secureString or secureObject parameter types. The Main template parameter '$($pwb.Name)' is a '$($MainTemplateParam.type)'" -TargetObject @($pwb, $MainTemplateParam)
Write-Error "PasswordBox controls must use secureString or secureObject parameter types. The Main template parameter '$($theOutput.Name)' linked to '$($pwb.Name)' is a '$($MainTemplateParam.type)'" -TargetObject @($pwb, $MainTemplateParam)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ foreach ($pwb in $passwordBoxes) { # Loop over each password box
$totalMins += $match.Groups['Min'].Value -as [int]
}
if ($passWordMinLength -gt $totalMins) {
Write-Warning "PasswordBox '$($pwb.Name)' regex does not have a minimum length of $PasswordMinLength" -TargetObject $pwb
Write-Warning "PasswordBox '$($pwb.Name)' regex does not have a minimum length of $PasswordMinLength"
}
}
} catch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@ param(
)

# First, find all textboxes within CreateUIDefinition.

$allTextBoxes = $CreateUiDefinitionObject | Find-JsonContent -Key type -value Microsoft.Common.TextBox
# Match length constraint at beginning of regex.
# Input string starts with ^(?=.{N,N} ^ ( ? = . {N ,N}
$lengthConstraintRegexAtBeginning = [Regex]::new('^[\^][\(][\?][=][\.]\{(?<Min>\d+),(?<Max>\d+)?\}.*')
$lengthConstraintRegexAtEnd = [Regex]::new('\{(?<Min>\d+),(?<Max>\d+)?\}(\$)?$')
# Regex Constraint should contain one of following pattern (Length Check): {m,n} or {m,} or {m}
$lengthContraintRegex = [Regex]::new('\{(?<Min>\d+)(?:,(?<Max>\d+)|,)?\}')

foreach ($textbox in $allTextBoxes) {
# Then we walk over each textbox.
Expand All @@ -26,6 +23,7 @@ foreach ($textbox in $allTextBoxes) {
Write-Error -Message "Textbox $($textbox.Name) is missing constraints" -ErrorId Textboxes.Are.Well.Formed.Missing.Constraints -TargetObject $textbox # error
continue # and continue (since additional failures would be noise).
}

$constraintRegexString = "";
if ($textbox.constraints.validations) {
$constraintRegexString = foreach ($validation in $textbox.constraints.validations) {
Expand All @@ -37,27 +35,27 @@ foreach ($textbox in $allTextBoxes) {
elseif ($textbox.constraints.regex) {
$constraintRegexString = $textbox.constraints.regex
if (-not $textbox.constraints.validationMessage) {
# If there's not a validation message
# Regex constraint is missing validation message
Write-Error -Message "Textbox $($textbox.Name) is missing constraints.validationMessage" -ErrorId Textboxes.Are.Well.Formed.Missing.Constraints.ValidationMessage -TargetObject $textbox #error.
}
}

if (-not $constraintRegexString ) {
# If the constraint didn't have a regex,
# If the constraint didn't have a regex
Write-Error -Message "Textbox $($textbox.Name) is missing constraints.regex or regex property in constraints.validations" -ErrorId Textboxes.Are.Well.Formed.Missing.Constraints.Regex -TargetObject $textbox #error.
}
else {
try {
# If it did,
# If it did
$constraintWasRegex = [Regex]::new($constraintRegexString) # try to cast to a regex
$hasLengthConstraintAtBeginning = $lengthConstraintRegexAtBeginning.Match($constraintRegexString)
$hasLengthConstraintAtEnd = $lengthConstraintRegexAtEnd.Match($constraintRegexString)
$hasLengthConstraint = $lengthContraintRegex.Match($constraintRegexString)

if (-not ($hasLengthConstraintAtBeginning.Success -or $hasLengthConstraintAtEnd.Success -or $isExpression.Success)) {
if (-not ($hasLengthConstraint.Success)) {
Write-Warning "TextBox '$($textBox.Name)' regex does not have a length constraint."
}
}
catch {
$err = $_ # if that fails,
$err = $_ # if that fails
Write-Error -Message "Textbox $($textbox.Name) regex is invalid: $($err)" -ErrorId Textboxes.Are.Well.Formed.Invalid.Constraints.Regex.Expressison -TargetObject $textbox #error.
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ $shouldHaveTooltips = $CreateUIDefinitionObject |
$noToolTipControls = "Microsoft.Common.InfoBox",
"Microsoft.Common.Section",
"Microsoft.Common.TextBlock",
"Microsoft.Solutions.ArmApiControl"
"Microsoft.Solutions.ArmApiControl",
"Microsoft.Common.EditableGrid"

foreach ($shouldHave in $shouldHaveTooltips) {
# then loop through each control
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location."
}
},
"certificates": {
"type": "object",
"defaultValue": [
{
"password": "password"
}
],
"metadata": {
"description": "Backend data."
}
}
},
"variables": {
},
"resources": [
],
"outputs": {
"location": {
"type": "string",
"value": "[parameters('location')]"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
"handler": "Microsoft.Azure.CreateUIDef",
"version": "0.1.2-preview",
"parameters": {
"basics": [
{
"name": "settings",
"label": "Settings",
"bladeTitle": "Settings",
"elements": [
{
"type": "Microsoft.Common.Section",
"name": "section",
"label": "Section Settings",
"visible": "true",
"elements": [
{
"type": "Microsoft.Common.PasswordBox",
"name": "passwordBox",
"label": {
"password": "Password",
"confirmPassword": "Confirm password"
},
"toolTip": "Password for password box",
"visible": true,
"constraints": {
"required": true,
"regex": "^[\\S]{10,25}$",
"validationMessage": "Password must be between 10 and 25 characters."
},
"options": {
"hideConfirmation": false
}
}
]
}
]
}
],
"outputs": {
"Location": "[location()]",
"certificates": {
"0": {
"password": "[coalesce(steps('settings').section.passwordBox, 'NA')]"
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location."
}
},
"certificates": {
"type": "secureObject",
"defaultValue": [
{
"password": "password"
}
],
"metadata": {
"description": "Backend data."
}
}
},
"variables": {
},
"resources": [
],
"outputs": {
"location": {
"type": "string",
"value": "[parameters('location')]"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
"handler": "Microsoft.Azure.CreateUIDef",
"version": "0.1.2-preview",
"parameters": {
"basics": [
{
"name": "settings",
"label": "Settings",
"bladeTitle": "Settings",
"elements": [
{
"type": "Microsoft.Common.Section",
"name": "section",
"label": "Section Settings",
"visible": "true",
"elements": [
{
"type": "Microsoft.Common.PasswordBox",
"name": "passwordBox",
"label": {
"password": "Password",
"confirmPassword": "Confirm password"
},
"toolTip": "Password for password box",
"visible": true,
"constraints": {
"required": true,
"regex": "^[\\S]{10,25}$",
"validationMessage": "Password must be between 10 and 25 characters."
},
"options": {
"hideConfirmation": false
}
}
]
}
]
}
],
"outputs": {
"Location": "[location()]",
"certificates": {
"0": {
"password": "[coalesce(steps('settings').section.passwordBox, 'NA')]"
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
"handler": "Microsoft.Compute.MultiVm",
"version": "0.1.2-preview",
"parameters": {
"basics": [
{
"name": "dbAdminPassword",
"type": "Microsoft.Common.PasswordBox",
"label": {
"password": "Password",
"confirmPassword": "Confirm password"
},
"toolTip": "Admin password for the database",
"constraints": {
"required": true,
"regex": "^(?=.*[A-Z])(?=.*[a-z])(?=.*\\d)[A-Za-z\\d\\$\\&\\+\\,:\\=\\?@#|'.\\^\\*!\\-_~/'\\[\\]\\{\\}\"]{8,}$",
"validationMessage": "The password must contain at least 8 characters, with at least 1 uppercase letter, 1 lowercase letter and 1 number, and special characters, but should not contain > < ( ) % ; \\."
},
"options": {
"hideConfirmation": false
},
"visible": true
}
],
"steps": []
}
}
Loading

0 comments on commit b2c9b1c

Please sign in to comment.