|
| 1 | +name: Trivy Container Scan |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + |
| 6 | +jobs: |
| 7 | + scan-containers: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + timeout-minutes: 60 |
| 10 | + strategy: |
| 11 | + fail-fast: false |
| 12 | + matrix: |
| 13 | + include: |
| 14 | + - image: cas-reg-backend |
| 15 | + category: trivy-container-backend |
| 16 | + - image: cas-reg-frontend |
| 17 | + category: trivy-container-registration |
| 18 | + - image: cas-admin-frontend |
| 19 | + category: trivy-container-administration |
| 20 | + - image: cas-compliance-frontend |
| 21 | + category: trivy-container-compliance |
| 22 | + - image: cas-dash-frontend |
| 23 | + category: trivy-container-dashboard |
| 24 | + - image: cas-rep-frontend |
| 25 | + category: trivy-container-reporting |
| 26 | + steps: |
| 27 | + - name: Checkout code |
| 28 | + uses: actions/checkout@v6 |
| 29 | + - name: Cache Scan Dependencies |
| 30 | + uses: actions/cache@v4 |
| 31 | + with: |
| 32 | + path: ~/.cache/trivy |
| 33 | + key: callee-trivy-${{ github.workflow }}-${{ github.run_id }} |
| 34 | + restore-keys: callee-trivy-${{ github.workflow }}- |
| 35 | + - name: Run Trivy vulnerability scanner on container image |
| 36 | + uses: aquasecurity/trivy-action@57a97c7e7821a5776cebc9bb87c984fa69cba8f1 # v0.35.0 |
| 37 | + with: |
| 38 | + scan-type: image |
| 39 | + image-ref: ghcr.io/bcgov/${{ matrix.image }}:${{ github.sha }} |
| 40 | + format: sarif |
| 41 | + output: trivy-container-results.sarif |
| 42 | + exit-code: "0" |
| 43 | + ignore-unfixed: false |
| 44 | + severity: CRITICAL,HIGH,MEDIUM |
| 45 | + timeout: 10m0s |
| 46 | + - name: Upload Trivy container scan results to GitHub Security tab |
| 47 | + uses: github/codeql-action/upload-sarif@v4 |
| 48 | + with: |
| 49 | + sarif_file: trivy-container-results.sarif |
| 50 | + category: ${{ matrix.category }} |
| 51 | + - name: Upload Trivy container scan results as artifact |
| 52 | + uses: actions/upload-artifact@v4 |
| 53 | + with: |
| 54 | + name: trivy-container-results-${{ matrix.image }} |
| 55 | + path: trivy-container-results.sarif |
0 commit comments