Skip to content

Security Analysis

Security Analysis #76

Workflow file for this run

name: Security Analysis
on:
schedule:
# Run security scans daily at 2 AM UTC
- cron: '0 2 * * *'
push:
branches: [ main ]
paths:
- '.devcontainer/**'
- 'Dockerfile'
- '.github/workflows/security.yml'
pull_request:
branches: [ main ]
paths:
- '.devcontainer/**'
- 'Dockerfile'
- '.github/workflows/security.yml'
workflow_dispatch: # Allow manual trigger
permissions:
contents: read
security-events: write
jobs:
security-scan:
runs-on: ubuntu-latest
name: Security and SBOM Analysis
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install missing dependencies
run: sudo apt-get update && sudo apt-get install -y tcl
- name: Build Docker image for scanning
run: |
IMAGE_NAME="dev-template:${{ github.sha }}"
docker build -t "$IMAGE_NAME" .devcontainer/
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: '${{ env.IMAGE_NAME }}'
format: 'sarif'
output: 'trivy-results.sarif'
- 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-image-scan'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Generate SBOM
uses: anchore/sbom-action@v0
with:
image: '${{ env.IMAGE_NAME }}'
format: 'spdx-json'
output-file: 'sbom.spdx.json'
- name: Upload SBOM as artifact
uses: actions/upload-artifact@v4
with:
name: sbom-${{ github.sha }}
path: sbom.spdx.json
retention-days: 30
- name: Run Trivy filesystem scan
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: '.'
format: 'sarif'
output: 'trivy-fs-results.sarif'
- name: Upload filesystem scan results
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: 'trivy-fs-results.sarif'
category: 'trivy-filesystem-scan'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}