no-plain-text-secure-string
What it does
Section titled “What it does”Reports a call of ConvertTo-SecureString with -AsPlainText.
Why it matters
Section titled “Why it matters”It turns a clear-text string into a SecureString, and the clear text is in the script, the history and the logs already. The protection is only in name.
To fix, read the secret as a SecureString (Read-Host -AsSecureString, a vault or Get-Credential).
Example
Section titled “Example”...Get-Help Write-Host...ConvertTo-SecureString $p -AsPlainText -ForceConvertTo-SecureString $pConvertTo-SecureString ` $p -AsPlainText...Get-CimInstance Win32_ProcessConvertTo-SecureString -AsPlainText "x" -Force...function Get-It { [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingWriteHost", "")]...Configuration
Section titled “Configuration”powershell: lint: rules: no-plain-text-secure-string: error # off, warn, error (default)Enabled by the presets: powershell/psscriptanalyzer.
Suppress one line with sudsy-disable-next-line no-plain-text-secure-string in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| psscriptanalyzer | PSAvoidUsingConvertToSecureStringWithPlainText |
full |