Skip to content

Commit 3bd92fb

Browse files
Switch to PSRule for security testing (#1687)
* Try using PSRule for security testing * configure expansion * reformat envvar * Add rule file * Try another approach * Only security baseline results * continue on error * Test the secure configuration * Remove template analyser * Update ps-rule.yaml * Update infra/main.test.bicep Co-authored-by: Pamela Fox <[email protected]> --------- Co-authored-by: Pamela Fox <[email protected]>
1 parent dd7c1d2 commit 3bd92fb

File tree

3 files changed

+67
-8
lines changed

3 files changed

+67
-8
lines changed

.github/workflows/azure-dev-validation.yaml

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
workflow_dispatch:
1212

1313
jobs:
14-
build:
14+
bicep:
1515
runs-on: ubuntu-latest
1616
permissions:
1717
security-events: write
@@ -24,15 +24,31 @@ jobs:
2424
with:
2525
inlineScript: az config set bicep.use_binary_from_path=false && az bicep build -f infra/main.bicep --stdout
2626

27-
- name: Run Microsoft Security DevOps Analysis
28-
uses: microsoft/security-devops-action@preview
29-
id: msdo
30-
continue-on-error: true
27+
psrule:
28+
runs-on: ubuntu-latest
29+
permissions:
30+
security-events: write
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
35+
- name: Run PSRule analysis
36+
uses: microsoft/[email protected]
3137
with:
32-
tools: templateanalyzer
38+
modules: PSRule.Rules.Azure
39+
baseline: Azure.Pillar.Security
40+
inputPath: infra/*.test.bicep
41+
outputFormat: Sarif
42+
outputPath: reports/ps-rule-results.sarif
43+
summary: true
44+
continue-on-error: true
45+
46+
env:
47+
PSRULE_CONFIGURATION_AZURE_BICEP_FILE_EXPANSION: 'true'
48+
PSRULE_CONFIGURATION_AZURE_BICEP_FILE_EXPANSION_TIMEOUT: '30'
3349

34-
- name: Upload alerts to Security tab
50+
- name: Upload results to security tab
3551
uses: github/codeql-action/upload-sarif@v3
3652
if: github.repository == 'Azure-Samples/azure-search-openai-demo'
3753
with:
38-
sarif_file: ${{ steps.msdo.outputs.sarifFile }}
54+
sarif_file: reports/ps-rule-results.sarif

infra/main.test.bicep

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// This file is for doing static analysis and contains sensible defaults
2+
// for PSRule 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 = 'swedencentral'
10+
11+
module main 'main.bicep' = {
12+
name: 'main'
13+
params: {
14+
environmentName: environmentName
15+
location: location
16+
appServiceSkuName: 'B1'
17+
computerVisionSkuName: 'S1'
18+
documentIntelligenceResourceGroupLocation: location
19+
documentIntelligenceSkuName: 'S0'
20+
openAiHost: 'azure'
21+
openAiResourceGroupLocation: location
22+
searchIndexName: 'gptkbindex'
23+
searchQueryLanguage: 'en-us'
24+
searchQuerySpeller: 'lexicon'
25+
searchServiceSemanticRankerLevel: 'free'
26+
searchServiceSkuName: 'standard'
27+
speechServiceSkuName: 'S0'
28+
storageSkuName: 'Standard_LRS'
29+
useApplicationInsights: false
30+
useVectors: true
31+
useGPT4V: false
32+
useSpeechInputBrowser: false
33+
useSpeechOutputBrowser: false
34+
35+
// Test the secure configuration
36+
enableUnauthenticatedAccess: false
37+
usePrivateEndpoint: true
38+
publicNetworkAccess: 'Disabled'
39+
}
40+
}

ps-rule.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# YAML: Set the AZURE_BICEP_FILE_EXPANSION configuration option to enable expansion
2+
configuration:
3+
AZURE_BICEP_FILE_EXPANSION: true

0 commit comments

Comments
 (0)