Skip to content

Use PSRule for testing #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions .github/workflows/bicep-audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,21 @@ jobs:
steps:
- 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

- name: Upload alerts to Security tab
modules: PSRule.Rules.Azure
baseline: Azure.Pillar.Security
inputPath: tests/
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: '60'
- name: Upload results 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
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
1 change: 1 addition & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The files in this folder are for the purposes of running PSRule analysis for security checks.
10 changes: 10 additions & 0 deletions tests/cloud-native/aks-arm64.test.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
targetScope = 'subscription'


module main '../../cloud-native/aks-arm64/main.bicep' = {
name: 'aks-arm64'
params: {
name: 'test-aks-arm64'
location: 'westus'
}
}
9 changes: 9 additions & 0 deletions tests/cloud-native/aks-azure-linux.test.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
targetScope = 'resourceGroup'


module main '../../cloud-native/aks-azure-linux/aks.bicep' = {
name: 'aks-azure-linux'
params: {
location: 'westus'
}
}
9 changes: 9 additions & 0 deletions tests/cloud-native/aks-bicep-k8s.test.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
targetScope = 'resourceGroup'


module main '../../cloud-native/aks-bicep-k8s/main.bicep' = {
name: 'aks-bicep'
params: {
location: 'westus'
}
}
9 changes: 9 additions & 0 deletions tests/cloud-native/aks-bicep-keda.test.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
targetScope = 'subscription'


module main01 '../../cloud-native/aks-bicep-keda/01-aks/main.bicep' = {
name: 'aks-01-bicep'
params: {
location: 'westus'
}
}
9 changes: 9 additions & 0 deletions tests/cloud-native/aks-bicep.test.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
targetScope = 'subscription'


module main '../../cloud-native/aks-bicep/01-aks/main.bicep' = {
name: 'aks-bicep'
params: {
location: 'westus'
}
}
11 changes: 11 additions & 0 deletions tests/cloud-native/aks-open-service-mesh.test.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
targetScope = 'subscription'


module main '../../cloud-native/aks-open-service-mesh/main.bicep' = {
name: 'aks-open-service-mesh'
params: {
name: 'testing'
userObjectId: '00000000-0000-0000-0000-000000000000'
location: 'westus'
}
}
12 changes: 12 additions & 0 deletions tests/cloud-native/aks-webapp-routing.test.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
targetScope = 'subscription'


module main '../../cloud-native/aks-webapp-routing/main.bicep' = {
name: 'aks-webapp-routing'
params: {
name: 'testing'
userObjectId: '00000000-0000-0000-0000-000000000000'
location: 'westus'
dnsName: 'testing.com'
}
}
9 changes: 9 additions & 0 deletions tests/cloud-native/containerapps.test.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
targetScope = 'subscription'


module main '../../cloud-native/containerapps-bicep/main.bicep' = {
name: 'containerapps-bicep'
params: {
location: 'westus'
}
}
10 changes: 10 additions & 0 deletions tests/linux/vm-flatcar-postgres.test.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
targetScope = 'subscription'


module main '../../linux/vm-flatcar-postgres/main.bicep' = {
name: 'vm-flatcar-postgres'
params: {
location: 'westus'
sshKey: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD'
}
}
10 changes: 10 additions & 0 deletions tests/linux/vm-mariner.test.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
targetScope = 'resourceGroup'


module main '../../linux/vm-mariner/vm.bicep' = {
name: 'vm-mariner'
params: {
location: 'westus'
sshKey: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD'
}
}
8 changes: 8 additions & 0 deletions tests/linux/vm-mastodon.test.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
targetScope = 'resourceGroup'


module main '../../linux/vm-mastodon/vm.bicep' = {
name: 'vm-mastodon'
params: {
}
}
9 changes: 9 additions & 0 deletions tests/linux/vm.test.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
targetScope = 'resourceGroup'


module main '../../linux/vm/vm.bicep' = {
name: 'linux-vm'
params: {
location: 'westus'
}
}
8 changes: 8 additions & 0 deletions tests/linux/vmss.test.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
targetScope = 'resourceGroup'


module main '../../linux/vmss/vmss.bicep' = {
name: 'vmss'
params: {
}
}