|
| 1 | +name: Trivy Image Scan (webapp) |
| 2 | + |
| 3 | +# Scheduled OS-level CVE drift scan of the published webapp image, pulled from |
| 4 | +# GHCR. The image is a heavy multi-stage build, so we scan the published |
| 5 | +# artifact rather than rebuilding per-PR. |
| 6 | +# |
| 7 | +# Report-only: writes a table to the job run summary. No SARIF upload, no PR |
| 8 | +# gate (for now). Library/dependency CVEs are covered by Dependabot; this scan |
| 9 | +# is restricted to OS packages (`vuln-type: os`) so the two don't double-report. |
| 10 | + |
| 11 | +on: |
| 12 | + schedule: |
| 13 | + - cron: "0 6 * * 1" # Mondays 06:00 UTC |
| 14 | + workflow_dispatch: |
| 15 | + inputs: |
| 16 | + tag: |
| 17 | + description: "Image tag to scan (blank = newest stable vX.Y.Z)" |
| 18 | + required: false |
| 19 | + default: "" |
| 20 | + |
| 21 | +permissions: {} |
| 22 | + |
| 23 | +concurrency: |
| 24 | + group: trivy-image-webapp |
| 25 | + cancel-in-progress: true |
| 26 | + |
| 27 | +jobs: |
| 28 | + scan: |
| 29 | + name: Scan |
| 30 | + runs-on: ubuntu-latest |
| 31 | + steps: |
| 32 | + - name: Resolve image tag |
| 33 | + id: resolve |
| 34 | + env: |
| 35 | + INPUT_TAG: ${{ github.event.inputs.tag }} |
| 36 | + run: | |
| 37 | + set -euo pipefail |
| 38 | + if [ -n "$INPUT_TAG" ]; then |
| 39 | + tag="$INPUT_TAG" |
| 40 | + else |
| 41 | + # Newest stable release tag (exclude -rc/-beta). Public GHCR repo, |
| 42 | + # so an anonymous pull token is enough to list tags. |
| 43 | + token="$(curl -fsSL "https://ghcr.io/token?scope=repository:triggerdotdev/trigger.dev:pull" | jq -r .token)" |
| 44 | + tag="$(curl -fsSL -H "Authorization: Bearer $token" \ |
| 45 | + "https://ghcr.io/v2/triggerdotdev/trigger.dev/tags/list?n=1000" \ |
| 46 | + | jq -r '.tags[]' \ |
| 47 | + | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -1)" |
| 48 | + fi |
| 49 | + if [ -z "$tag" ]; then |
| 50 | + echo "Could not resolve an image tag to scan" >&2 |
| 51 | + exit 1 |
| 52 | + fi |
| 53 | + echo "tag=$tag" >> "$GITHUB_OUTPUT" |
| 54 | + echo "Scanning ghcr.io/triggerdotdev/trigger.dev:$tag" |
| 55 | +
|
| 56 | + - name: Run Trivy image scan |
| 57 | + uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0 |
| 58 | + with: |
| 59 | + scan-type: image |
| 60 | + image-ref: ghcr.io/triggerdotdev/trigger.dev:${{ steps.resolve.outputs.tag }} |
| 61 | + # vuln-type maps to --pkg-types: OS packages only (library deps are |
| 62 | + # Dependabot's job). ignore-unfixed drops vulns with no patch yet. |
| 63 | + vuln-type: os |
| 64 | + ignore-unfixed: true |
| 65 | + severity: HIGH,CRITICAL |
| 66 | + format: table |
| 67 | + output: trivy-image-webapp.txt |
| 68 | + |
| 69 | + - name: Job summary |
| 70 | + if: always() |
| 71 | + env: |
| 72 | + TAG: ${{ steps.resolve.outputs.tag }} |
| 73 | + run: | |
| 74 | + { |
| 75 | + echo "## Trivy Image Scan (webapp) — \`${TAG:-unknown}\`" |
| 76 | + echo '```' |
| 77 | + # GitHub step summary is capped at 1 MiB; truncate large reports. |
| 78 | + head -c 900000 trivy-image-webapp.txt 2>/dev/null || echo "(no report produced)" |
| 79 | + echo '```' |
| 80 | + } >> "$GITHUB_STEP_SUMMARY" |
0 commit comments