Skip to content
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

Add AvoidUsingAllowUnencryptedAuthentication #1857

Merged
merged 8 commits into from Feb 13, 2024

Conversation

MJVL
Copy link
Contributor

@MJVL MJVL commented Nov 6, 2022

PR Summary

This adds a new rule: AvoidUsingAllowUnencryptedAuthentication.

This rule searches for use of the -AllowUnencryptedAuthentication switch. This mainly serves to flag use with Invoke-WebRequest and Invoke-RestMethod, but also works for other cmdlets which may use the same parameter scheme.

This parameter is directly warned against in MSDN as it isn't secure. It is risky and should only be used for compatibility with legacy systems. A Warning here should be sufficient to dissuade against this.

PR Checklist

Copy link
Collaborator

@bergmeister bergmeister left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, just some minor suggestions but looks good otherwise.

docs/Rules/AvoidUsingAllowUnencryptedAuthentication.md Outdated Show resolved Hide resolved
#if !CORECLR
[Export(typeof(IScriptRule))]
#endif
public class AvoidUsingAllowUnencryptedAuthentication : AvoidParameterGeneric
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, didn't know there was this base class to make implementation so much simpler

… into authRule

# Conflicts:
#	Rules/Strings.Designer.cs
#	Rules/Strings.resx
Describe "AvoidUsingAllowUnencryptedAuthentication" {
Context "When there are violations" {
It "detects unencrypted authentication violations" {
(Invoke-ScriptAnalyzer -ScriptDefinition 'Invoke-WebRequest foo -AllowUnencryptedAuthentication' -Settings $settings).Count | Should -Be 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd be happier if these were separate test cases, but this is ok

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

Successfully merging this pull request may close these issues.

None yet

3 participants