Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Don't Merge!][SecureString][Autorest-custom][Az.ContainerRegistry] Update the String property to SecureString #26866

Open
wants to merge 1 commit into
base: generation
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ public class PSContainerRegistryCredential
public PSContainerRegistryCredential(RegistryListCredentialsResult credentials)
{
Username = credentials?.Username;
Password = credentials?.Password?.Length > 0 ? credentials.Password[0]?.Value : string.Empty;
Password2 = credentials?.Password?.Length > 1 ? credentials.Password[1]?.Value : string.Empty;
Password = credentials?.Password?.Length > 0 ? credentials.Password[0]?.Value.ToSecureString() : string.Empty.ToSecureString();
Password2 = credentials?.Password?.Length > 1 ? credentials.Password[1]?.Value.ToSecureString() : string.Empty.ToSecureString();
}

public string Username { get; set; }
public string Password { get; set; }
public string Password2 { get; set; }
public System.Security.SecureString Password { get ; set; }
public System.Security.SecureString Password2 { get ; set; }
}
}
19 changes: 19 additions & 0 deletions src/ContainerRegistry/ContainerRegistry.Autorest/custom/Utils.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace Microsoft.Azure.PowerShell.Cmdlets.ContainerRegistry.Models.Api202301Preview
{
public static class Utils
{
public static System.Security.SecureString ToSecureString(this string input)
{
if (string.IsNullOrEmpty(input))
return null;

System.Security.SecureString secureString = new System.Security.SecureString();
foreach (char c in input)
{
secureString.AppendChar(c);
}
secureString.MakeReadOnly();
return secureString;
}
}
}
Loading