From 23d1e521f7b644e5087d272c44412d92f4755088 Mon Sep 17 00:00:00 2001 From: Jin Lei <54836179+msJinLei@users.noreply.github.com> Date: Tue, 15 Dec 2020 15:39:43 +0800 Subject: [PATCH] Fix secure string issue (#13741) --- src/MySql/Az.MySql.psd1 | 4 ++-- src/MySql/ChangeLog.md | 3 +++ src/MySql/Properties/AssemblyInfo.cs | 4 ++-- src/MySql/utils/Unprotect-SecureString.ps1 | 16 ++++++++++++++++ 4 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 src/MySql/utils/Unprotect-SecureString.ps1 diff --git a/src/MySql/Az.MySql.psd1 b/src/MySql/Az.MySql.psd1 index 290f238388ba..f4a08e4ea6a9 100644 --- a/src/MySql/Az.MySql.psd1 +++ b/src/MySql/Az.MySql.psd1 @@ -12,7 +12,7 @@ RootModule = './Az.MySql.psm1' # Version number of this module. -ModuleVersion = '0.3.0' +ModuleVersion = '0.3.1' # Supported PSEditions CompatiblePSEditions = 'Core', 'Desktop' @@ -130,7 +130,7 @@ PrivateData = @{ # IconUri = '' # ReleaseNotes of this module - ReleaseNotes = '* Added MySql flexible server cmdlets' + ReleaseNotes = '* Fixed secure string issue' # Prerelease string of this module # Prerelease = '' diff --git a/src/MySql/ChangeLog.md b/src/MySql/ChangeLog.md index 306283775987..56bfb3914384 100644 --- a/src/MySql/ChangeLog.md +++ b/src/MySql/ChangeLog.md @@ -19,6 +19,9 @@ --> ## Upcoming Release +## Version 0.3.1 +* Fixed secure string issue + ## Version 0.3.0 * Added MySql flexible server cmdlets diff --git a/src/MySql/Properties/AssemblyInfo.cs b/src/MySql/Properties/AssemblyInfo.cs index 35c99a435820..291dcf78cf35 100644 --- a/src/MySql/Properties/AssemblyInfo.cs +++ b/src/MySql/Properties/AssemblyInfo.cs @@ -24,5 +24,5 @@ [assembly: ComVisible(false)] [assembly: CLSCompliant(false)] [assembly: Guid("00815AB0-DED8-4FE1-A7F0-5A98B87EAA3D")] -[assembly: AssemblyVersion("0.3.0")] -[assembly: AssemblyFileVersion("0.3.0")] +[assembly: AssemblyVersion("0.3.1")] +[assembly: AssemblyFileVersion("0.3.1")] diff --git a/src/MySql/utils/Unprotect-SecureString.ps1 b/src/MySql/utils/Unprotect-SecureString.ps1 new file mode 100644 index 000000000000..cb05b51a6220 --- /dev/null +++ b/src/MySql/utils/Unprotect-SecureString.ps1 @@ -0,0 +1,16 @@ +#This script converts securestring to plaintext + +param( + [Parameter(Mandatory, ValueFromPipeline)] + [System.Security.SecureString] + ${SecureString} +) + +$ssPtr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecureString) +try { + $plaintext = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($ssPtr) +} finally { + [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($ssPtr) +} + +return $plaintext \ No newline at end of file