Security #57
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ============================================================================== | |
| # Security Pipeline | |
| # Runs container image vulnerability scanning. | |
| # ============================================================================== | |
| name: Security | |
| # ------------------------------------------------------------------------------ | |
| # Triggers | |
| # ------------------------------------------------------------------------------ | |
| on: | |
| push: | |
| branches: ["main"] | |
| pull_request: | |
| branches: ["main"] | |
| schedule: | |
| - cron: "30 1 * * 0" # Weekly on Sunday at 01:30 UTC | |
| # ------------------------------------------------------------------------------ | |
| # Concurrency | |
| # ------------------------------------------------------------------------------ | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| # ------------------------------------------------------------------------------ | |
| # Permissions | |
| # ------------------------------------------------------------------------------ | |
| permissions: | |
| contents: read | |
| security-events: write | |
| # ------------------------------------------------------------------------------ | |
| # Jobs | |
| # ------------------------------------------------------------------------------ | |
| jobs: | |
| # ---------------------------------------------------------------------------- | |
| # Trivy - Container image vulnerability scanning | |
| # Scans the image built from this repository's Dockerfile | |
| # (includes base image + installed OS packages + app dependencies) | |
| # ---------------------------------------------------------------------------- | |
| trivy-image: | |
| name: Trivy Image Scan | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Source | |
| uses: actions/checkout@v6 | |
| - name: Set image name | |
| id: image | |
| run: echo "name=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build Docker image (local) | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| load: true | |
| tags: ${{ steps.image.outputs.name }}:scan | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Run Trivy vulnerability scanner | |
| uses: aquasecurity/trivy-action@master | |
| with: | |
| image-ref: "${{ steps.image.outputs.name }}:scan" | |
| format: "sarif" | |
| output: "trivy-results.sarif" | |
| ignore-unfixed: true | |
| vuln-type: "os,library" | |
| severity: "CRITICAL,HIGH" | |
| - name: Upload Trivy results to GitHub Security tab | |
| uses: github/codeql-action/upload-sarif@v4 | |
| with: | |
| sarif_file: "trivy-results.sarif" | |
| category: "trivy-container" |