Skip to content

Commit

Permalink
Fix secure string issue (#13741) (#13754)
Browse files Browse the repository at this point in the history
  • Loading branch information
msJinLei authored Dec 16, 2020
1 parent 29ff833 commit 219620f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/MySql/Az.MySql.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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 = ''
Expand Down
3 changes: 3 additions & 0 deletions src/MySql/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
-->
## Upcoming Release

## Version 0.3.1
* Fixed secure string issue

## Version 0.3.0
* Added MySql flexible server cmdlets

Expand Down
4 changes: 2 additions & 2 deletions src/MySql/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
16 changes: 16 additions & 0 deletions src/MySql/utils/Unprotect-SecureString.ps1
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 219620f

Please sign in to comment.