Skip to content

Commit 39441ba

Browse files
author
Quoc Truong
committed
Add comments
1 parent 776f40d commit 39441ba

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Rules/AvoidUserNameAndPasswordParams.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,21 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
5353
// Iterates all ParamAsts and check if their names are on the list.
5454
foreach (ParameterAst paramAst in paramAsts)
5555
{
56+
// this will be null if there is no [pscredential] attached to the parameter
5657
var psCredentialType = paramAst.Attributes.FirstOrDefault(paramAttribute =>
5758
(paramAttribute.TypeName.IsArray && (paramAttribute.TypeName as ArrayTypeName).ElementType.GetReflectionType() == typeof(PSCredential))
5859
|| paramAttribute.TypeName.GetReflectionType() == typeof(PSCredential));
5960

61+
// this will be null if there are no [credential()] attribute attached
6062
var credentialAttribute = paramAst.Attributes.FirstOrDefault(paramAttribute => paramAttribute.TypeName.GetReflectionType() == typeof(CredentialAttribute));
6163

62-
String paramName = paramAst.Name.VariablePath.ToString();
63-
64-
// check that the type is securestring
64+
// this will be null if there are no [securestring] attached to the parameter
6565
var secureStringType = paramAst.Attributes.FirstOrDefault(paramAttribute =>
6666
(paramAttribute.TypeName.IsArray && (paramAttribute.TypeName as ArrayTypeName).ElementType.GetReflectionType() == typeof (System.Security.SecureString))
6767
|| paramAttribute.TypeName.GetReflectionType() == typeof(System.Security.SecureString));
68-
68+
69+
String paramName = paramAst.Name.VariablePath.ToString();
70+
6971
foreach (String password in passwords)
7072
{
7173
if (paramName.IndexOf(password, StringComparison.OrdinalIgnoreCase) != -1)

0 commit comments

Comments
 (0)