Skip to content

ci: sign and tag only the scanned image digest - #192

Merged
uniqueg merged 5 commits into
devfrom
ci/sign-scanned-digest
Oct 23, 2026
Merged

uniqueg merged 5 commits into
devfrom
ci/sign-scanned-digest

Conversation

@uniqueg

@uniqueg uniqueg commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes #188

The release and dev image flows now sign and tag exactly the image that was scanned:

  1. push (Push image in release.yaml, Push app image in checks.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.
  2. scan (Scan image, unchanged name of the required check): scans <image>@<digest> with the shared scan-image action, in a job without Docker Hub credentials, signing identity or id-token. Pull requests still scan a local build.
  3. publish (Publish image and release; in CI renamed from Build and publish app image to Publish 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, or dev/sha-<commit>) with docker buildx imagetools create and 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 the dev tag.

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 release environment, and both push and publish need 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 in docs/development.md.

The Docker Hub organization now comes from the repository variable DOCKERHUB_ORG (by default elixircloud) through a workflow-level IMAGE_NAME, as in FOCA, also in scan.yaml (it hard-coded elixircloud). 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_ORG secrets are no longer used.

Docs ("Verifying images and charts" in docs/operations.md, the release steps, settings and image scans in docs/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).
  • Trivy v0.75.0 locally against an existing image by its index digest (remote source): an image index with attestation manifests resolves and scans correctly, as the new scan job does.
  • CI on this PR (pull request path: local build + scan, required check Scan image): all checks pass; Push app image and Publish app image are skipped, as they should be for pull requests. The push path (push -> scan by digest -> publish) runs only on pushes to dev, 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, the dev OS 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

  • Consolidate the digest checks and the tag-and-verify logic into shared scripts: each is a few lines of inline shell, checked at each consumer, which matches the existing style of the workflows (and of the FOCA mirror).
  • Make push wait 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.
  • Sourcery: "0.3.0 image was not scanned at its digest". 0.3.0 is not released yet; it will be the first release built by this workflow.
  • Sourcery: race between two concurrent releases on latest. The logic that decides latest is unchanged by this PR; a lock across runs is a separate design change.
  • Sourcery: a fork's packaged chart still defaults to elixircloud/cloud-registry. The chart default is unchanged; forks set cloudRegistry.image.
  • The pre-existing behaviour of the publish concurrency 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

  • The environments' DOCKERHUB_ORG secrets are no longer read and can be removed. Forks set the repository variable DOCKERHUB_ORG (for elixircloud nothing needs to be set).
  • A release now needs two approvals in release.
  • A dev CI 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:

  • Ensure release and development images are scanned at the exact digest that is later signed and tagged, preventing unscanned images from being published.

Enhancements:

  • Separate image pushing, scanning, and publishing into distinct workflow jobs with digest handoff and post-scan signing and tag verification.
  • Use the repository DOCKERHUB_ORG variable to identify images across workflows, including secretless scan jobs.
  • Require a second release-environment approval after scanning before signing, tagging, and creating the release.

CI:

  • Update CI and release workflows to build and push images once by digest, scan them without registry credentials or signing permissions, and publish only successful scans.

Documentation:

  • Document digest-based image publication, two-step release approval, repository image organization configuration, and rerun behavior.

uniqueg and others added 4 commits October 23, 2026 05:14
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]>
@sourcery-ai

sourcery-ai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Reworks 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 publication

sequenceDiagram
    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
Loading

File-Level Changes

Change Details Files
Split image handling into push, scan, and publish stages so only the exact scanned digest can be signed and tagged.
  • Build once and push untagged with SBOM, provenance, OCI metadata, and an exported digest.
  • Scan the pushed image by digest in a credential-free job; retain local builds for pull requests.
  • After all checks and a successful scan, attest and sign the digest, create dev/commit or release/latest tags from it, and verify every tag resolves to that digest.
  • Add digest validation and release-image version verification.
.github/workflows/checks.yaml
.github/workflows/release.yaml
Use a repository-level Docker Hub organization variable consistently across image workflows.
  • Define fully qualified image names from DOCKERHUB_ORG with an elixircloud fallback.
  • Update scheduled release-image scanning and remove reliance on environment DOCKERHUB_ORG secrets.
.github/workflows/checks.yaml
.github/workflows/release.yaml
.github/workflows/scan.yaml
Document the new trust boundaries, approval flow, image provenance, and rerun behavior.
  • Explain the two release-environment approvals and the separation of credentialed publishing from scanning.
  • Document that published images are the scanned images and that failed scans remain untagged and unsigned.
  • Update maintainer settings and fork configuration guidance.
docs/development.md
docs/operations.md

Assessment against linked issues

Issue Objective Addressed Explanation
#188 Build and push release and dev images once by digest without tags, then scan that exact digest in a job without Docker Hub credentials, signing identity, or id-token permission. ✅
#188 Only after the digest passes scanning, attest and sign that same digest, tag it, and verify that each published tag resolves to the signed digest. ✅
#188 Update documentation to state that published release and dev images are the scanned images. ✅

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov

codecov Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (e0dc51d) to head (bc47d1f).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@uniqueg
uniqueg marked this pull request as ready for review October 23, 2026 10:25

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread docs/operations.md Resolved
Comment thread .github/workflows/release.yaml Resolved
Comment thread .github/workflows/release.yaml Resolved
@uniqueg
uniqueg merged commit 7ce7a07 into dev Oct 23, 2026
18 checks passed
@uniqueg
uniqueg deleted the ci/sign-scanned-digest branch October 23, 2026 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci: sign only the scanned image digest

1 participant