Repository navigation
ci: sign and tag only the scanned image digest - #432
Conversation
The release and dev image flows now build and push each image once, by digest and untagged (job `push`), scan exactly that digest in a job without credentials, signing identity or `id-token` (job `scan`, shared `scan-image` action), and only if the scan passes attest, sign and tag it, checking that each tag resolves to the signed digest (job `docker`). Before, the published images were built a second time after the scan. The digests are passed between the matrix jobs as artifacts. The Docker Hub organization now comes from the repository variable `DOCKERHUB_ORG` (by default `elixircloud`), as in `scan.yml`, so that the secret-less scan job knows the image name; the `DOCKERHUB_ORG` secret is no longer used. Refs #428 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Describe the scan-before-sign flow in "Verifying images and charts", the contributing guide's image scan section and the README's release steps, and that all workflows take the Docker Hub organization from the repository variable `DOCKERHUB_ORG`. Refs #428 Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Name the local pull request build like the pushed images, so that code scanning matches the OS package findings of pull requests and pushes (Trivy derives their location from the repository name). - Run the scan only for pull requests or after a successful push. - Say that digests of failed runs stay on Docker Hub, untagged. - Docs: limit the claim to images published from now on, state what passing the scan means, and re-wrap the edited paragraphs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideThe workflows now build and push each image once by immutable digest, scan that exact digest in an isolated job, and only then attest, sign, and tag it with verification; image naming now uses the DOCKERHUB_ORG repository variable, and the documentation reflects the new publication and release flow. Sequence diagram for digest-based image publicationsequenceDiagram
participant Push as Push image
participant Registry as Docker Hub
participant Scan as Scan image
participant Docker as Publish image
Push->>Registry: Build and push image by digest
Push->>Scan: Upload digest-pyV artifact
Scan->>Scan: Download image digest
Scan->>Registry: Scan IMAGE_NAME@digest
Scan-->>Docker: Scan passed
Docker->>Registry: Attest build provenance
Docker->>Registry: cosign sign IMAGE_NAME@digest
Docker->>Registry: docker buildx imagetools create
Docker->>Registry: docker buildx imagetools inspect
Flow diagram for scanned image publicationflowchart TD
A[Build image once] --> B[Push untagged image by digest]
B --> C[Scan exact digest]
C -->|scan passes| D[Attest and sign digest]
D --> E[Tag digest]
E --> F[Verify tag resolves to digest]
C -->|scan fails| G[Remain untagged and unsigned]
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Resolve the conflicts with #429, which moved the release steps from the README to "Versioning and releases" in the contributing guide: describe the scan-before-sign flow there, and point the release workflow's header to it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #432 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 27 27
Lines 2869 2869
=========================================
Hits 2869 2869
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've reviewed your changes and they look great!
Sourcery assessment
Needs a human reviewer. If the digest handoff or scan gate is wrong, an image that was not actually scanned could still be signed and published under the expected tags, and downstream users may already have pulled or deployed it. Reverting can remove or correct the tags, but it cannot undo those uses.
Summary
Closes #428 (base
devis not the default branch, so the issue is closed by hand after the merge).The release and
devimage flows now sign and tag exactly the image that was scanned:push(Push image (Python X)): builds each image once and pushes it by digest, untagged (with SBOM and provenance attestations); the release workflow also checks the FOCA version the image reports. The digest is passed on as an artifact (digest-pyV), as all jobs of a matrix share one set of outputs.scan(Scan image (Python X), unchanged name): scans<image>@<digest>with the sharedscan-imageaction, in a job without Docker Hub credentials, signing identity orid-token. Pull requests still scan a local build.docker(Publish image (Python X)): only if the scan passed, attests and signs that digest, then tags it withdocker buildx imagetools createand checks that each tag resolves to the signed digest. In the release workflow it still runs after the PyPI upload, which still waits for the scan.A digest that fails the scan stays untagged and unsigned, and nothing refers to it.
The Docker Hub organization now comes from the repository variable
DOCKERHUB_ORG(by defaultelixircloud), asscan.ymlalready did, through a workflow-levelIMAGE_NAME. The secret-less scan job needs the image name too, and a name built from a secret would be masked in job outputs. TheDOCKERHUB_ORGsecret is no longer used.Docs ("Verifying images and charts" in the deployment guide, "Image scan" in the contributing guide, the release steps in "Versioning and releases" of the contributing guide, moved there from the README by #429) now say that the published images are the scanned ones. The required checks (
Unit tests,Scan images, ...) keep their names.Mirrored in elixir-cloud-aai/cloud-registry#188 (same job structure and comments; Cloud Registry has a single image, so it passes the digest as a job output instead of an artifact).
How it was verified
actionlint(v1.7.12, with shellcheck 0.10.0): no findings on the changed workflows (only the existing SC2102 info on the lint job'spip install -e .[dev,docs]).pre-commit run --all-files: all hooks pass.devimage by its index digest (docker.io/elixircloud/foca@sha256:5c3056..., remote source): the image index with attestation manifests resolves and scans correctly, as the newscanjob does.Push imageandPublish imageare skipped, as they should be for pull requests. The same flow in cloud-registry (build: make project PEP 561 compliant #192, merged) ran the push path ondevsuccessfully:devandsha-<commit>point to the scanned and signed digest. The push path (push->scanby digest ->docker) runs only on pushes todev, so it first runs after the merge; I will watch that run. The release path runs only for a tag and could not be run before a release.Changes from the pre-push review: the local PR build is now tagged
<image>:scan, so that code scanning matches the OS package findings of PRs and pushes (Trivy derives their location from the repository name; after the merge, thedevOS package alerts are recreated once under the new location). The scan now runs only for PRs or after a successful push. The comments say that digests of failed runs stay on Docker Hub, untagged.Declined review findings
pushwait for lint and tests: it runs alongside them on purpose, so that the scan starts early. Untagged digests of failed runs are harmless, and this is documented.devpublish images, and that already needed the secrets before this change.Notes for maintainers
DOCKERHUB_ORGsecret is no longer read. Forks that publish elsewhere set the repository variableDOCKERHUB_ORGinstead (forelixircloudnothing needs to be set).Open questions
None.
🤖 Generated with Claude Code
Summary by Sourcery
Publish only Docker image digests that have passed vulnerability scanning, then attest, sign, and verify every resulting tag.
New Features:
Bug Fixes:
Enhancements:
CI:
Documentation: