Skip to content

no-plain-text-password

PowerShellsuspiciousno fixdefault: warnpowershell/psscriptanalyzer

Reports a [string] parameter whose name contains password, passphrase or cred.

A [string] stays in memory as clear text and is easy to log or to show in history and transcripts. [SecureString] and [PSCredential] keep the secret protected and make the cmdlet fit with the credential handling of other commands.

To fix, take a [SecureString] or a [PSCredential].

Reported
...
param(
[string]$Password,
[Parameter(Mandatory)][string] $UserPassphrase = 'x',
[securestring]$Secret,
[string]$Name,
...
$null = 1
$global:LASTEXITCODE = 1
...
function Show-It($Error, [string]$Credential) { }
powershell:
lint:
rules:
no-plain-text-password: warn # off, warn (default), error

Enabled by the presets: powershell/psscriptanalyzer.

Suppress one line with sudsy-disable-next-line no-plain-text-password in a comment of the file’s language.

The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.

Tool Rule Match What differs
psscriptanalyzer PSAvoidUsingPlainTextForPassword partial SuppressMessageAttribute is not honored (see the scope).