diff --git a/.github/workflows/ms.keyvault.vaults.yml b/.github/workflows/ms.keyvault.vaults.yml index ece5a08f75..d6ec346e70 100644 --- a/.github/workflows/ms.keyvault.vaults.yml +++ b/.github/workflows/ms.keyvault.vaults.yml @@ -86,10 +86,10 @@ jobs: runs-on: ubuntu-latest needs: - job_initialize_pipeline - strategy: - fail-fast: false - matrix: - moduleTestFilePaths: ${{ fromJSON(needs.job_initialize_pipeline.outputs.moduleTestFilePaths) }} + # strategy: + # fail-fast: false + # matrix: + # moduleTestFilePaths: ${{ fromJSON(needs.job_initialize_pipeline.outputs.moduleTestFilePaths) }} steps: - name: Checkout uses: actions/checkout@v3 @@ -97,54 +97,54 @@ jobs: uses: ./.github/actions/templates/setEnvironmentVariables with: variablesPath: ${{ env.variablesPath }} - - name: 'Replace tokens in template file' - uses: azure/powershell@v1 - with: - azPSVersion: 'latest' - inlineScript: | - $templateFilePath = '${{ env.modulePath }}/${{ matrix.moduleTestFilePaths }}' - # Grouping task logs - Write-Output '::group::Replace tokens in template file' - - # Load used functions - . (Join-Path $env:GITHUB_WORKSPACE 'utilities' 'pipelines' 'tokensReplacement' 'Convert-TokensInFileList.ps1') - - # Populate tokens - $Tokens = @{ - resourceGroupName = '${{ env.resourceGroupName }}' - subscriptionId = '${{ secrets.ARM_SUBSCRIPTION_ID }}' - managementGroupId = '${{ secrets.ARM_MGMTGROUP_ID }}' - tenantId = '${{ env.ARM_TENANT_ID }}' - } - - ## Add local (source control) tokens - $tokenMap = @{} - foreach ($token in (Get-ChildItem env: | Where-Object -Property Name -Like "localToken_*")) { - $tokenMap += @{ $token.Name.Replace('localToken_','','OrdinalIgnoreCase') = $token.value } - } - Write-Verbose ('Using local tokens [{0}]' -f ($tokenMap.Keys -join ', ')) -Verbose - $Tokens += $tokenMap - - ## Swap 'namePrefix' token if empty and provided as a GitHub secret - if([String]::IsNullOrEmpty($Tokens['namePrefix'])){ - Write-Verbose 'Using [namePrefix] token from GitHub' -Verbose - $Tokens['namePrefix'] = '${{ env.TOKEN_NAMEPREFIX }}' - } - - # Construct Token Function Input - $ConvertTokensInputs = @{ - FilePathList = @($templateFilePath) - Tokens = $Tokens - TokenPrefix = '${{ env.tokenPrefix }}' - TokenSuffix = '${{ env.tokenSuffix }}' - } - - Write-Verbose "Convert Tokens Input:`n $($ConvertTokensInputs | ConvertTo-Json -Depth 10)" -Verbose - - # Invoke Token Replacement Functionality [For Module] - $null = Convert-TokensInFileList @ConvertTokensInputs - - Write-Output '::endgroup::' + # - name: 'Replace tokens in template file' + # uses: azure/powershell@v1 + # with: + # azPSVersion: 'latest' + # inlineScript: | + # $templateFilePath = '${{ env.modulePath }}/${{ matrix.moduleTestFilePaths }}' + # # Grouping task logs + # Write-Output '::group::Replace tokens in template file' + + # # Load used functions + # . (Join-Path $env:GITHUB_WORKSPACE 'utilities' 'pipelines' 'tokensReplacement' 'Convert-TokensInFileList.ps1') + + # # Populate tokens + # $Tokens = @{ + # resourceGroupName = '${{ env.resourceGroupName }}' + # subscriptionId = '${{ secrets.ARM_SUBSCRIPTION_ID }}' + # managementGroupId = '${{ secrets.ARM_MGMTGROUP_ID }}' + # tenantId = '${{ env.ARM_TENANT_ID }}' + # } + + # ## Add local (source control) tokens + # $tokenMap = @{} + # foreach ($token in (Get-ChildItem env: | Where-Object -Property Name -Like "localToken_*")) { + # $tokenMap += @{ $token.Name.Replace('localToken_','','OrdinalIgnoreCase') = $token.value } + # } + # Write-Verbose ('Using local tokens [{0}]' -f ($tokenMap.Keys -join ', ')) -Verbose + # $Tokens += $tokenMap + + # ## Swap 'namePrefix' token if empty and provided as a GitHub secret + # if([String]::IsNullOrEmpty($Tokens['namePrefix'])){ + # Write-Verbose 'Using [namePrefix] token from GitHub' -Verbose + # $Tokens['namePrefix'] = '${{ env.TOKEN_NAMEPREFIX }}' + # } + + # # Construct Token Function Input + # $ConvertTokensInputs = @{ + # FilePathList = @($templateFilePath) + # Tokens = $Tokens + # TokenPrefix = '${{ env.tokenPrefix }}' + # TokenSuffix = '${{ env.tokenSuffix }}' + # } + + # Write-Verbose "Convert Tokens Input:`n $($ConvertTokensInputs | ConvertTo-Json -Depth 10)" -Verbose + + # # Invoke Token Replacement Functionality [For Module] + # $null = Convert-TokensInFileList @ConvertTokensInputs + + # Write-Output '::endgroup::' # Run analysis by using the PSRule GitHub action. - name: Run PSRule analysis @@ -152,7 +152,17 @@ jobs: # continue-on-error: true # Setting this whilst PSRule gets bedded in, in this project with: modules: 'PSRule.Rules.Azure' - inputPath: '${{ env.modulePath }}/${{ matrix.moduleTestFilePaths }}' + inputPath: '${{ env.modulePath }}/' + outputFormat: Csv + outputPath: '${{ env.modulePath }}-output.csv' + + - name: Output to Github Logs + if: always() + run: cat '${{ env.modulePath }}-output.csv' + + - name: Output to Github summaries + if: always() + run: cat '${{ env.modulePath }}-output.csv' >> $GITHUB_STEP_SUMMARY # ############################# # # Deployment validation # diff --git a/ps-rule.yaml b/ps-rule.yaml index 151c9a2173..0a1e9f91b7 100644 --- a/ps-rule.yaml +++ b/ps-rule.yaml @@ -23,9 +23,14 @@ include: module: - PSRule.Rules.Azure +execution: + suppressedRuleWarning: false + output: culture: - 'en-US' + outcome: 'All' + #as: 'Summary' input: @@ -58,6 +63,6 @@ rule: - Azure.KeyVault.PurgeProtect # Suppression ignores rules for a specific Azure resource by name. -suppression: - Azure.Resource.UseTags: - - <>kvvmin001 +# suppression: +# Azure.Resource.UseTags: +# - <>kvvmin001