Skip to content

Commit d69fe7f

Browse files
author
Quoc Truong
committed
Merge pull request #204 from PowerShell/FixAvoidUsingPlainTextForPassword
Fix AvoidUsingPlainTextForPassword raised for types other than strings or object
2 parents ba547fc + 6c9b9cf commit d69fe7f

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Rules/AvoidUsingPlainTextForPassword.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
5555
}
5656
}
5757

58-
if (hasPwd && (!paramType.IsArray && paramType != typeof(System.Security.SecureString)
59-
|| (paramType.IsArray && paramType.GetElementType() != typeof(System.Security.SecureString))))
58+
if (hasPwd && (!paramType.IsArray && (paramType == typeof(String) || paramType == typeof(object)))
59+
|| (paramType.IsArray && (paramType.GetElementType() == typeof(String) || paramType.GetElementType() == typeof(object))))
6060
{
6161
yield return new DiagnosticRecord(
6262
String.Format(CultureInfo.CurrentCulture, Strings.AvoidUsingPlainTextForPasswordError, paramAst.Name),

Tests/Rules/AvoidUsingPlainTextForPasswordNoViolations.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
ValueFromPipelineByPropertyName=$true,
1111
Position=0)]
1212
$Param1,
13-
13+
[int]
14+
$passwordinteger,
1415
# Param2 help description
1516
[int]
1617
$Param2,

0 commit comments

Comments
 (0)