-
Notifications
You must be signed in to change notification settings - Fork 62
[Freshness] PSScriptAnalyzer Article Updates - Batch 3 #404
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| --- | ||
| description: Avoid semicolons as line terminators | ||
| ms.date: 06/28/2023 | ||
| ms.date: 06/01/2026 | ||
| ms.topic: reference | ||
| title: AvoidSemicolonsAsLineTerminators | ||
| --- | ||
|
|
@@ -10,14 +10,14 @@ title: AvoidSemicolonsAsLineTerminators | |
|
|
||
| ## Description | ||
|
|
||
| Lines should not end with a semicolon. | ||
|
|
||
| > [!NOTE] | ||
| > This rule is not enabled by default. The user needs to enable it through settings. | ||
| Avoid using semicolons at the end of lines. In PowerShell, line-ending semicolons are redundant and | ||
| detract from code readability. Although semicolons serve as statement separators on a single line, | ||
| using them as line terminators is discouraged. This rule promotes cleaner, more maintainable code by | ||
| removing unnecessary semicolons. This rule isn't enabled by default. | ||
|
|
||
| ## Example | ||
|
|
||
| ### Wrong | ||
| ### Noncompliant | ||
|
|
||
| ```powershell | ||
| Install-Module -Name PSScriptAnalyzer; $a = 1 + $b; | ||
|
|
@@ -28,7 +28,7 @@ Install-Module -Name PSScriptAnalyzer; | |
| $a = 1 + $b | ||
| ``` | ||
|
|
||
| ### Correct | ||
| ### Compliant | ||
|
|
||
| ```powershell | ||
| Install-Module -Name PSScriptAnalyzer; $a = 1 + $b | ||
|
|
@@ -43,14 +43,18 @@ $a = 1 + $b | |
|
|
||
| ```powershell | ||
| Rules = @{ | ||
| PSAvoidSemicolonsAsLineTerminators = @{ | ||
| Enable = $true | ||
| PSAvoidSemicolonsAsLineTerminators = @{ | ||
| Enable = $true | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### Parameters | ||
| ## Parameters | ||
|
|
||
| ### Enable | ||
|
|
||
| Enables (`$true`) the rule during ScriptAnalyzer invocation. | ||
|
|
||
| #### Enable: bool (Default value is `$false`) | ||
| ### Disable | ||
|
|
||
| Enable or disable the rule during ScriptAnalyzer invocation. | ||
| Disables (`$false`) the rule during ScriptAnalyzer invocation. Default value is `$false`. | ||
|
Comment on lines
+54
to
+60
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As with the other PRs, recommend reverting this structure since the rule doesn't have a |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| --- | ||
| description: Avoid sending credentials and secrets over unencrypted connections | ||
| ms.date: 02/28/2024 | ||
| ms.date: 06/01/2026 | ||
| ms.topic: reference | ||
| title: AvoidUsingAllowUnencryptedAuthentication | ||
| --- | ||
|
|
@@ -10,25 +10,22 @@ title: AvoidUsingAllowUnencryptedAuthentication | |
|
|
||
| ## Description | ||
|
|
||
| Avoid using the **AllowUnencryptedAuthentication** parameter of `Invoke-WebRequest` and | ||
| `Invoke-RestMethod`. When using this parameter, the cmdlets send credentials and secrets over | ||
| unencrypted connections. This should be avoided except for compatibility with legacy systems. | ||
| The **AllowUnencryptedAuthentication** parameter of `Invoke-WebRequest` and `Invoke-RestMethod` | ||
| permits credentials and secrets to be transmitted over unencrypted connections, creating a security | ||
| risk. Avoid using this parameter unless you must maintain compatibility with legacy systems that | ||
| require unencrypted authentication. | ||
|
|
||
| For more details, see [Invoke-RestMethod](xref:Microsoft.PowerShell.Utility.Invoke-RestMethod). | ||
| To learn more, see [Invoke-RestMethod](xref:Microsoft.PowerShell.Utility.Invoke-RestMethod). | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should also link to |
||
|
|
||
| ## How | ||
| ## Example | ||
|
|
||
| Avoid using the **AllowUnencryptedAuthentication** parameter. | ||
|
|
||
| ## Example 1 | ||
|
|
||
| ### Wrong | ||
| ### Noncompliant | ||
|
|
||
| ```powershell | ||
| Invoke-WebRequest foo -AllowUnencryptedAuthentication | ||
| ``` | ||
|
|
||
| ### Correct | ||
| ### Compliant | ||
|
|
||
| ```powershell | ||
| Invoke-WebRequest foo | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| --- | ||
| description: Avoid using broken hash algorithms | ||
| ms.date: 06/28/2023 | ||
| ms.date: 06/01/2026 | ||
| ms.topic: reference | ||
| title: AvoidUsingBrokenHashAlgorithms | ||
| --- | ||
|
|
@@ -10,37 +10,35 @@ title: AvoidUsingBrokenHashAlgorithms | |
|
|
||
| ## Description | ||
|
|
||
| Avoid using the broken algorithms MD5 or SHA-1. | ||
| Avoid using the cryptographically broken hash algorithms `MD5` and `SHA-1`. These algorithms are | ||
| vulnerable to collision attacks and are no longer considered secure for cryptographic purposes. | ||
|
|
||
| ## How | ||
|
|
||
| Replace broken algorithms with secure alternatives. MD5 and SHA-1 should be replaced with SHA256, | ||
| SHA384, SHA512, or other safer algorithms when possible, with MD5 and SHA-1 only being utilized by | ||
| necessity for backwards compatibility. | ||
| Replace `MD5` and `SHA-1` with secure alternatives such as `SHA256`, `SHA384`, or `SHA512`. Use | ||
| broken algorithms only when absolutely necessary for backwards compatibility with legacy systems. | ||
|
|
||
| ## Example 1 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure we need two examples for this rule. I think we can remove the second example and rename this heading to just |
||
|
|
||
| ### Wrong | ||
| ### Noncompliant | ||
|
|
||
| ```powershell | ||
| Get-FileHash foo.txt -Algorithm MD5 | ||
| ``` | ||
|
|
||
| ### Correct | ||
| ### Compliant | ||
|
|
||
| ```powershell | ||
| Get-FileHash foo.txt -Algorithm SHA256 | ||
| ``` | ||
|
|
||
| ## Example 2 | ||
|
|
||
| ### Wrong | ||
| ### Noncompliant | ||
|
|
||
| ```powershell | ||
| Get-FileHash foo.txt -Algorithm SHA1 | ||
| ``` | ||
|
|
||
| ### Correct | ||
| ### Compliant | ||
|
|
||
| ```powershell | ||
| Get-FileHash foo.txt | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.