mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-13 21:32:06 +00:00
Improve remote prompt handling for PSCredential and SecureString arrays (#28007)
This commit is contained in:
1 parent
9f7b30680d
commit
a71ba38db7
2 files changed
+14
-4
No files matched your search
@@ -666,12 +666,21 @@ namespace System.Management.Automation.Internal.Host
|
||||
|
||||
internal static bool IsSecuritySensitiveType(string typeName)
|
||||
{
|
||||
if (typeName.Equals(nameof(PSCredential), StringComparison.OrdinalIgnoreCase))
|
||||
string effectiveName = typeName;
|
||||
int suffixIndex = effectiveName.IndexOfAny(new char[] { '[', ',' });
|
||||
if (suffixIndex >= 0)
|
||||
{
|
||||
effectiveName = effectiveName.Substring(0, suffixIndex);
|
||||
}
|
||||
|
||||
if (effectiveName.Equals(nameof(PSCredential), StringComparison.OrdinalIgnoreCase) ||
|
||||
effectiveName.Equals(typeof(PSCredential).FullName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (typeName.Equals(nameof(SecureString), StringComparison.OrdinalIgnoreCase))
|
||||
if (effectiveName.Equals(nameof(SecureString), StringComparison.OrdinalIgnoreCase) ||
|
||||
effectiveName.Equals(typeof(SecureString).FullName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
+3
-2
@@ -379,12 +379,13 @@ namespace System.Management.Automation.Remoting
|
||||
Type fieldType = InternalHostUserInterface.GetFieldType(fieldDesc);
|
||||
if (fieldType != null)
|
||||
{
|
||||
if (fieldType == typeof(PSCredential))
|
||||
Type effectiveType = fieldType.IsArray ? fieldType.GetElementType() : fieldType;
|
||||
if (effectiveType == typeof(PSCredential))
|
||||
{
|
||||
havePSCredential = true;
|
||||
fieldDesc.ModifiedByRemotingProtocol = true;
|
||||
}
|
||||
else if (fieldType == typeof(System.Security.SecureString))
|
||||
else if (effectiveType == typeof(System.Security.SecureString))
|
||||
{
|
||||
prerequisiteCalls.Add(ConstructWarningMessageForSecureString(
|
||||
computerName, RemotingErrorIdStrings.RemoteHostPromptSecureStringPrompt));
|
||||
|
||||
Reference in new issue
Block a user