Skip to content

Commit d6b17a1

Browse files
committed
Fix PSScript Analyzer
1 parent 874947f commit d6b17a1

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

.github/linters/.powershell-psscriptanalyzer.psd1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
ExcludeRules = @(
1212
'PSUseShouldProcessForStateChangingFunctions',
1313
'PSAvoidUsingConvertToSecureStringWithPlainText',
14-
'PSUseDeclaredVarsMoreThanAssignments'
14+
'PSUseDeclaredVarsMoreThanAssignments',
15+
'PSUseLiteralInitializerForHashtable'
1516

1617
)
1718
#IncludeRules = @(

SecretManagement.Hashicorp.Vault.KV/SecretManagement.Hashicorp.Vault.KV.Extension/SecretManagement.Hashicorp.Vault.KV.Extension.psm1

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,11 @@ function Invoke-VaultToken {
151151
#>
152152
[CmdletBinding()]
153153
param (
154-
[Parameter(ValueFromPipelineByPropertyName)]
154+
[Parameter()]
155155
[SecureString] $Password,
156-
[Parameter(ValueFromPipelineByPropertyName)]
156+
[Parameter()]
157157
[string] $VaultName,
158-
[Parameter(ValueFromPipelineByPropertyName)]
158+
[Parameter()]
159159
[hashtable] $AdditionalParameters
160160
)
161161
Test-VaultVariable -Arguments $AdditionalParameters
@@ -226,7 +226,11 @@ function Invoke-VaultToken {
226226
continue
227227
}
228228
"Token" {
229-
$script:VaultToken = (Get-Credential -UserName Token -Message "Please Enter the token").Password
229+
if ($Password) {
230+
$script:VaultToken = $Password
231+
} else {
232+
$script:VaultToken = (Get-Credential -UserName Token -Message "Please Enter the token").Password
233+
}
230234
break
231235
}
232236
"userpass" {
@@ -480,6 +484,7 @@ function Get-Secret {
480484
$SecretName = $Name
481485
}
482486
$SecretData = Invoke-VaultAPIQuery -VaultName $VaultName -SecretName $Name @VerboseSplat
487+
#jscpd:ignore-start
483488
switch ($script:KVVersion) {
484489
'v1' {
485490
switch ($script:OutputType) {
@@ -529,6 +534,7 @@ function Get-Secret {
529534
}
530535
default { throw "Unknown KeyVaule version" }
531536
}
537+
#jscpd:ignore-end
532538
return $SecretObject
533539
}
534540
}
@@ -730,7 +736,9 @@ function Unlock-SecretVault {
730736
[Parameter(ValueFromPipelineByPropertyName)]
731737
[hashtable] $AdditionalParameters
732738
)
733-
Invoke-VaultToken -Password $Password -VaultName $VaultName -AdditionalParameters $AdditionalParameters
739+
process {
740+
Invoke-VaultToken -Password $Password -VaultName $VaultName -AdditionalParameters $AdditionalParameters
741+
}
734742
}
735743
function Unregister-SecretVault {
736744
[CmdletBinding()]

0 commit comments

Comments
 (0)