Skip to content

Commit

Permalink
Use PSRule for scanning
Browse files Browse the repository at this point in the history
  • Loading branch information
tonybaloney committed Jun 5, 2024
1 parent 09aaabf commit aeb5a71
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .cruft.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"template": "https://github.com/Azure-Samples/Azure-Python-Standardization-Template-Generator",
"commit": "ff59b9db5cb475015804edbbab7ecb817a81bf77",
"commit": "75d8c04bda1e75ae989198d933a785ca153bd891",
"checkout": null,
"context": {
"cookiecutter": {
Expand Down
21 changes: 14 additions & 7 deletions .github/workflows/audit-bicep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,23 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Run Microsoft Security DevOps Analysis
uses: microsoft/security-devops-action@preview
id: msdo
continue-on-error: true
- name: Run PSRule analysis
uses: microsoft/[email protected]
with:
tools: templateanalyzer
modules: PSRule.Rules.Azure
baseline: Azure.Pillar.Security
inputPath: infra/*.test.bicep
outputFormat: Sarif
outputPath: reports/ps-rule-results.sarif
summary: true
continue-on-error: true

env:
PSRULE_CONFIGURATION_AZURE_BICEP_FILE_EXPANSION: 'true'
PSRULE_CONFIGURATION_AZURE_BICEP_FILE_EXPANSION_TIMEOUT: '30'

- name: Upload alerts to Security tab
uses: github/codeql-action/upload-sarif@v3
if: github.repository_owner == 'Azure-Samples'
with:

sarif_file: ${{ steps.msdo.outputs.sarifFile }}
sarif_file: reports/ps-rule-results.sarif
26 changes: 26 additions & 0 deletions infra/main.test.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// This file is for doing static analysis and contains sensible defaults
// for the template analyser to minimise false-positives and provide the best results.

// This file is not intended to be used as a runtime configuration file.

targetScope = 'subscription'

param environmentName string = 'testing'
param location string = 'westus2'

@secure()
param dbserverPassword string = newGuid()

@secure()
param secretKey string = newGuid()

module main 'main.bicep' = {
name: 'main'
params: {
name: environmentName
location: location
// These are used for static analysis and never deployed
dbserverPassword: dbserverPassword
secretKey: secretKey
}
}
3 changes: 3 additions & 0 deletions ps-rule.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# YAML: Set the AZURE_BICEP_FILE_EXPANSION configuration option to enable expansion
configuration:
AZURE_BICEP_FILE_EXPANSION: true

0 comments on commit aeb5a71

Please sign in to comment.