mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-12-04 00:06:39 +00:00
ci: scan windmill-ee-full and windmill-extra release images with Trivy
Every published release image is now scanned in CI: windmill-ee-full joins the scan_release_images matrix, and publish_extra.yml gets the same scan job for windmill-extra. scan_release_images now runs when a build failed, so a failed build_ee_full no longer skips the scans of the other images. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
9eda2e1c0c
commit
d7477e0025
@@ -405,10 +405,12 @@ jobs:
|
||||
|
||||
# Scans the digests this run built, never a tag: :main and :latest race with concurrent main
|
||||
# builds. Release artifacts are uploaded before the gate so a failing gate still publishes them.
|
||||
# Runs even if a build failed (build_ee_full fails on flaky downloads), so the images that were
|
||||
# published still get scanned; the entry of an image that was not built fails on its digest.
|
||||
scan_release_images:
|
||||
runs-on: ubicloud
|
||||
needs: [build, build_ee, build_slim, build_ee_slim]
|
||||
if: startsWith(github.ref, 'refs/tags/v') && github.event_name == 'push'
|
||||
needs: [build, build_ee, build_slim, build_ee_slim, build_ee_full]
|
||||
if: ${{ !cancelled() && startsWith(github.ref, 'refs/tags/v') && github.event_name == 'push' }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@@ -425,6 +427,9 @@ jobs:
|
||||
- image: windmill-ee-slim
|
||||
suffix: "-ee-slim"
|
||||
digest: ${{ needs.build_ee_slim.outputs.digest }}
|
||||
- image: windmill-ee-full
|
||||
suffix: "-ee-full"
|
||||
digest: ${{ needs.build_ee_full.outputs.digest }}
|
||||
env:
|
||||
# 0.69.3, pinned by digest so a republished tag cannot change what runs with release credentials.
|
||||
TRIVY_IMAGE: aquasec/trivy@sha256:bcc376de8d77cfe086a917230e818dc9f8528e3c852f7b1aff648949b6258d1c
|
||||
@@ -439,7 +444,14 @@ jobs:
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Image reference
|
||||
run: echo "IMAGE_REF=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}${{ matrix.suffix }}@${{ matrix.digest }}" >> "$GITHUB_ENV"
|
||||
env:
|
||||
DIGEST: ${{ matrix.digest }}
|
||||
run: |
|
||||
if [ -z "$DIGEST" ]; then
|
||||
echo "::error::no digest for ${{ matrix.image }}: its build job did not push an image in this run"
|
||||
exit 1
|
||||
fi
|
||||
echo "IMAGE_REF=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}${{ matrix.suffix }}@$DIGEST" >> "$GITHUB_ENV"
|
||||
|
||||
# The VEX must be built from an unfiltered scan: a statement covers only the CVEs listed in it.
|
||||
# amd64 only: both arches install the same package versions from the same sources.
|
||||
@@ -792,6 +804,8 @@ jobs:
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
|
||||
needs: [build_ee]
|
||||
runs-on: ubicloud
|
||||
outputs:
|
||||
digest: ${{ steps.docker_build.outputs.digest }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4.4.0
|
||||
|
||||
|
||||
@@ -143,6 +143,8 @@ jobs:
|
||||
# un-verifying the release; to republish a release, re-push its tag
|
||||
if: github.event_name == 'push' || !startsWith(github.ref, 'refs/tags/')
|
||||
runs-on: ubicloud-standard-8
|
||||
outputs:
|
||||
digest: ${{ steps.docker_build.outputs.digest }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4.4.0
|
||||
|
||||
@@ -191,3 +193,119 @@ jobs:
|
||||
with:
|
||||
image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
digest: ${{ steps.docker_build.outputs.digest }}
|
||||
|
||||
# The same scan, VEX, Scout report and gate as scan_release_images in docker-image.yml, whose
|
||||
# steps these are: keep the two in sync. A one-entry matrix so the steps can stay identical.
|
||||
scan_release_image:
|
||||
runs-on: ubicloud
|
||||
needs: [publish_extra]
|
||||
if: startsWith(github.ref, 'refs/tags/v') && github.event_name == 'push'
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- image: windmill-extra
|
||||
suffix: ""
|
||||
digest: ${{ needs.publish_extra.outputs.digest }}
|
||||
env:
|
||||
# 0.69.3, pinned by digest so a republished tag cannot change what runs with release credentials.
|
||||
TRIVY_IMAGE: aquasec/trivy@sha256:bcc376de8d77cfe086a917230e818dc9f8528e3c852f7b1aff648949b6258d1c
|
||||
steps:
|
||||
- uses: actions/checkout@v4.4.0
|
||||
|
||||
- name: Login to registry
|
||||
uses: docker/login-action@v3.7.0
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Image reference
|
||||
env:
|
||||
DIGEST: ${{ matrix.digest }}
|
||||
run: |
|
||||
if [ -z "$DIGEST" ]; then
|
||||
echo "::error::no digest for ${{ matrix.image }}: its build job did not push an image in this run"
|
||||
exit 1
|
||||
fi
|
||||
echo "IMAGE_REF=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}${{ matrix.suffix }}@$DIGEST" >> "$GITHUB_ENV"
|
||||
|
||||
# The VEX must be built from an unfiltered scan: a statement covers only the CVEs listed in it.
|
||||
# amd64 only: both arches install the same package versions from the same sources.
|
||||
- name: Trivy scan
|
||||
run: |
|
||||
mkdir -p scan
|
||||
trivy() { docker run --rm -v "$RUNNER_TEMP/trivy-cache:/root/.cache/trivy" -v "$PWD/scan:/out" "$TRIVY_IMAGE" "$@"; }
|
||||
trivy image -q --platform linux/amd64 \
|
||||
--scanners vuln --format json -o /out/full.json "$IMAGE_REF"
|
||||
.github/scripts/image-vex.sh \
|
||||
"https://github.com/windmill-labs/windmill/releases/tag/${GITHUB_REF_NAME}#${{ matrix.image }}" \
|
||||
scan/full.json > "scan/${{ matrix.image }}.openvex.json"
|
||||
trivy image -q --platform linux/amd64 \
|
||||
--scanners vuln --vex "/out/${{ matrix.image }}.openvex.json" \
|
||||
--format json -o "/out/${{ matrix.image }}.trivy.json" "$IMAGE_REF"
|
||||
trivy convert --format table \
|
||||
--severity CRITICAL,HIGH -o "/out/${{ matrix.image }}.cves.txt" "/out/${{ matrix.image }}.trivy.json"
|
||||
|
||||
- name: Attach scan results to the release
|
||||
uses: softprops/action-gh-release@v2.6.2
|
||||
with:
|
||||
files: |
|
||||
scan/${{ matrix.image }}.openvex.json
|
||||
scan/${{ matrix.image }}.trivy.json
|
||||
scan/${{ matrix.image }}.cves.txt
|
||||
|
||||
- uses: sigstore/cosign-installer@v4.1.2
|
||||
with:
|
||||
cosign-release: "v2.6.5"
|
||||
|
||||
# Lets `trivy image --vex oci` apply the statements without the release page. `cosign
|
||||
# attest` has no --recursive, and a scanner may resolve either the index or the platform
|
||||
# manifest, so each digest gets its own attestation.
|
||||
- name: Attest VEX
|
||||
run: |
|
||||
repo="${IMAGE_REF%@*}"
|
||||
digests="${{ matrix.digest }} $(docker buildx imagetools inspect --raw "$IMAGE_REF" \
|
||||
| jq -r '.manifests[]? | select(.platform.os != "unknown") | .digest')"
|
||||
for d in $digests; do
|
||||
for attempt in 1 2 3; do
|
||||
cosign attest --yes --type openvex \
|
||||
--predicate "scan/${{ matrix.image }}.openvex.json" "$repo@$d" && continue 2
|
||||
echo "::warning::cosign attest of $d failed (attempt $attempt/3)"
|
||||
[ "$attempt" -lt 3 ] && sleep $((attempt * 30))
|
||||
done
|
||||
exit 1
|
||||
done
|
||||
|
||||
- name: Docker Scout report
|
||||
uses: docker/scout-action@v1.28.0
|
||||
with:
|
||||
command: cves
|
||||
only-severities: critical,high
|
||||
image: ${{ env.IMAGE_REF }}
|
||||
sarif-file: scout.sarif.json
|
||||
summary: true
|
||||
dockerhub-user: windmilllabs
|
||||
dockerhub-password: ${{ secrets.DOCKER_PAT }}
|
||||
|
||||
# Filed under main: the Security tab only reads the default branch, so tag-only uploads
|
||||
# never close their alerts. `sha` is the release commit, which is on main.
|
||||
- name: Upload SARIF result
|
||||
uses: github/codeql-action/upload-sarif@v4.39.3
|
||||
with:
|
||||
sarif_file: scout.sarif.json
|
||||
category: docker-scout-${{ matrix.image }}
|
||||
ref: refs/heads/main
|
||||
sha: ${{ github.sha }}
|
||||
|
||||
# Gates on the VEX-filtered report attached to the release, so the gate and the published
|
||||
# results agree on what is not_affected.
|
||||
- name: Fail on fixable critical CVEs
|
||||
run: |
|
||||
fixable="$(jq -r '.Results[]? | (.Vulnerabilities // [])[]
|
||||
| select(.Severity == "CRITICAL" and .Status == "fixed")
|
||||
| "\(.VulnerabilityID) \(.PkgName) \(.InstalledVersion) -> \(.FixedVersion)"' \
|
||||
"scan/${{ matrix.image }}.trivy.json" | sort -u)"
|
||||
if [ -n "$fixable" ]; then
|
||||
echo "$fixable" | sed 's/^/::error::fixable critical CVE: /'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user