Repository navigation
ci: sign and tag only the scanned image digest - #192
Conversation
The release and dev image flows now build and push the 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 `publish`). Before, the published image was built a second time after the scan. In the release workflow, `push` and `publish` both run in the `release` environment, so a release needs two approvals. The Docker Hub organization now comes from the repository variable `DOCKERHUB_ORG` (by default `elixircloud`), also in `scan.yaml`, so that the secret-less scan job knows the image name; the `DOCKERHUB_ORG` secrets of the environments are no longer used. Refs #188 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Describe the scan-before-sign flow in "Verifying images and charts" and the development guide (release steps, two approvals, image scans), and that the Docker Hub organization is the repository variable `DOCKERHUB_ORG`. Refs #188 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 GuideReworks release and dev image workflows into a digest-preserving push → credential-free scan → sign/attest/tag pipeline, ensuring published tags reference exactly the scanned image while centralizing image naming through DOCKERHUB_ORG and updating operational documentation. Sequence diagram for digest-preserving image publicationsequenceDiagram
participant Push as push job
participant Registry as Docker Hub
participant Scan as scan job
participant Publish as publish job
participant Sigstore as Sigstore
Push->>Registry: Build and push image by digest
Registry-->>Push: digest
Push->>Scan: Pass image@digest
Scan->>Registry: Pull image@digest
Scan-->>Publish: Scan passed
Publish->>Registry: Attest build provenance for digest
Publish->>Sigstore: cosign sign image@digest
Publish->>Registry: imagetools create tags from image@digest
Publish->>Registry: imagetools inspect each tag
Registry-->>Publish: Each tag resolves to digest
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #192 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 14 14
Lines 917 917
=========================================
Hits 917 917 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've found 3 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="docs/operations.md" line_range="113-114" />
<code_context>
(both fail on fixable critical and high vulnerabilities), and the `latest`
image weekly; the maintainers see the results in the repository's
-code scanning alerts.
+code scanning alerts. From version 0.3.0 on, the published images (releases
+and `dev`) are the scanned ones: the workflows push each image by digest,
+untagged, scan exactly that digest, and only if the scan passes (no fixable
+critical or high vulnerabilities, except accepted ones) sign and tag it.
</code_context>
<issue_to_address>
**Published image appears scanned**
When readers assess the already-published 0.3.0 image using this wording, `docs/operations.md` says the scan-before-sign flow applies from 0.3.0, but that release's workflow scanned a local build and then rebuilt the published image. Readers therefore get false assurance that the published digest was scanned.
Limit the guarantee to images built by the new workflow and explicitly say the existing 0.3.0 image was not scanned at its published digest.
</issue_to_address>
### Comment 2
<location path=".github/workflows/release.yaml" line_range="368" />
<code_context>
+ SHA: ${{ github.sha }}
+ run: |
+ for tag in "${IMAGE_NAME}:dev" "${IMAGE_NAME}:sha-${SHA}"; do
+ docker buildx imagetools create --tag "${tag}" "${IMAGE_NAME}@${DIGEST}"
+ actual="$(docker buildx imagetools inspect "${tag}" \
+ --format '{{ json .Manifest }}' | jq -r .digest)"
</code_context>
<issue_to_address>
**Latest points to older release**
When an older release checks the highest tag before a higher-version tag is pushed, then pauses while that higher release publishes `latest`, `steps.latest` records `true` from its fetch; a concurrently publishing higher release can then set `latest` to its digest, after which this run’s `imagetools create` overwrites it with the older digest. Consumers pulling `:latest` get the wrong release.
Serialize the highest-release check and `latest` tag update across release runs, and make the update use the latest tag set while holding that serialization.
</issue_to_address>
### Comment 3
<location path=".github/workflows/release.yaml" line_range="38" />
<code_context>
+# `elixircloud`), as in `scan.yaml`, so that the scan job, which has no
+# secrets, scans the image that is published
+env:
+ IMAGE_NAME: docker.io/${{ vars.DOCKERHUB_ORG || 'elixircloud' }}/cloud-registry
+
# Cancel superseded runs of a pull request; runs for pushes get their own
</code_context>
<issue_to_address>
**Fork chart pulls upstream image**
When a fork sets `DOCKERHUB_ORG` to its publishing organization, the release workflow packages `deployment` without overriding its image repository, so the chart defaults to `elixircloud/cloud-registry` instead of the fork’s published image; installations of the fork’s chart pull the upstream image. Make the chart default use the configured organization or set it during packaging.
Make the packaged chart’s default image repository use the configured organization.
Also at `.github/workflows/checks.yaml:22`.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 3 findings to address first, and if the digest wiring or tag operation is wrong, an image other than the one that passed the scan could receive the published tags and signature, then be pulled or deployed. Reverting can restore the tags, but it cannot undo prior pulls or deployments, and the signature remains available.
Blocking findings: docs/operations.md:114, .github/workflows/release.yaml:368, .github/workflows/release.yaml:38
Summary
Closes #188
The release and
devimage flows now sign and tag exactly the image that was scanned:push(Push imageinrelease.yaml,Push app imageinchecks.yaml): builds the image once and pushes it by digest, untagged (with SBOM and provenance attestations, OCI labels); the release workflow also checks the app version the image reports. The digest is a job output.scan(Scan image, unchanged name of the required check): 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.publish(Publish image and release; in CI renamed fromBuild and publish app imagetoPublish app image, which is not a required check): only if the scan passed, attests and signs that digest, then tags it (X.Y.Z/latest, ordev/sha-<commit>) withdocker buildx imagetools createand checks that each tag resolves to the signed digest. In CI, the head-commit check and the publish concurrency group stay on this job, which sets thedevtag.A digest that fails the scan stays untagged and unsigned, and nothing refers to it.
Two approvals per release: the Docker Hub secrets exist only in the
releaseenvironment, and bothpushandpublishneed them, so a release now waits for approval twice: once to push the image, and once more after the scan passed, to sign, tag and create the GitHub release. This is documented indocs/development.md.The Docker Hub organization now comes from the repository variable
DOCKERHUB_ORG(by defaultelixircloud) through a workflow-levelIMAGE_NAME, as in FOCA, also inscan.yaml(it hard-codedelixircloud). The secret-less scan job needs the image name too, and a name built from a secret would be masked in job outputs. The environments'DOCKERHUB_ORGsecrets are no longer used.Docs ("Verifying images and charts" in
docs/operations.md, the release steps, settings and image scans indocs/development.md) now say that the published images are the scanned ones.Mirrored in elixir-cloud-aai/foca#428 (same job structure and comments; FOCA builds one image per Python version, so it passes the digests as artifacts).
How it was verified
pre-commit run --all-files(including actionlint): all hooks pass (mypy skipped locally; no Python changes).scanjob does.Scan image): all checks pass;Push app imageandPublish app imageare skipped, as they should be for pull requests. The push path (push->scanby digest ->publish) 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 docs explain re-runs (all jobs: new digest; failed jobs: same digest).Declined review findings
pushwait for the tests: it runs alongside them on purpose, so that the scan starts early. Untagged digests of failed runs are harmless, and this is documented.latest. The logic that decideslatestis unchanged by this PR; a lock across runs is a separate design change.elixircloud/cloud-registry. The chart default is unchanged; forks setcloudRegistry.image.publishconcurrency group (a waiting job can be replaced by an older run's job, which then skips at the head check): not changed by this PR. It is out of scope.Notes for maintainers
DOCKERHUB_ORGsecrets are no longer read and can be removed. Forks set the repository variableDOCKERHUB_ORG(forelixircloudnothing needs to be set).release.devCI run that fails because Docker Hub is unavailable must be re-run before that commit can be released (the release checks for a successful CI run).Open questions
None.
🤖 Generated with Claude Code
Summary by Sourcery
Publish only the image digest that has passed vulnerability scanning, then attest, sign, and tag that digest in CI and release workflows.
Bug Fixes:
Enhancements:
CI:
Documentation: