From d83a01c2d4e0b07542b69ed65386310ffc50146d Mon Sep 17 00:00:00 2001 From: Elisa Anzelmo Date: Wed, 21 Sep 2022 12:06:03 +0200 Subject: [PATCH 1/8] kv summart csv no outcome --- .github/workflows/ms.keyvault.vaults.yml | 108 ++++++++++++----------- ps-rule.yaml | 7 +- 2 files changed, 59 insertions(+), 56 deletions(-) diff --git a/.github/workflows/ms.keyvault.vaults.yml b/.github/workflows/ms.keyvault.vaults.yml index ece5a08f75..4b824aa835 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,9 @@ 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 }}-outputsummary.csv' # ############################# # # Deployment validation # diff --git a/ps-rule.yaml b/ps-rule.yaml index 151c9a2173..12acc708fd 100644 --- a/ps-rule.yaml +++ b/ps-rule.yaml @@ -26,6 +26,7 @@ include: output: culture: - 'en-US' + as: 'Summary' input: @@ -58,6 +59,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 From 19c47ba9b267a35a7f5a1743804550e9ce4a20b2 Mon Sep 17 00:00:00 2001 From: Elisa Anzelmo Date: Wed, 21 Sep 2022 12:09:29 +0200 Subject: [PATCH 2/8] print summary --- .github/workflows/ms.keyvault.vaults.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/ms.keyvault.vaults.yml b/.github/workflows/ms.keyvault.vaults.yml index 4b824aa835..1916b3bb9c 100644 --- a/.github/workflows/ms.keyvault.vaults.yml +++ b/.github/workflows/ms.keyvault.vaults.yml @@ -156,6 +156,14 @@ jobs: outputFormat: Csv outputPath: '${{ env.modulePath }}-outputsummary.csv' + - name: Output to Github Logs + if: always() + run: cat '${{ env.modulePath }}-outputsummary.csv' + + - name: Output to Github summaries + if: always() + run: cat '${{ env.modulePath }}-outputsummary.csv' >> $GITHUB_STEP_SUMMARY + # ############################# # # Deployment validation # # ############################# From 8fca4396dbb14d7e83115f882bc3777971feed39 Mon Sep 17 00:00:00 2001 From: Elisa Anzelmo Date: Wed, 21 Sep 2022 12:16:31 +0200 Subject: [PATCH 3/8] outcome all, format csv as summary --- ps-rule.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/ps-rule.yaml b/ps-rule.yaml index 12acc708fd..dc4ad10f4a 100644 --- a/ps-rule.yaml +++ b/ps-rule.yaml @@ -26,6 +26,7 @@ include: output: culture: - 'en-US' + outcome: 'All' as: 'Summary' From 33034a522044fb58a5f7d3278c6af609fb1351cf Mon Sep 17 00:00:00 2001 From: Elisa Anzelmo Date: Wed, 21 Sep 2022 12:23:34 +0200 Subject: [PATCH 4/8] csv detailed all --- .github/workflows/ms.keyvault.vaults.yml | 6 +++--- ps-rule.yaml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ms.keyvault.vaults.yml b/.github/workflows/ms.keyvault.vaults.yml index 1916b3bb9c..d6ec346e70 100644 --- a/.github/workflows/ms.keyvault.vaults.yml +++ b/.github/workflows/ms.keyvault.vaults.yml @@ -154,15 +154,15 @@ jobs: modules: 'PSRule.Rules.Azure' inputPath: '${{ env.modulePath }}/' outputFormat: Csv - outputPath: '${{ env.modulePath }}-outputsummary.csv' + outputPath: '${{ env.modulePath }}-output.csv' - name: Output to Github Logs if: always() - run: cat '${{ env.modulePath }}-outputsummary.csv' + run: cat '${{ env.modulePath }}-output.csv' - name: Output to Github summaries if: always() - run: cat '${{ env.modulePath }}-outputsummary.csv' >> $GITHUB_STEP_SUMMARY + run: cat '${{ env.modulePath }}-output.csv' >> $GITHUB_STEP_SUMMARY # ############################# # # Deployment validation # diff --git a/ps-rule.yaml b/ps-rule.yaml index dc4ad10f4a..1b2a63b635 100644 --- a/ps-rule.yaml +++ b/ps-rule.yaml @@ -27,7 +27,7 @@ output: culture: - 'en-US' outcome: 'All' - as: 'Summary' + #as: 'Summary' input: From 3fa4f210014fcc0c12883b3aa78638b3d3bb476b Mon Sep 17 00:00:00 2001 From: Elisa Anzelmo Date: Wed, 21 Sep 2022 12:28:28 +0200 Subject: [PATCH 5/8] csv all detail execution supresswaring --- ps-rule.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ps-rule.yaml b/ps-rule.yaml index 1b2a63b635..0a1e9f91b7 100644 --- a/ps-rule.yaml +++ b/ps-rule.yaml @@ -23,6 +23,9 @@ include: module: - PSRule.Rules.Azure +execution: + suppressedRuleWarning: false + output: culture: - 'en-US' From 048e4ebb3a6cb10c43ca3ce9fe68cb18637c439b Mon Sep 17 00:00:00 2001 From: Elisa Anzelmo Date: Wed, 21 Sep 2022 12:54:20 +0200 Subject: [PATCH 6/8] rull.pass log information --- ps-rule.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ps-rule.yaml b/ps-rule.yaml index 0a1e9f91b7..a1dc051890 100644 --- a/ps-rule.yaml +++ b/ps-rule.yaml @@ -26,10 +26,13 @@ include: execution: suppressedRuleWarning: false +logging: + rulePass: Information + output: culture: - 'en-US' - outcome: 'All' + #outcome: 'All' #as: 'Summary' From d37364a98005856ea765dcde3f814a8efb81c415 Mon Sep 17 00:00:00 2001 From: Elisa Anzelmo Date: Wed, 21 Sep 2022 13:21:21 +0200 Subject: [PATCH 7/8] empty options with summary on --- .github/workflows/ms.keyvault.vaults.yml | 16 ++++++++-------- ps-rule.yaml | 5 +---- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ms.keyvault.vaults.yml b/.github/workflows/ms.keyvault.vaults.yml index d6ec346e70..e329d6aa42 100644 --- a/.github/workflows/ms.keyvault.vaults.yml +++ b/.github/workflows/ms.keyvault.vaults.yml @@ -153,16 +153,16 @@ jobs: with: modules: 'PSRule.Rules.Azure' inputPath: '${{ env.modulePath }}/' - outputFormat: Csv - outputPath: '${{ env.modulePath }}-output.csv' + # outputFormat: Csv + # outputPath: '${{ env.modulePath }}-output.csv' - - name: Output to Github Logs - if: always() - run: cat '${{ 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 + # - 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 a1dc051890..8383458786 100644 --- a/ps-rule.yaml +++ b/ps-rule.yaml @@ -26,14 +26,11 @@ include: execution: suppressedRuleWarning: false -logging: - rulePass: Information - output: culture: - 'en-US' #outcome: 'All' - #as: 'Summary' + as: 'Summary' input: From 815d655ea491e69ff13ff0fafd08c5a0ee270b18 Mon Sep 17 00:00:00 2001 From: Elisa Anzelmo Date: Wed, 21 Sep 2022 13:25:44 +0200 Subject: [PATCH 8/8] csv test --- .github/workflows/ms.keyvault.vaults.yml | 16 ++++++++-------- ps-rule.yaml | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ms.keyvault.vaults.yml b/.github/workflows/ms.keyvault.vaults.yml index e329d6aa42..d6ec346e70 100644 --- a/.github/workflows/ms.keyvault.vaults.yml +++ b/.github/workflows/ms.keyvault.vaults.yml @@ -153,16 +153,16 @@ jobs: with: modules: 'PSRule.Rules.Azure' inputPath: '${{ env.modulePath }}/' - # outputFormat: Csv - # outputPath: '${{ env.modulePath }}-output.csv' + outputFormat: Csv + outputPath: '${{ env.modulePath }}-output.csv' - # - name: Output to Github Logs - # if: always() - # run: cat '${{ 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 + - 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 8383458786..0a1e9f91b7 100644 --- a/ps-rule.yaml +++ b/ps-rule.yaml @@ -29,8 +29,8 @@ execution: output: culture: - 'en-US' - #outcome: 'All' - as: 'Summary' + outcome: 'All' + #as: 'Summary' input: