fix lint issues
continuous-integration/drone/push Build is failing Details
continuous-integration/drone/pr Build is failing Details

This commit is contained in:
OCram85 2022-07-15 10:17:16 +02:00
parent 22a3e838c8
commit c6234e1884
3 changed files with 19 additions and 10 deletions

View File

@ -26,6 +26,11 @@ function New-CSCertificate {
#> #>
[CmdletBinding(SupportsShouldProcess = $true)] [CmdletBinding(SupportsShouldProcess = $true)]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
'PSAvoidUsingInvokeExpression',
'',
Justification = 'needed for openssl wrapping'
)]
[OutputType()] [OutputType()]
param ( param (
[Parameter(Mandatory = $true, ValueFromPipeline = $true)] [Parameter(Mandatory = $true, ValueFromPipeline = $true)]
@ -57,7 +62,10 @@ function New-CSCertificate {
Write-Error @ErrorParams Write-Error @ErrorParams
} }
} }
elseif (($PSVersionTable.PSEdition -eq 'Desktop' -and $PSVersionTable.PSVersion.Major -lt 6) -or ($IsWindows -eq $true)) { elseif (
($PSVersionTable.PSEdition -eq 'Desktop' -and $PSVersionTable.PSVersion.Major -lt 6) -or
($IsWindows -eq $true)
) {
$openssl = Join-Path -Path $ModuleBase -ChildPath '/Vendor/libressl255/openssl.exe' $openssl = Join-Path -Path $ModuleBase -ChildPath '/Vendor/libressl255/openssl.exe'
} }
@ -77,7 +85,9 @@ function New-CSCertificate {
$Subj = $SubjPattern -f $SubjValues $Subj = $SubjPattern -f $SubjValues
$PEMCertName = $CertName -replace '.pfx', '.crt' $PEMCertName = $CertName -replace '.pfx', '.crt'
$ExpPattern = '& ''{0}'' req -x509 -sha256 -nodes -days {1} -newkey rsa:2048 -keyout {2} -out {3} -subj "{4}" *>$null' $ExpPattern = (
'& ''{0}'' req -x509 -sha256 -nodes -days {1} -newkey rsa:2048 -keyout {2} -out {3} -subj "{4}" *>$null'
)
$ExpValues = @( $ExpValues = @(
$openssl, $openssl,
$CRTAttribute.Days $CRTAttribute.Days

View File

@ -14,8 +14,6 @@ BeforeAll {
Describe "Get-CredentialStore" { Describe "Get-CredentialStore" {
Context "Basic logic tests" { Context "Basic logic tests" {
It "Read CS without params" { It "Read CS without params" {
$TestCredentialStore = './resources/cs/CredentialStore.json'
$TestPfxCert = './resources/cs/PSCredentialStore.pfx'
if (! (Test-Path -Path (Get-DefaultCredentialStorePath)) ) { if (! (Test-Path -Path (Get-DefaultCredentialStorePath)) ) {
{ New-CredentialStore -Force } | Should -Not -Throw { New-CredentialStore -Force } | Should -Not -Throw
} }

View File

@ -19,13 +19,13 @@ function New-CredentialStore {
Use this switch to reset an existing store. The complete content will be wiped. Use this switch to reset an existing store. The complete content will be wiped.
.PARAMETER SkipPFXCertCreation .PARAMETER SkipPFXCertCreation
You can skip the pfx certificate creation process. This makes sense if you have a previously created cert or want to You can skip the pfx certificate creation process. This makes sense if you have a previously created cert
import a cert in cross-platform environments. or want to import a cert in cross-platform environments.
.Parameter UseCertStore .Parameter UseCertStore
Instead of using a plain pfx file beside your CredentialStore file you can import it into the user or machine Instead of using a plain pfx file beside your CredentialStore file you can import it into the user or
certificate store. In this case the system itself secures the cert and you don't hat to set custom NTFS machine certificate store. In this case the system itself secures the cert and you don't hat to set custom
permissions so secure your shared certificate. NTFS permissions so secure your shared certificate.
.INPUTS .INPUTS
[None] [None]
@ -88,7 +88,8 @@ function New-CredentialStore {
$ErrorParams = @{ $ErrorParams = @{
ErrorAction = 'Stop' ErrorAction = 'Stop'
Exception = [System.IO.InvalidDataException]::new( Exception = [System.IO.InvalidDataException]::new(
'Please provide a full path containing the credential store file name with the .json extension!' 'Please provide a full path containing the ' +
'credential store file name with the .json extension!'
) )
} }
Write-Error @ErrorParams Write-Error @ErrorParams