File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,21 @@ $securePassword = ConvertTo-SecureString $decryptedPassword -AsPlainText -Force
30
30
}
31
31
'@
32
32
33
+ # If function doesn't starts at offset 0, then the test case fails before commit b551211
34
+ $ruleSuppressionAvoidUsernameAndPassword = @'
35
+
36
+ function SuppressUserAndPwdRule()
37
+ {
38
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingUserNameAndPassWordParams", "")]
39
+ [CmdletBinding()]
40
+ param
41
+ (
42
+ [System.String] $username,
43
+ [System.Boolean] $password
44
+ )
45
+ }
46
+ '@
47
+
33
48
Describe " RuleSuppressionWithoutScope" {
34
49
Context " Function" {
35
50
It " Does not raise violations" {
@@ -38,6 +53,16 @@ Describe "RuleSuppressionWithoutScope" {
38
53
$suppression = $violationsUsingScriptDefinition | Where-Object { $_.RuleName -eq " PSProvideCommentHelp" }
39
54
$suppression.Count | Should Be 0
40
55
}
56
+
57
+ It " Suppresses rule with extent created using ScriptExtent constructor" {
58
+ Invoke-ScriptAnalyzer `
59
+ - ScriptDefinition $ruleSuppressionAvoidUsernameAndPassword `
60
+ - IncludeRule " PSAvoidUsingUserNameAndPassWordParams" `
61
+ - OutVariable ruleViolations `
62
+ - SuppressedOnly
63
+ $ruleViolations.Count | Should Be 1
64
+ }
65
+
41
66
}
42
67
43
68
Context " Script" {
You can’t perform that action at this time.
0 commit comments