|
| 1 | +name: Trivy Image Scan (webapp) |
| 2 | + |
| 3 | +# OS-level CVE scan of a published webapp image. Called by the publish pipeline |
| 4 | +# (publish.yml) to scan each build right after it's pushed to GHCR — so every |
| 5 | +# main build and every release is scanned, not rebuilt. Also runnable ad-hoc |
| 6 | +# via workflow_dispatch against any image ref. |
| 7 | +# |
| 8 | +# Report-only: writes a table to the run summary. No SARIF upload, no gate. |
| 9 | +# Library/dependency CVEs are covered by Dependabot, so this is restricted to |
| 10 | +# OS packages (`vuln-type: os`) to avoid double-reporting. |
| 11 | + |
| 12 | +on: |
| 13 | + workflow_call: |
| 14 | + inputs: |
| 15 | + image-ref: |
| 16 | + description: "Full image ref to scan (e.g. ghcr.io/triggerdotdev/trigger.dev:main)" |
| 17 | + type: string |
| 18 | + required: true |
| 19 | + workflow_dispatch: |
| 20 | + inputs: |
| 21 | + image-ref: |
| 22 | + description: "Full image ref to scan" |
| 23 | + type: string |
| 24 | + required: false |
| 25 | + default: "ghcr.io/triggerdotdev/trigger.dev:main" |
| 26 | + |
| 27 | +permissions: {} |
| 28 | + |
| 29 | +concurrency: |
| 30 | + group: trivy-image-webapp-${{ inputs.image-ref }} |
| 31 | + cancel-in-progress: true |
| 32 | + |
| 33 | +jobs: |
| 34 | + scan: |
| 35 | + name: Scan |
| 36 | + runs-on: ubuntu-latest |
| 37 | + permissions: |
| 38 | + contents: read |
| 39 | + packages: read # pull the image from GHCR |
| 40 | + steps: |
| 41 | + - name: Run Trivy image scan |
| 42 | + uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0 |
| 43 | + with: |
| 44 | + scan-type: image |
| 45 | + image-ref: ${{ inputs.image-ref }} |
| 46 | + # vuln-type maps to --pkg-types: OS packages only (library deps are |
| 47 | + # Dependabot's job). ignore-unfixed drops vulns with no patch yet. |
| 48 | + vuln-type: os |
| 49 | + ignore-unfixed: true |
| 50 | + severity: HIGH,CRITICAL |
| 51 | + format: table |
| 52 | + output: trivy-image-webapp.txt |
| 53 | + |
| 54 | + - name: Job summary |
| 55 | + if: always() |
| 56 | + env: |
| 57 | + IMAGE_REF: ${{ inputs.image-ref }} |
| 58 | + run: | |
| 59 | + { |
| 60 | + echo "## Trivy Image Scan (webapp) — \`${IMAGE_REF}\`" |
| 61 | + echo '```' |
| 62 | + # GitHub step summary is capped at 1 MiB; truncate large reports. |
| 63 | + head -c 900000 trivy-image-webapp.txt 2>/dev/null || echo "(no report produced)" |
| 64 | + echo '```' |
| 65 | + } >> "$GITHUB_STEP_SUMMARY" |
0 commit comments