@@ -52,15 +52,15 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
52
52
requiresTransformationAttribute = true ;
53
53
}
54
54
55
+ // do not run the rule if the script requires PS version 5
56
+ // but PSSA in invoked through PS version < 5
55
57
if ( sbAst != null
56
- && sbAst . ScriptRequirements != null
57
- && sbAst . ScriptRequirements . RequiredPSVersion != null
58
- && sbAst . ScriptRequirements . RequiredPSVersion . Major == 5 )
58
+ && sbAst . ScriptRequirements != null
59
+ && sbAst . ScriptRequirements . RequiredPSVersion != null
60
+ && sbAst . ScriptRequirements . RequiredPSVersion . Major == 5
61
+ && requiresTransformationAttribute )
59
62
{
60
- if ( requiresTransformationAttribute )
61
- {
62
63
yield break ;
63
- }
64
64
}
65
65
66
66
IEnumerable < Ast > funcDefAsts = ast . FindAll ( testAst => testAst is FunctionDefinitionAst , true ) ;
@@ -153,7 +153,12 @@ private bool WrongCredentialUsage(ParameterAst parameter, bool requiresTransform
153
153
return false ;
154
154
}
155
155
156
- var credentialAttribute = parameter . Attributes . FirstOrDefault ( paramAttribute => paramAttribute . TypeName . GetReflectionType ( ) == typeof ( CredentialAttribute ) ) ;
156
+ var credentialAttribute = parameter . Attributes . FirstOrDefault (
157
+ paramAttribute =>
158
+ paramAttribute . TypeName . GetReflectionType ( ) == typeof ( CredentialAttribute )
159
+ || paramAttribute . TypeName . FullName . Equals (
160
+ "System.Management.Automation.Credential" ,
161
+ StringComparison . OrdinalIgnoreCase ) ) ;
157
162
158
163
// check that both exists and pscredentialtype comes before credential attribute
159
164
if ( psCredentialType != null
0 commit comments