61 lines
1.6 KiB
YAML
61 lines
1.6 KiB
YAML
name: Docker Security Scan
|
|
|
|
on:
|
|
push:
|
|
branches: [ "main" ]
|
|
paths:
|
|
- 'Dockerfile'
|
|
- '.github/workflows/docker-security-scan.yml'
|
|
- 'mix.exs'
|
|
- 'mix.lock'
|
|
pull_request:
|
|
branches: [ "main" ]
|
|
paths:
|
|
- 'Dockerfile'
|
|
- '.github/workflows/docker-security-scan.yml'
|
|
- 'mix.exs'
|
|
- 'mix.lock'
|
|
schedule:
|
|
- cron: '0 0 * * 0' # Run weekly on Sundays at midnight
|
|
workflow_dispatch: # Allow manual triggers
|
|
|
|
jobs:
|
|
scan:
|
|
name: Security Scan
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
security-events: write
|
|
actions: read
|
|
packages: read
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Build Docker image
|
|
run: docker build -t aprs:${{ github.sha }} .
|
|
|
|
- name: Run Trivy vulnerability scanner
|
|
uses: aquasecurity/trivy-action@master
|
|
with:
|
|
image-ref: aprs:${{ github.sha }}
|
|
format: 'sarif'
|
|
output: 'trivy-results.sarif'
|
|
severity: 'CRITICAL,HIGH'
|
|
timeout: '10m'
|
|
scanners: 'vuln,config,secret'
|
|
|
|
- name: Upload Trivy scan results to GitHub Security tab
|
|
uses: github/codeql-action/upload-sarif@v3
|
|
if: always()
|
|
with:
|
|
sarif_file: 'trivy-results.sarif'
|
|
category: 'Trivy Scan'
|
|
|
|
- name: Fail on CRITICAL vulnerabilities
|
|
if: ${{ failure() }}
|
|
run: |
|
|
echo "Critical vulnerabilities found in the Docker image."
|
|
echo "Please review the scan results in the Security tab."
|
|
exit 1
|