Skip to content

Commit

Permalink
Fix SecureString issue on linux (#12861)
Browse files Browse the repository at this point in the history
* Fix #12707

* Update ChangeLog.md

* Update ChangeLog.md

Co-authored-by: Dingmeng Xue <[email protected]>
  • Loading branch information
dolauli and dingmeng-xue authored Sep 9, 2020
1 parent fad8443 commit 4a4733c
Show file tree
Hide file tree
Showing 109 changed files with 428 additions and 286 deletions.
2 changes: 2 additions & 0 deletions src/Az.autorest.props
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<ModuleHelpFiles Include="$(MSBuildThisFileDirectory)$(PsModuleName)\help\**\*.*"/>
<ModuleGeneratedFiles Include="$(MSBuildThisFileDirectory)$(PsModuleName)\generated\**\*.*"/>
<ModuleTestFiles Include="$(MSBuildThisFileDirectory)$(PsModuleName)\test\**\*.*"/>
<UtilsFiles Include="$(MSBuildThisFileDirectory)$(PsModuleName)\utils\**\*.*"/>
</ItemGroup>

<Target Name="CopyFiles" AfterTargets="Build">
Expand All @@ -72,6 +73,7 @@
<Copy SourceFiles="exports\ProxyCmdletDefinitions.ps1" DestinationFolder="$(RepoArtifacts)$(Configuration)\Az.$(PsModuleName)\exports" />
<Copy SourceFiles="internal\ProxyCmdletDefinitions.ps1" DestinationFolder="$(RepoArtifacts)$(Configuration)\Az.$(PsModuleName)\internal" Condition="Exists('internal\ProxyCmdletDefinitions.ps1')" />
<Copy SourceFiles="internal\Az.$(PsModuleName).internal.psm1" DestinationFolder="$(RepoArtifacts)$(Configuration)\Az.$(PsModuleName)\internal" />
<Copy SourceFiles="@(UtilsFiles)" DestinationFiles="@(UtilsFiles->'$(RepoArtifacts)$(Configuration)\Az.$(PsModuleName)\utils\%(RecursiveDir)%(Filename)%(Extension)')" Condition="Exists('utils')"/>
</Target>

</Project>
160 changes: 138 additions & 22 deletions src/Blockchain/Az.Blockchain.psd1
Original file line number Diff line number Diff line change
@@ -1,25 +1,141 @@
#
# Module manifest for module 'Az.Blockchain'
#
# Generated by: Microsoft Corporation
#
# Generated on: 2020/9/4
#

@{
GUID = 'ae1a09bf-916c-480c-a1bb-bace1453a91e'
RootModule = './Az.Blockchain.psm1'
ModuleVersion = '0.1.0'
CompatiblePSEditions = 'Core', 'Desktop'
Author = 'Microsoft Corporation'
CompanyName = 'Microsoft Corporation'
Copyright = 'Microsoft Corporation. All rights reserved.'
Description = 'Microsoft Azure PowerShell: Blockchain cmdlets'
PowerShellVersion = '5.1'
DotNetFrameworkVersion = '4.7.2'
RequiredAssemblies = './bin/Az.Blockchain.private.dll'
RequiredModules = @(@{ModuleName = 'Az.Accounts'; ModuleVersion = '1.9.3'; })
FormatsToProcess = './Az.Blockchain.format.ps1xml'
FunctionsToExport = 'Get-AzBlockchainConsortium', 'Get-AzBlockchainMember', 'Get-AzBlockchainMemberApiKey', 'Get-AzBlockchainMemberConsortiumMember', 'Get-AzBlockchainSku', 'Get-AzBlockchainTransactionNode', 'Get-AzBlockchainTransactionNodeApiKey', 'New-AzBlockchainMember', 'New-AzBlockchainMemberApiKey', 'New-AzBlockchainTransactionNode', 'New-AzBlockchainTransactionNodeApiKey', 'Remove-AzBlockchainMember', 'Remove-AzBlockchainTransactionNode', 'Test-AzBlockchainLocationNameAvailability', 'Update-AzBlockchainMember', 'Update-AzBlockchainTransactionNode'
AliasesToExport = '*'
PrivateData = @{

# Script module or binary module file associated with this manifest.
RootModule = './Az.Blockchain.psm1'

# Version number of this module.
ModuleVersion = '0.1.0'

# Supported PSEditions
CompatiblePSEditions = 'Core', 'Desktop'

# ID used to uniquely identify this module
GUID = 'ae1a09bf-916c-480c-a1bb-bace1453a91e'

# Author of this module
Author = 'Microsoft Corporation'

# Company or vendor of this module
CompanyName = 'Microsoft Corporation'

# Copyright statement for this module
Copyright = 'Microsoft Corporation. All rights reserved.'

# Description of the functionality provided by this module
Description = 'Microsoft Azure PowerShell: Blockchain cmdlets'

# Minimum version of the PowerShell engine required by this module
PowerShellVersion = '5.1'

# Name of the PowerShell host required by this module
# PowerShellHostName = ''

# Minimum version of the PowerShell host required by this module
# PowerShellHostVersion = ''

# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
DotNetFrameworkVersion = '4.7.2'

# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# CLRVersion = ''

# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
RequiredModules = @(@{ModuleName = 'Az.Accounts'; ModuleVersion = '1.9.3'; })

# Assemblies that must be loaded prior to importing this module
RequiredAssemblies = './bin/Az.Blockchain.private.dll'

# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()

# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = @()

# Format files (.ps1xml) to be loaded when importing this module
FormatsToProcess = './Az.Blockchain.format.ps1xml'

# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
# NestedModules = @()

# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = 'Get-AzBlockchainConsortium', 'Get-AzBlockchainMember',
'Get-AzBlockchainMemberApiKey',
'Get-AzBlockchainMemberConsortiumMember', 'Get-AzBlockchainSku',
'Get-AzBlockchainTransactionNode',
'Get-AzBlockchainTransactionNodeApiKey', 'New-AzBlockchainMember',
'New-AzBlockchainMemberApiKey', 'New-AzBlockchainTransactionNode',
'New-AzBlockchainTransactionNodeApiKey',
'Remove-AzBlockchainMember', 'Remove-AzBlockchainTransactionNode',
'Test-AzBlockchainLocationNameAvailability',
'Update-AzBlockchainMember', 'Update-AzBlockchainTransactionNode'

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = @()

# Variables to export from this module
# VariablesToExport = @()

# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = '*'

# DSC resources to export from this module
# DscResourcesToExport = @()

# List of all modules packaged with this module
# ModuleList = @()

# List of all files packaged with this module
# FileList = @()

# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{

PSData = @{
Tags = 'Azure', 'ResourceManager', 'ARM', 'PSModule', 'Blockchain'
LicenseUri = 'https://aka.ms/azps-license'
ProjectUri = 'https://github.com/Azure/azure-powershell'
ReleaseNotes = ''
}
}

# Tags applied to this module. These help with module discovery in online galleries.
Tags = 'Azure','ResourceManager','ARM','PSModule','Blockchain'

# A URL to the license for this module.
LicenseUri = 'https://aka.ms/azps-license'

# A URL to the main website for this project.
ProjectUri = 'https://github.com/Azure/azure-powershell'

# A URL to an icon representing this module.
# IconUri = ''

# ReleaseNotes of this module
# ReleaseNotes = ''

# Prerelease string of this module
# Prerelease = ''

# Flag to indicate whether the module requires explicit user acceptance for install/update/save
# RequireLicenseAcceptance = $false

# External dependent modules of this module
# ExternalModuleDependencies = @()

} # End of PSData hashtable

} # End of PrivateData hashtable

# HelpInfo URI of this module
# HelpInfoURI = ''

# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''

}

1 change: 1 addition & 0 deletions src/Blockchain/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Additional information about change #1
-->
## Upcoming Release
* Fixed SecureString parameters of `New-AzBlockchainMember` on Linux [12707]

## Version 0.1.0
* the first preview release
Expand Down
8 changes: 5 additions & 3 deletions src/Blockchain/check-dependencies.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ if(-not $Isolated) {
return
}

function DownloadModule ([bool]$predicate, [string]$path, [string]$moduleName, [string]$versionMinimum) {
function DownloadModule ([bool]$predicate, [string]$path, [string]$moduleName, [string]$versionMinimum, [string]$requiredVersion) {
if($predicate) {
$module = Get-Module -ListAvailable -Name $moduleName
if((-not $module) -or ($versionMinimum -and ($module | ForEach-Object { $_.Version } | Where-Object { $_ -ge [System.Version]$versionMinimum } | Measure-Object).Count -eq 0)) {
$null = New-Item -ItemType Directory -Force -Path $path
Write-Host -ForegroundColor Green "Installing local $moduleName module into '$path'..."
if($versionMinimum) {
if ($requiredVersion) {
Find-Module -Name $moduleName -RequiredVersion $requiredVersion -Repository PSGallery | Save-Module -Path $path
}elseif($versionMinimum) {
Find-Module -Name $moduleName -MinimumVersion $versionMinimum -Repository PSGallery | Save-Module -Path $path
} else {
Find-Module -Name $moduleName -Repository PSGallery | Save-Module -Path $path
Expand All @@ -45,7 +47,7 @@ if(Test-Path -Path $localModulesPath) {
}

DownloadModule -predicate ($all -or $Accounts) -path $localModulesPath -moduleName 'Az.Accounts' -versionMinimum '1.7.4'
DownloadModule -predicate ($all -or $Pester) -path $localModulesPath -moduleName 'Pester' -versionMinimum ''
DownloadModule -predicate ($all -or $Pester) -path $localModulesPath -moduleName 'Pester' -requiredVersion '4.10.1'

$tools = Join-Path $PSScriptRoot 'tools'
$resourceDir = Join-Path $tools 'Resources'
Expand Down
4 changes: 2 additions & 2 deletions src/Blockchain/custom/New-AzBlockchainMember.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,12 @@ param(
process {
try {
if ($PSBoundParameters.ContainsKey('Password')) {
$psTxt = [System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($PSBoundParameters['Password']))
$psTxt = . "$PSScriptRoot/../utils/Unprotect-SecureString.ps1" $PSBoundParameters['Password']
$null = $PSBoundParameters.Remove('Password')
$PSBoundParameters.Add('Password', $psTxt)
}
if ($PSBoundParameters.ContainsKey('ConsortiumManagementAccountPassword')) {
$psTxt = [System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($PSBoundParameters['ConsortiumManagementAccountPassword']))
$psTxt = . "$PSScriptRoot/../utils/Unprotect-SecureString.ps1" $PSBoundParameters['ConsortiumManagementAccountPassword']
$null = $PSBoundParameters.Remove('ConsortiumManagementAccountPassword')
$PSBoundParameters.Add('ConsortiumManagementAccountPassword', $psTxt)
}
Expand Down
2 changes: 1 addition & 1 deletion src/Blockchain/custom/New-AzBlockchainTransactionNode.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ param(
process {
try {
if ($PSBoundParameters.ContainsKey('Password')) {
$psTxt = [System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($PSBoundParameters['Password']))
$psTxt = . "$PSScriptRoot/../utils/Unprotect-SecureString.ps1" $PSBoundParameters['Password']
$PSBoundParameters.Remove('Password')
$PSBoundParameters.Add('Password', $psTxt)
}
Expand Down
4 changes: 2 additions & 2 deletions src/Blockchain/custom/Update-AzBlockchainMember.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,12 @@ param(
process {
try {
if ($PSBoundParameters.ContainsKey('Password')) {
$psTxt = [System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($PSBoundParameters['Password']))
$psTxt = . "$PSScriptRoot/../utils/Unprotect-SecureString.ps1" $PSBoundParameters['Password']
$PSBoundParameters.Remove('Password')
$PSBoundParameters.Add('Password', $psTxt)
}
if ($PSBoundParameters.ContainsKey('ConsortiumManagementAccountPassword')) {
$psTxt = [System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($PSBoundParameters['ConsortiumManagementAccountPassword']))
$psTxt = . "$PSScriptRoot/../utils/Unprotect-SecureString.ps1" $PSBoundParameters['ConsortiumManagementAccountPassword']
$PSBoundParameters.Remove('ConsortiumManagementAccountPassword')
$PSBoundParameters.Add('ConsortiumManagementAccountPassword', $psTxt)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ param(
process {
try {
if ($PSBoundParameters.ContainsKey('Password')) {
$psTxt = [System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($PSBoundParameters['Password']))
$psTxt = . "$PSScriptRoot/../utils/Unprotect-SecureString.ps1" $PSBoundParameters['Password']
$PSBoundParameters.Remove('Password')
$PSBoundParameters.Add('Password', $psTxt)
}
Expand Down
2 changes: 1 addition & 1 deletion src/Blockchain/exports/Get-AzBlockchainMember.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ To create the parameters described below, construct a hash table containing the
INPUTOBJECT <IBlockchainIdentity>: Identity Parameter
[BlockchainMemberName <String>]: Blockchain member name.
[Id <String>]: Resource identity path
[Location <String>]: Location Name.
[Location <String>]: Location name.
[OperationId <String>]: Operation Id.
[ResourceGroupName <String>]: The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
[SubscriptionId <String>]: Gets the subscription Id which uniquely identifies the Microsoft Azure subscription. The subscription ID is part of the URI for every service call.
Expand Down
2 changes: 1 addition & 1 deletion src/Blockchain/exports/Get-AzBlockchainTransactionNode.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ To create the parameters described below, construct a hash table containing the
INPUTOBJECT <IBlockchainIdentity>: Identity Parameter
[BlockchainMemberName <String>]: Blockchain member name.
[Id <String>]: Resource identity path
[Location <String>]: Location Name.
[Location <String>]: Location name.
[OperationId <String>]: Operation Id.
[ResourceGroupName <String>]: The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
[SubscriptionId <String>]: Gets the subscription Id which uniquely identifies the Microsoft Azure subscription. The subscription ID is part of the URI for every service call.
Expand Down
2 changes: 1 addition & 1 deletion src/Blockchain/exports/New-AzBlockchainMemberApiKey.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ To create the parameters described below, construct a hash table containing the
INPUTOBJECT <IBlockchainIdentity>: Identity Parameter
[BlockchainMemberName <String>]: Blockchain member name.
[Id <String>]: Resource identity path
[Location <String>]: Location Name.
[Location <String>]: Location name.
[OperationId <String>]: Operation Id.
[ResourceGroupName <String>]: The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
[SubscriptionId <String>]: Gets the subscription Id which uniquely identifies the Microsoft Azure subscription. The subscription ID is part of the URI for every service call.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ To create the parameters described below, construct a hash table containing the
INPUTOBJECT <IBlockchainIdentity>: Identity Parameter
[BlockchainMemberName <String>]: Blockchain member name.
[Id <String>]: Resource identity path
[Location <String>]: Location Name.
[Location <String>]: Location name.
[OperationId <String>]: Operation Id.
[ResourceGroupName <String>]: The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
[SubscriptionId <String>]: Gets the subscription Id which uniquely identifies the Microsoft Azure subscription. The subscription ID is part of the URI for every service call.
Expand Down
Loading

0 comments on commit 4a4733c

Please sign in to comment.