Skip to content

Commit a14b50c

Browse files
Christoph Bergmeistersdwheeler
Christoph Bergmeister
authored andcommitted
Updates from newly merged PRs 1857, 1921 and 1850
1 parent 9ad5e07 commit a14b50c

File tree

4 files changed

+57
-3
lines changed

4 files changed

+57
-3
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
description: Avoid sending credentials and secrets over unencrypted connections
3+
ms.custom: PSSA v1.22.0
4+
ms.date: 02/13/2024
5+
ms.topic: reference
6+
title: AvoidUsingAllowUnencryptedAuthentication
7+
---
8+
# AvoidUsingAllowUnencryptedAuthentication
9+
10+
**Severity Level: Warning**
11+
12+
## Description
13+
14+
Avoid using the `AllowUnencryptedAuthentication` switch on `Invoke-WebRequest`, `Invoke-RestMethod`, and other webrequest cmdlets, which sends credentials and secrets over unencrypted connections.
15+
This should be avoided except for compatability with legacy systems.
16+
17+
For more details, see the documentation warning [here](https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/invoke-webrequest#-allowunencryptedauthentication).
18+
19+
## How
20+
21+
Avoid using the `AllowUnencryptedAuthentication` switch.
22+
23+
## Example 1
24+
25+
### Wrong
26+
27+
```powershell
28+
Invoke-WebRequest foo -AllowUnencryptedAuthentication
29+
```
30+
31+
### Correct
32+
33+
```powershell
34+
Invoke-WebRequest foo
35+
```

reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingPositionalParameters.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ supplied. A simple example where the risk of using positional parameters is negl
2525
```powershell
2626
Rules = @{
2727
PSAvoidUsingPositionalParameters = @{
28-
CommandAllowList = 'az', 'Join-Path'
28+
CommandAllowList = 'Join-Path', 'MyCmdletOrScript'
2929
Enable = $true
3030
}
3131
}
3232
```
3333

3434
### Parameters
3535

36-
#### CommandAllowList: string[] (Default value is 'az')
36+
#### CommandAllowList: string[] (Default value is @()')
3737

38-
Commands to be excluded from this rule. `az` is excluded by default because starting with version 2.40.0 the entrypoint of the AZ CLI became an `az.ps1` script but this script does not have any named parameters and just passes them on using `$args` as is to the Python process that it starts, therefore it is still a CLI and not a PowerShell command.
38+
Commands or scripts to be excluded from this rule.
3939

4040
#### Enable: bool (Default value is `$true`)
4141

reference/docs-conceptual/PSScriptAnalyzer/Rules/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ The PSScriptAnalyzer contains the following rule definitions.
2727
| [AvoidSemicolonsAsLineTerminators](./AvoidSemicolonsAsLineTerminators.md) | Warning | No | |
2828
| [AvoidShouldContinueWithoutForce](./AvoidShouldContinueWithoutForce.md) | Warning | Yes | |
2929
| [AvoidTrailingWhitespace](./AvoidTrailingWhitespace.md) | Warning | Yes | |
30+
| [AvoidUsingAllowUnencryptedAuthentication](./AvoidUsingAllowUnencryptedAuthentication.md) | Warning | Yes | |
3031
| [AvoidUsingBrokenHashAlgorithms](./AvoidUsingBrokenHashAlgorithms.md) | Warning | Yes | |
3132
| [AvoidUsingCmdletAliases](./AvoidUsingCmdletAliases.md) | Warning | Yes | Yes<sup>2</sup> |
3233
| [AvoidUsingComputerNameHardcoded](./AvoidUsingComputerNameHardcoded.md) | Error | Yes | |

reference/docs-conceptual/PSScriptAnalyzer/Rules/ReviewUnusedParameter.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,24 @@ title: ReviewUnusedParameter
1414
This rule identifies parameters declared in a script, scriptblock, or function scope that have not
1515
been used in that scope.
1616

17+
## Configuration settings
18+
19+
|Configuration key|Meaning|Accepted values|Mandatory|Example|
20+
|---|---|---|---|---|
21+
|CommandsToTraverse|By default, this command will not consider child scopes other than scriptblocks provided to Where-Object or ForEach-Object. This setting allows you to add additional commands that accept scriptblocks that this rule should traverse into.|string[]: list of commands whose scriptblock to traverse.|`@('Invoke-PSFProtectedCommand')`|
22+
23+
```powershell
24+
@{
25+
Rules = @{
26+
ReviewUnusedParameter = @{
27+
CommandsToTraverse = @(
28+
'Invoke-PSFProtectedCommand'
29+
)
30+
}
31+
}
32+
}
33+
```
34+
1735
## How
1836

1937
Consider removing the unused parameter.

0 commit comments

Comments
 (0)