Skip to content

Commit 431b709

Browse files
authored
Move from template analyser to psrule for security audits (#133)
1 parent 565ef6e commit 431b709

File tree

3 files changed

+40
-10
lines changed

3 files changed

+40
-10
lines changed

.github/workflows/bicep-audit.yml

+18-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
name: Validate AZD template
1+
name: Validate bicep templates
22
on:
33
push:
44
branches:
55
- main
66
paths:
7-
- "infra/**"
7+
- "**/*.bicep"
88
pull_request:
99
branches:
1010
- main
1111
paths:
12-
- "infra/**"
12+
- "**/*.bicep"
1313
workflow_dispatch:
1414

1515
jobs:
@@ -21,15 +21,23 @@ jobs:
2121
- name: Checkout
2222
uses: actions/checkout@v4
2323

24-
- name: Run Microsoft Security DevOps Analysis
25-
uses: microsoft/security-devops-action@preview
26-
id: msdo
27-
continue-on-error: true
24+
- name: Run PSRule analysis
25+
uses: microsoft/[email protected]
2826
with:
29-
tools: templateanalyzer
27+
modules: PSRule.Rules.Azure
28+
baseline: Azure.Pillar.Security
29+
inputPath: infra/*.test.bicep
30+
outputFormat: Sarif
31+
outputPath: reports/ps-rule-results.sarif
32+
summary: true
33+
continue-on-error: true
34+
35+
env:
36+
PSRULE_CONFIGURATION_AZURE_BICEP_FILE_EXPANSION: 'true'
37+
PSRULE_CONFIGURATION_AZURE_BICEP_FILE_EXPANSION_TIMEOUT: '30'
3038

31-
- name: Upload alerts to Security tab
39+
- name: Upload results to security tab
3240
uses: github/codeql-action/upload-sarif@v3
3341
if: github.repository_owner == 'Azure-Samples'
3442
with:
35-
sarif_file: ${{ steps.msdo.outputs.sarifFile }}
43+
sarif_file: reports/ps-rule-results.sarif

infra/main.test.bicep

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// This file is for doing static analysis and contains sensible defaults
2+
// for the bicep analyser to minimise false-positives and provide the best results.
3+
4+
// This file is not intended to be used as a runtime configuration file.
5+
6+
targetScope = 'subscription'
7+
8+
param environmentName string = 'testing'
9+
param location string = 'westus2'
10+
11+
module main 'main.bicep' = {
12+
name: 'main'
13+
params: {
14+
environmentName: environmentName
15+
location: location
16+
}
17+
}

ps-rule.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# YAML: Set the AZURE_BICEP_FILE_EXPANSION configuration option to enable expansion
2+
configuration:
3+
AZURE_BICEP_FILE_EXPANSION: true
4+
AZURE_DEPLOYMENT_NONSENSITIVE_PARAMETER_NAMES:
5+
- resourceToken

0 commit comments

Comments
 (0)