Skip to content

Commit b55122c

Browse files
authored
Bug in VerifyNSG() function result initialisation
VerifyNSG() has a simple bug - on entering the function the result success flag is incorrectly initialised to $true (optimistic) - when it should be initialised to $false (pessimistic) ... The function can ONLY be successful on one path; IF an NSG is found WITH valid rules. As it was, if NO NSG is found the function will STILL return success and therefore the following script / code used for mitigation will not be executed.
1 parent 525b554 commit b55122c

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

samples/manage/azure-sql-db-managed-instance/prepare-subnet/prepareSubnet.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ function VerifyNSG {
485485
$result = @{
486486
nsgSecurityRules = New-Object "$NScollections.List``1[$NSnetworkModels.PSSecurityRule]"
487487
failedSecurityRules = New-Object "$NScollections.List``1[$NSnetworkModels.PSSecurityRule]"
488-
success = $true
488+
success = $false
489489
}
490490
Write-Host("Verifying Network security group for subnet '{0}'."-f $subnet.Name)
491491
$nsg = LoadNetworkSecurityGroup $subnet

0 commit comments

Comments
 (0)