Skip to content

Commit 0711fb2

Browse files
author
Kapil Borle
committed
Add test case for rule suppression with rule id
1 parent 1641008 commit 0711fb2

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Tests/Engine/RuleSuppression.tests.ps1

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,25 @@ Describe "RuleSuppressionWithoutScope" {
8181
$suppression = $violationsUsingScriptDefinition | Where-Object {$_.RuleName -eq "PSAvoidDefaultValueForMandatoryParameter" }
8282
$suppression.Count | Should Be 1
8383
}
84+
85+
It "Suppresses PSAvoidUsingPlainTextForPassword violation for the given ID" {
86+
$ruleSuppressionIdAvoidPlainTextPassword = @'
87+
function SuppressPwdParam()
88+
{
89+
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingPlainTextForPassword", "password1")]
90+
param(
91+
[string] $password1,
92+
[string] $password2
93+
)
94+
}
95+
'@
96+
Invoke-ScriptAnalyzer `
97+
-ScriptDefinition $ruleSuppressionIdAvoidPlainTextPassword `
98+
-IncludeRule "PSAvoidUsingPlainTextForPassword" `
99+
-OutVariable ruleViolations `
100+
-SuppressedOnly
101+
$ruleViolations.Count | Should Be 1
102+
}
84103
}
85104

86105
if (($PSVersionTable.PSVersion -ge [Version]'5.0'))

0 commit comments

Comments
 (0)