Skip to content
Merged
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
97 changes: 97 additions & 0 deletions .github/workflows/trivy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Trivy Security Scan
on:
pull_request:
paths:
- 'terraform/**'
- '.github/workflows/trivy.yaml'
push:
branches:
- main
paths:
- 'terraform/**'
- '.github/workflows/trivy.yaml'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
trivy-aws:
name: Trivy IaC Scan (AWS)

Check notice

Code scanning / SonarCloud

Write permissions should be defined at the job level Low

Move this write permission from workflow level to job level. See more on SonarQube Cloud
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Run Trivy scanner (table output)
uses: aquasecurity/trivy-action@57a97c7e7821a5776cebc9bb87c984fa69cba8f1 # v0.35.0
with:
scan-type: 'fs'
scan-ref: 'terraform/aws/modules/'
scanners: 'vuln,secret,misconfig'
ignore-unfixed: false
exit-code: '0'
format: 'table'
severity: 'CRITICAL,HIGH'

- name: Run Trivy scanner (SARIF output)
uses: aquasecurity/trivy-action@57a97c7e7821a5776cebc9bb87c984fa69cba8f1 # v0.35.0
with:
scan-type: 'fs'
scan-ref: 'terraform/aws/modules/'
scanners: 'vuln,secret,misconfig'
ignore-unfixed: false
exit-code: '0'
format: 'sarif'
output: 'trivy-aws-results.sarif'
severity: 'CRITICAL,HIGH'

- name: Upload AWS scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: 'trivy-aws-results.sarif'
category: 'trivy-iac-aws'

trivy-azure:
name: Trivy IaC Scan (Azure)
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Run Trivy scanner (table output)
uses: aquasecurity/trivy-action@57a97c7e7821a5776cebc9bb87c984fa69cba8f1 # v0.35.0
with:
scan-type: 'fs'
scan-ref: 'terraform/azure/modules/'
scanners: 'vuln,secret,misconfig'
ignore-unfixed: false
exit-code: '0'
format: 'table'
severity: 'CRITICAL,HIGH'

- name: Run Trivy scanner (SARIF output)
uses: aquasecurity/trivy-action@57a97c7e7821a5776cebc9bb87c984fa69cba8f1 # v0.35.0
with:
scan-type: 'fs'
scan-ref: 'terraform/azure/modules/'
scanners: 'vuln,secret,misconfig'
ignore-unfixed: false
exit-code: '0'
format: 'sarif'
output: 'trivy-azure-results.sarif'
severity: 'CRITICAL,HIGH'

- name: Upload Azure scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: 'trivy-azure-results.sarif'
category: 'trivy-iac-azure'
Loading