From b49ffd8127caba17da7ec03e324f6d675605d4e8 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 12 Nov 2026 22:01:58 +0000 Subject: [PATCH] Add Trivy vulnerability scan to PR checks Scan the freshly built amd64 image. Report fixable HIGH+ findings in the job log and fail the PR only on fixable CRITICAL, so an upstream HIGH disclosure does not block unrelated PRs. Suppressions go in .trivyignore with a justification and expiry. The action is pinned by commit SHA. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_014iDTyB5N8EdZyyZo4ymUVR --- .github/workflows/pr.yml | 25 +++++++++++++++++++++++++ .trivyignore | 3 +++ 2 files changed, 28 insertions(+) create mode 100644 .trivyignore diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index caac62d..ca80354 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -9,6 +9,7 @@ on: - motd.txt - scripts/** - .hadolint.yaml + - .trivyignore - .github/workflows/** concurrency: @@ -64,3 +65,27 @@ jobs: - name: Smoke test run: scripts/smoke-test.sh k8s-debug:pr + + # Vulnerability scan (the vulnerability DB is arch independent, so one + # arch is enough). Report everything fixable at HIGH+, but only block the + # PR on fixable CRITICAL so an upstream HIGH disclosure cannot wedge + # unrelated PRs. Add justified exceptions to .trivyignore. + - name: Trivy report (HIGH+, fixable) + if: matrix.arch == 'amd64' + uses: aquasecurity/trivy-action@a9c7b0f06e461e9d4b4d1711f154ee024b8d7ab8 # v0.36.0 + with: + image-ref: k8s-debug:pr + severity: HIGH,CRITICAL + ignore-unfixed: true + exit-code: "0" + trivyignores: .trivyignore + + - name: Trivy gate (CRITICAL, fixable) + if: matrix.arch == 'amd64' + uses: aquasecurity/trivy-action@a9c7b0f06e461e9d4b4d1711f154ee024b8d7ab8 # v0.36.0 + with: + image-ref: k8s-debug:pr + severity: CRITICAL + ignore-unfixed: true + exit-code: "1" + trivyignores: .trivyignore diff --git a/.trivyignore b/.trivyignore new file mode 100644 index 0000000..452a742 --- /dev/null +++ b/.trivyignore @@ -0,0 +1,3 @@ +# Trivy exceptions. One CVE id per line, each with a justification and an +# expiry date so that suppressions do not live forever, e.g. +# CVE-2025-12345 exp:2026-12-31 # no fix upstream; not reachable (reason)