Skip to content

Commit

Permalink
Merge pull request #91 from tonybaloney/psrule
Browse files Browse the repository at this point in the history
Use PSRule for security audits instead of template analyser
  • Loading branch information
brunoborges authored Jul 11, 2024
2 parents f4d708e + 469b53f commit b20eec5
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 18 deletions.
27 changes: 17 additions & 10 deletions .github/workflows/infra-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,27 @@ jobs:
uses: azure/CLI@v1
with:
inlineScript: az config set bicep.use_binary_from_path=false && az bicep build -f deploy/aca/infra/main.bicep --stdout

- name: Run Microsoft Security DevOps Analysis
uses: microsoft/security-devops-action@v1
id: msdo
continue-on-error: true

- name: Run PSRule analysis on App Service deployment
uses: microsoft/[email protected]
with:
tools: templateanalyzer
modules: PSRule.Rules.Azure
baseline: Azure.Pillar.Security
inputPath: deploy/app-service/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@v2
- name: Upload results to security tab
uses: github/codeql-action/upload-sarif@v3
if: github.repository == 'Azure-Samples/azure-search-openai-demo-java'
with:
sarif_file: ${{ steps.msdo.outputs.sarifFile }}

sarif_file: reports/ps-rule-results.sarif

# deploy:
# name: "Deploy Infra and App using azd"
Expand Down
24 changes: 16 additions & 8 deletions .github/workflows/nightly-jobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,26 @@ jobs:
with:
inlineScript: az config set bicep.use_binary_from_path=false && az bicep build -f deploy/aca/infra/main.bicep --stdout

- name: Run Microsoft Security DevOps Analysis
uses: microsoft/security-devops-action@v1
id: msdo
continue-on-error: true
- name: Run PSRule analysis on App Service deployment
uses: microsoft/[email protected]
with:
tools: templateanalyzer
modules: PSRule.Rules.Azure
baseline: Azure.Pillar.Security
inputPath: deploy/app-service/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@v2
- name: Upload results to security tab
uses: github/codeql-action/upload-sarif@v3
if: github.repository == 'Azure-Samples/azure-search-openai-demo-java'
with:
sarif_file: ${{ steps.msdo.outputs.sarifFile }}
sarif_file: reports/ps-rule-results.sarif

frontend:
name: "Front-end validation"
Expand Down
27 changes: 27 additions & 0 deletions deploy/app-service/infra/main.test.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// This file is for doing static analysis and contains sensible defaults
// for PSRule 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 = 'swedencentral'

module main 'main.bicep' = {
name: 'main'
params: {
environmentName: environmentName
location: location
openAiHost: 'azure'
openAiResourceGroupLocation: location
searchIndexName: 'gptkbindex'
searchQueryLanguage: 'en-us'
searchQuerySpeller: 'lexicon'
searchServiceSkuName: 'standard'
storageSkuName: 'Standard_LRS'
useApplicationInsights: false
chatGptDeploymentName: 'chat'
embeddingDeploymentName: 'embedding'
}
}
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 b20eec5

Please sign in to comment.