From 920207f51ff949cac06400902dd965a2035c9cdf Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Wed, 8 Apr 2026 14:26:29 -0400 Subject: [PATCH] Fix S360 PSAvoidUsingConvertToSecureStringWithPlainText in GetCredential.Tests.ps1 Replace ConvertTo-SecureString -AsPlainText with [System.Net.NetworkCredential]::new() which produces an equivalent SecureString without triggering the PSSA rule. Fixes ADO #34502919 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../Microsoft.PowerShell.Security/GetCredential.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Security/GetCredential.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Security/GetCredential.Tests.ps1 index fad8285aab..7b9600a434 100755 --- a/test/powershell/Modules/Microsoft.PowerShell.Security/GetCredential.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Security/GetCredential.Tests.ps1 @@ -97,7 +97,7 @@ Describe "Get-Credential Test" -Tag "CI" { } It "Get-Credential `$credential" { #[SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine", Justification="Demo/doc/test secret.")] - $password = ConvertTo-SecureString -String "CredTest" -AsPlainText -Force + $password = [System.Net.NetworkCredential]::new('', 'CredTest').SecurePassword $credential = [pscredential]::new("John", $password) $cred = Get-Credential $credential