Skip to content

False positive from PSAvoidUsingPlainTextForPassword #203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
KirkMunro opened this issue May 22, 2015 · 4 comments
Closed

False positive from PSAvoidUsingPlainTextForPassword #203

KirkMunro opened this issue May 22, 2015 · 4 comments
Assignees

Comments

@KirkMunro
Copy link
Contributor

Right now it appears that the PSAvoidUsingPlainTextForPassword rule generates an error whenever it sees a variable called $Password that is not a SecureString. I have a Reset-DoPxDroplet function with a $Password parameter of type switch (System.Management.Automation.SwitchParameter) to allow me to reset the password on a droplet (VM). There is no use of secure string or string, just switch, so that I can make the appropriate REST API endpoint, yet this rule generates a warning anyway.

If I'm clearly defining the type of my $Password parameter as switch, which I am in this case, then this rule shouldn't even look at how I'm using that parameter. It should only complain if I have $Password that is not strongly typed, or that is of type string.

@raghushantha
Copy link
Member

We need to add more heuristics for this rule.

@quoctruong
Copy link

Address in #204

@imfrancisd
Copy link

I think there are missing parentheses on line 58 and line 59.

if (hasPwd && (!paramType.IsArray && (paramType == typeof(String) || paramType == typeof(object)))
              || (paramType.IsArray && (paramType.GetElementType() == typeof(String) || paramType.GetElementType() == typeof(object))))

If line 59 is true, then the value of hasPwd won't matter.

@quoctruong
Copy link

Thanks for the catch Francis. We've fixed this in #226

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants