Skip to content

Commit 4a4733c

Browse files
Fix SecureString issue on linux (#12861)
* Fix #12707 * Update ChangeLog.md * Update ChangeLog.md Co-authored-by: Dingmeng Xue <[email protected]>
1 parent fad8443 commit 4a4733c

File tree

109 files changed

+428
-286
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+428
-286
lines changed

src/Az.autorest.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
<ModuleHelpFiles Include="$(MSBuildThisFileDirectory)$(PsModuleName)\help\**\*.*"/>
5858
<ModuleGeneratedFiles Include="$(MSBuildThisFileDirectory)$(PsModuleName)\generated\**\*.*"/>
5959
<ModuleTestFiles Include="$(MSBuildThisFileDirectory)$(PsModuleName)\test\**\*.*"/>
60+
<UtilsFiles Include="$(MSBuildThisFileDirectory)$(PsModuleName)\utils\**\*.*"/>
6061
</ItemGroup>
6162

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

7779
</Project>

src/Blockchain/Az.Blockchain.psd1

Lines changed: 138 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,141 @@
1+
#
2+
# Module manifest for module 'Az.Blockchain'
3+
#
4+
# Generated by: Microsoft Corporation
5+
#
6+
# Generated on: 2020/9/4
7+
#
8+
19
@{
2-
GUID = 'ae1a09bf-916c-480c-a1bb-bace1453a91e'
3-
RootModule = './Az.Blockchain.psm1'
4-
ModuleVersion = '0.1.0'
5-
CompatiblePSEditions = 'Core', 'Desktop'
6-
Author = 'Microsoft Corporation'
7-
CompanyName = 'Microsoft Corporation'
8-
Copyright = 'Microsoft Corporation. All rights reserved.'
9-
Description = 'Microsoft Azure PowerShell: Blockchain cmdlets'
10-
PowerShellVersion = '5.1'
11-
DotNetFrameworkVersion = '4.7.2'
12-
RequiredAssemblies = './bin/Az.Blockchain.private.dll'
13-
RequiredModules = @(@{ModuleName = 'Az.Accounts'; ModuleVersion = '1.9.3'; })
14-
FormatsToProcess = './Az.Blockchain.format.ps1xml'
15-
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'
16-
AliasesToExport = '*'
17-
PrivateData = @{
10+
11+
# Script module or binary module file associated with this manifest.
12+
RootModule = './Az.Blockchain.psm1'
13+
14+
# Version number of this module.
15+
ModuleVersion = '0.1.0'
16+
17+
# Supported PSEditions
18+
CompatiblePSEditions = 'Core', 'Desktop'
19+
20+
# ID used to uniquely identify this module
21+
GUID = 'ae1a09bf-916c-480c-a1bb-bace1453a91e'
22+
23+
# Author of this module
24+
Author = 'Microsoft Corporation'
25+
26+
# Company or vendor of this module
27+
CompanyName = 'Microsoft Corporation'
28+
29+
# Copyright statement for this module
30+
Copyright = 'Microsoft Corporation. All rights reserved.'
31+
32+
# Description of the functionality provided by this module
33+
Description = 'Microsoft Azure PowerShell: Blockchain cmdlets'
34+
35+
# Minimum version of the PowerShell engine required by this module
36+
PowerShellVersion = '5.1'
37+
38+
# Name of the PowerShell host required by this module
39+
# PowerShellHostName = ''
40+
41+
# Minimum version of the PowerShell host required by this module
42+
# PowerShellHostVersion = ''
43+
44+
# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
45+
DotNetFrameworkVersion = '4.7.2'
46+
47+
# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
48+
# CLRVersion = ''
49+
50+
# Processor architecture (None, X86, Amd64) required by this module
51+
# ProcessorArchitecture = ''
52+
53+
# Modules that must be imported into the global environment prior to importing this module
54+
RequiredModules = @(@{ModuleName = 'Az.Accounts'; ModuleVersion = '1.9.3'; })
55+
56+
# Assemblies that must be loaded prior to importing this module
57+
RequiredAssemblies = './bin/Az.Blockchain.private.dll'
58+
59+
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
60+
# ScriptsToProcess = @()
61+
62+
# Type files (.ps1xml) to be loaded when importing this module
63+
# TypesToProcess = @()
64+
65+
# Format files (.ps1xml) to be loaded when importing this module
66+
FormatsToProcess = './Az.Blockchain.format.ps1xml'
67+
68+
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
69+
# NestedModules = @()
70+
71+
# 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.
72+
FunctionsToExport = 'Get-AzBlockchainConsortium', 'Get-AzBlockchainMember',
73+
'Get-AzBlockchainMemberApiKey',
74+
'Get-AzBlockchainMemberConsortiumMember', 'Get-AzBlockchainSku',
75+
'Get-AzBlockchainTransactionNode',
76+
'Get-AzBlockchainTransactionNodeApiKey', 'New-AzBlockchainMember',
77+
'New-AzBlockchainMemberApiKey', 'New-AzBlockchainTransactionNode',
78+
'New-AzBlockchainTransactionNodeApiKey',
79+
'Remove-AzBlockchainMember', 'Remove-AzBlockchainTransactionNode',
80+
'Test-AzBlockchainLocationNameAvailability',
81+
'Update-AzBlockchainMember', 'Update-AzBlockchainTransactionNode'
82+
83+
# 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.
84+
CmdletsToExport = @()
85+
86+
# Variables to export from this module
87+
# VariablesToExport = @()
88+
89+
# 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.
90+
AliasesToExport = '*'
91+
92+
# DSC resources to export from this module
93+
# DscResourcesToExport = @()
94+
95+
# List of all modules packaged with this module
96+
# ModuleList = @()
97+
98+
# List of all files packaged with this module
99+
# FileList = @()
100+
101+
# 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.
102+
PrivateData = @{
103+
18104
PSData = @{
19-
Tags = 'Azure', 'ResourceManager', 'ARM', 'PSModule', 'Blockchain'
20-
LicenseUri = 'https://aka.ms/azps-license'
21-
ProjectUri = 'https://github.com/Azure/azure-powershell'
22-
ReleaseNotes = ''
23-
}
24-
}
105+
106+
# Tags applied to this module. These help with module discovery in online galleries.
107+
Tags = 'Azure','ResourceManager','ARM','PSModule','Blockchain'
108+
109+
# A URL to the license for this module.
110+
LicenseUri = 'https://aka.ms/azps-license'
111+
112+
# A URL to the main website for this project.
113+
ProjectUri = 'https://github.com/Azure/azure-powershell'
114+
115+
# A URL to an icon representing this module.
116+
# IconUri = ''
117+
118+
# ReleaseNotes of this module
119+
# ReleaseNotes = ''
120+
121+
# Prerelease string of this module
122+
# Prerelease = ''
123+
124+
# Flag to indicate whether the module requires explicit user acceptance for install/update/save
125+
# RequireLicenseAcceptance = $false
126+
127+
# External dependent modules of this module
128+
# ExternalModuleDependencies = @()
129+
130+
} # End of PSData hashtable
131+
132+
} # End of PrivateData hashtable
133+
134+
# HelpInfo URI of this module
135+
# HelpInfoURI = ''
136+
137+
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
138+
# DefaultCommandPrefix = ''
139+
25140
}
141+

src/Blockchain/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Fixed SecureString parameters of `New-AzBlockchainMember` on Linux [12707]
2122

2223
## Version 0.1.0
2324
* the first preview release

src/Blockchain/check-dependencies.ps1

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ if(-not $Isolated) {
2121
return
2222
}
2323

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

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

5052
$tools = Join-Path $PSScriptRoot 'tools'
5153
$resourceDir = Join-Path $tools 'Resources'

src/Blockchain/custom/New-AzBlockchainMember.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,12 @@ param(
184184
process {
185185
try {
186186
if ($PSBoundParameters.ContainsKey('Password')) {
187-
$psTxt = [System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($PSBoundParameters['Password']))
187+
$psTxt = . "$PSScriptRoot/../utils/Unprotect-SecureString.ps1" $PSBoundParameters['Password']
188188
$null = $PSBoundParameters.Remove('Password')
189189
$PSBoundParameters.Add('Password', $psTxt)
190190
}
191191
if ($PSBoundParameters.ContainsKey('ConsortiumManagementAccountPassword')) {
192-
$psTxt = [System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($PSBoundParameters['ConsortiumManagementAccountPassword']))
192+
$psTxt = . "$PSScriptRoot/../utils/Unprotect-SecureString.ps1" $PSBoundParameters['ConsortiumManagementAccountPassword']
193193
$null = $PSBoundParameters.Remove('ConsortiumManagementAccountPassword')
194194
$PSBoundParameters.Add('ConsortiumManagementAccountPassword', $psTxt)
195195
}

src/Blockchain/custom/New-AzBlockchainTransactionNode.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ param(
135135
process {
136136
try {
137137
if ($PSBoundParameters.ContainsKey('Password')) {
138-
$psTxt = [System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($PSBoundParameters['Password']))
138+
$psTxt = . "$PSScriptRoot/../utils/Unprotect-SecureString.ps1" $PSBoundParameters['Password']
139139
$PSBoundParameters.Remove('Password')
140140
$PSBoundParameters.Add('Password', $psTxt)
141141
}

src/Blockchain/custom/Update-AzBlockchainMember.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,12 @@ param(
141141
process {
142142
try {
143143
if ($PSBoundParameters.ContainsKey('Password')) {
144-
$psTxt = [System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($PSBoundParameters['Password']))
144+
$psTxt = . "$PSScriptRoot/../utils/Unprotect-SecureString.ps1" $PSBoundParameters['Password']
145145
$PSBoundParameters.Remove('Password')
146146
$PSBoundParameters.Add('Password', $psTxt)
147147
}
148148
if ($PSBoundParameters.ContainsKey('ConsortiumManagementAccountPassword')) {
149-
$psTxt = [System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($PSBoundParameters['ConsortiumManagementAccountPassword']))
149+
$psTxt = . "$PSScriptRoot/../utils/Unprotect-SecureString.ps1" $PSBoundParameters['ConsortiumManagementAccountPassword']
150150
$PSBoundParameters.Remove('ConsortiumManagementAccountPassword')
151151
$PSBoundParameters.Add('ConsortiumManagementAccountPassword', $psTxt)
152152
}

src/Blockchain/custom/Update-AzBlockchainTransactionNode.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ param(
133133
process {
134134
try {
135135
if ($PSBoundParameters.ContainsKey('Password')) {
136-
$psTxt = [System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($PSBoundParameters['Password']))
136+
$psTxt = . "$PSScriptRoot/../utils/Unprotect-SecureString.ps1" $PSBoundParameters['Password']
137137
$PSBoundParameters.Remove('Password')
138138
$PSBoundParameters.Add('Password', $psTxt)
139139
}

src/Blockchain/exports/Get-AzBlockchainMember.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ To create the parameters described below, construct a hash table containing the
6060
INPUTOBJECT <IBlockchainIdentity>: Identity Parameter
6161
[BlockchainMemberName <String>]: Blockchain member name.
6262
[Id <String>]: Resource identity path
63-
[Location <String>]: Location Name.
63+
[Location <String>]: Location name.
6464
[OperationId <String>]: Operation Id.
6565
[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.
6666
[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.

src/Blockchain/exports/Get-AzBlockchainTransactionNode.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ To create the parameters described below, construct a hash table containing the
5050
INPUTOBJECT <IBlockchainIdentity>: Identity Parameter
5151
[BlockchainMemberName <String>]: Blockchain member name.
5252
[Id <String>]: Resource identity path
53-
[Location <String>]: Location Name.
53+
[Location <String>]: Location name.
5454
[OperationId <String>]: Operation Id.
5555
[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.
5656
[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.

src/Blockchain/exports/New-AzBlockchainMemberApiKey.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ To create the parameters described below, construct a hash table containing the
4848
INPUTOBJECT <IBlockchainIdentity>: Identity Parameter
4949
[BlockchainMemberName <String>]: Blockchain member name.
5050
[Id <String>]: Resource identity path
51-
[Location <String>]: Location Name.
51+
[Location <String>]: Location name.
5252
[OperationId <String>]: Operation Id.
5353
[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.
5454
[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.

src/Blockchain/exports/New-AzBlockchainTransactionNodeApiKey.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ To create the parameters described below, construct a hash table containing the
4848
INPUTOBJECT <IBlockchainIdentity>: Identity Parameter
4949
[BlockchainMemberName <String>]: Blockchain member name.
5050
[Id <String>]: Resource identity path
51-
[Location <String>]: Location Name.
51+
[Location <String>]: Location name.
5252
[OperationId <String>]: Operation Id.
5353
[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.
5454
[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.

0 commit comments

Comments
 (0)