From 986c84b1cd385ba6c347cb886d7b1230e7bbf322 Mon Sep 17 00:00:00 2001 From: Byron Williams Date: Thu, 17 Sep 2026 18:12:13 -0700 Subject: [PATCH 1/2] fix(docker): load single-platform image for local Trivy scan path The local-scan path (push=false, enable-trivy-scan=true) built the image via buildx without load: true, then Export local image for scanning ran docker save on it. buildx only populates the runner's local Docker image store when load is set, so save always failed with "reference does not exist" on every PR-time scan-only build. Since docker's local exporter can't materialize a multi-arch manifest list, the fix also pins this path to linux/amd64 instead of the multi-platform default. The push=true path (actual publish to a registry) is unchanged: full multi-platform builds, scanned via the registry-image Trivy step instead. This only changes a path that previously failed on every invocation, so no existing passing caller can regress. Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/python-docker.yml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python-docker.yml b/.github/workflows/python-docker.yml index 17528a3..5b95052 100644 --- a/.github/workflows/python-docker.yml +++ b/.github/workflows/python-docker.yml @@ -304,14 +304,31 @@ jobs: # Additional custom tags ${{ inputs.additional-tags }} + # #CRITICAL: external-resources: the local-scan path below (push=false, + # enable-trivy-scan=true) needs this build to end up in the runner's + # local Docker image store, since "Export local image for scanning" + # does `docker save` on it. buildx only populates that store when + # `load: true` is set; without it, the image exists only in the build + # cache and docker save fails with "reference does not exist". Loading + # also requires a single-platform build (the docker exporter cannot + # materialize a multi-arch manifest list locally), so this path is + # pinned to linux/amd64 rather than the multi-arch default. The + # push=true path is untouched: it keeps full multi-platform builds and + # scans the pushed registry image instead (see the two Trivy steps + # below), so this only changes behavior on a path that previously + # failed on every single invocation. + # #VERIFY: if a downstream repo ever needs local scanning of a + # non-amd64 image, this will need a platform input instead of a + # hardcoded value. - name: Build and push Docker image id: build-push uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0 with: context: ${{ inputs.context }} file: ${{ inputs.dockerfile }} - platforms: ${{ inputs.platforms }} + platforms: ${{ (inputs.enable-trivy-scan && steps.push-check.outputs.push != 'true') && 'linux/amd64' || inputs.platforms }} push: ${{ steps.push-check.outputs.push }} + load: ${{ inputs.enable-trivy-scan && steps.push-check.outputs.push != 'true' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} build-args: ${{ inputs.build-args }} From d23beec2af5730b2b9c69447a184ab752a82af1a Mon Sep 17 00:00:00 2001 From: Byron Williams Date: Thu, 17 Sep 2026 20:11:14 -0700 Subject: [PATCH 2/2] fix(docker-workflow): guard sbom/provenance and platform reporting under local-scan load The local-scan path (push=false, enable-trivy-scan=true) already pins the build to linux/amd64 via load: true, since the docker exporter cannot materialize a multi-arch manifest list locally. Two related gaps remained on that same path: - The docker exporter does not support SBOM/provenance attestation output, but sbom/provenance stayed wired directly to the caller's raw inputs, silently dropping attestations instead of surfacing the limitation. - The Build Summary step reported inputs.platforms unconditionally, so it showed the multi-arch default even when the build was actually pinned to a single platform. Guard both with the same enable-trivy-scan && push != 'true' condition already used for load/platforms, and extend the RAD comment block with an #EDGE/#VERIFY pair documenting the SBOM/provenance limitation. Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/python-docker.yml | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/.github/workflows/python-docker.yml b/.github/workflows/python-docker.yml index 5b95052..79bd784 100644 --- a/.github/workflows/python-docker.yml +++ b/.github/workflows/python-docker.yml @@ -304,7 +304,7 @@ jobs: # Additional custom tags ${{ inputs.additional-tags }} - # #CRITICAL: external-resources: the local-scan path below (push=false, + # #CRITICAL: external resources: the local-scan path below (push=false, # enable-trivy-scan=true) needs this build to end up in the runner's # local Docker image store, since "Export local image for scanning" # does `docker save` on it. buildx only populates that store when @@ -316,10 +316,18 @@ jobs: # push=true path is untouched: it keeps full multi-platform builds and # scans the pushed registry image instead (see the two Trivy steps # below), so this only changes behavior on a path that previously - # failed on every single invocation. - # #VERIFY: if a downstream repo ever needs local scanning of a - # non-amd64 image, this will need a platform input instead of a - # hardcoded value. + # failed on every single invocation. The Build Summary step below + # mirrors this same condition so it reports the platform actually + # built, not the raw input. + # #EDGE: security: the docker exporter (selected by load: true) does + # not support SBOM/provenance attestation output, so sbom/provenance + # are forced off below on this same path even when the caller's + # enable-sbom or enable-provenance inputs default to true; those + # attestations are only produced on the push=true path. + # #VERIFY: if a downstream caller ever needs local scanning of a + # non-amd64 image, replace the hardcoded linux/amd64 above with a + # dedicated platform input; confirm no current caller expects + # arm64-specific local-scan coverage before making that change. - name: Build and push Docker image id: build-push uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0 @@ -334,8 +342,8 @@ jobs: build-args: ${{ inputs.build-args }} cache-from: type=gha cache-to: type=gha,mode=max - sbom: ${{ inputs.enable-sbom }} - provenance: ${{ inputs.enable-provenance }} + sbom: ${{ (inputs.enable-trivy-scan && steps.push-check.outputs.push != 'true') && 'false' || inputs.enable-sbom }} + provenance: ${{ (inputs.enable-trivy-scan && steps.push-check.outputs.push != 'true') && 'false' || inputs.enable-provenance }} # Export local image for Trivy scanning when not pushed to registry - name: Export local image for scanning @@ -406,7 +414,7 @@ jobs: if: always() env: PUSH_STATUS: ${{ steps.push-check.outputs.push }} - PLATFORMS: ${{ inputs.platforms }} + PLATFORMS: ${{ (inputs.enable-trivy-scan && steps.push-check.outputs.push != 'true') && 'linux/amd64' || inputs.platforms }} IMAGE_TAGS: ${{ steps.meta.outputs.tags }} IMAGE_DIGEST: ${{ steps.build-push.outputs.digest }} IS_FORK: ${{ steps.check-fork.outputs.is_fork }}