Repository navigation
ci: attest, sign and scan published images - #181
Conversation
Build images with SBOM and provenance attestations (mode=max), attest their build provenance (GitHub artifact attestations, pushed to Docker Hub) and sign their digests with cosign keyless signing, for dev images (checks.yaml) and release images (release.yaml). The release workflow now pushes the image by digest, checks and scans exactly that digest, attests and signs it, and only then tags it X.Y.Z (and latest), so that every tag points to a checked and signed image. The chart attached to a release gets a GitHub artifact attestation and a Sigstore bundle. Scan the image with Trivy (composite action .github/actions/scan-image, pinned by SHA, as in FOCA) on every pull request and push, before release images are tagged, and weekly for latest (scan.yaml): fail on fixable critical and high findings, upload SARIF to code scanning. Accepted findings go to .trivyignore.yaml with reason and expiry; the first entries are pip's vendored packages. Dependabot now also updates the composite action. No new secrets; job permissions are limited to the jobs that need them. Refs: #172 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Explain how operators verify images and the chart (gh attestation verify, cosign verify and verify-blob with the expected identity and issuer) and read an image's SBOM and provenance, how maintainers handle scan findings, and add the release notes entry. Closes #172 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The release job holds the Docker Hub credentials, a contents: write token and the release signing identity; Trivy resolves its binary from a mutable release tag at run time, so don't run it there. The release commit's image is already scanned by CI, whose success the release requires. Also document cosign 3 for verification, the identity of dev images, secret findings, re-runs of the release and why the ignore entries can't be limited by path. Refs: #172 Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI scans a commit when it is pushed, possibly days before the release, and the release rebuilds the image (dependency ranges are resolved again). Build and scan the release commit's image in a separate job without secrets, signing identity or write tokens, and make publishing depend on it. Refs: #172 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideThe PR adds end-to-end supply-chain security for container images and Helm charts: images are scanned in isolated jobs, built with SBOM/provenance metadata, attested and keylessly signed, while releases publish and tag a verified immutable digest and distribute signed, attested chart artifacts. Documentation and maintenance guidance explain how to verify and operate the new process. Sequence diagram for the attested and signed release imagesequenceDiagram
participant Release as release.yaml
participant Scanner as scan job
participant Builder as docker/build-push-action
participant Registry as Docker Hub
participant GitHub as GitHub Attestations
participant Cosign as cosign
Release->>Scanner: Build release commit image
Scanner->>Scanner: scan-image
Scanner-->>Release: Scan passes
Release->>Builder: Build and push by digest
Builder->>Registry: Push image with SBOM and provenance
Release->>Release: Check app version at digest
Release->>GitHub: Attest build provenance for digest
GitHub->>Registry: Push provenance attestation
Release->>Cosign: Sign image digest with OIDC
Cosign->>Registry: Store Sigstore signature
Release->>Registry: imagetools create version and latest tags
Release->>Registry: Inspect tags and verify digest
Sequence diagram for image scanning in isolated CI jobssequenceDiagram
participant Workflow as CI or weekly workflow
participant Build as Docker Buildx
participant Trivy as scan-image
participant CodeScanning as GitHub Code Scanning
Workflow->>Build: Build local image
Build-->>Workflow: Loaded image
Workflow->>Trivy: Scan image with Trivy
Trivy->>Trivy: Apply .trivyignore.yaml
Trivy->>CodeScanning: Upload SARIF findings
Trivy-->>Workflow: Fail on fixable CRITICAL or HIGH findings
Entity relationship diagram for signed release artifactserDiagram
IMAGE_DIGEST {
string digest PK
string sbom
string provenance
}
IMAGE_TAG {
string tag PK
string digest FK
}
IMAGE_SIGNATURE {
string digest FK
string oidc_identity
}
CHART_ARTIFACT {
string filename PK
string attestation
string sigstore_bundle
}
IMAGE_DIGEST ||--o{ IMAGE_TAG : referenced_by
IMAGE_DIGEST ||--o{ IMAGE_SIGNATURE : signed_by
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #181 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 11 11
Lines 737 737
=========================================
Hits 737 737 ☔ 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. The workflows publish Sigstore signatures and provenance attestations for image digests and release charts, which consumers can use to decide what to trust. If the signer identity or subject digest is wrong, a misleading trust claim remains published even after reverting; the affected artifacts are bounded to those this workflow signed.
Summary
Closes #172.
checks.yaml) and release images (release.yaml) are built withdocker/build-push-actionwithsbom: trueandprovenance: mode=max.actions/attest-build-provenance(push-to-registry: true) andcosign sign(keyless, the workflow's OIDC identity) on the pushed digest. Only the publishing jobs getid-token: writeandattestations: write.scanjob builds the release commit's image and scans it. It has no environment, no secrets and onlycontents: read, andpublishneeds it. The image is then pushed by digest (untagged), and the workflow checks the app version of exactly that digest, attests and signs it, and only after that tags itX.Y.Z(andlatest) withdocker buildx imagetools create. It checks that each tag resolves to the signed digest. Before, the image was loaded locally and pushed withdocker push, which can't carry attestations..tgzgets a GitHub artifact attestation (subject-path) and a Sigstore bundle (cosign sign-blob --bundle,cloud-registry-X.Y.Z.tgz.sigstore.json), which is attached to the release. The chart packaging inprepareis unchanged..github/actions/scan-image, runs Trivy (trivy-action and Trivy pinned, the same as in FOCA's matching PR for foca#403). It uploads all findings as SARIF to code scanning (skipped for fork PRs), then fails on fixable critical/high findings. It is used by:Scan image(every PR and push;publishnow needs it);scanjob (gate only, no upload). Trivy never runs in the job that holds the Docker Hub credentials, thecontents: writetoken or the signing identity: trivy-action resolves the Trivy binary from its release tag at run time, so a hijacked tag must not be able to reach those.scan.yaml, which scanselixircloud/cloud-registry:latest(public image, so it needs no secrets)..trivyignore.yaml: each entry haspurls, astatementand anexpired_at. The first entries are four HIGH findings in packages that pip vendors (urllib3 2.7.0, setuptools 70.3.0, msgpack 1.1.2, listed in pip's SBOM in the base image). The app doesn't use them, and the urllib3 the app does use is already 2.8.0. The latest pip still vendors these versions. The entries expire on 2027-01-31.directories). The Trivy version itself has to be bumped by hand (documented).docs/operations.md(gh attestation verify,cosign verify/verify-blobwith the exact identity and issuer, how to read the SBOM and provenance), maintainer notes indocs/development.md, and an entry in thedocs/releases/0.3.0.mdnotes.Full process (release workflow), not the light lane.
How it was verified
pre-commit run --all-files(incl. actionlint, check-yaml, semgrep, gitleaks): passed.mkdocs build --strict: passed.pytest tests/test_config.py tests/test_release_version.py: 71 passed (Helm tests skipped locally, no helm; chart untouched).elixircloud/cloud-registry:dev(same Dockerfile and base image): without the ignore file it reported 4 fixable HIGH findings (all from pip's vendored SBOM); with.trivyignore.yamland--severity CRITICAL,HIGH --ignore-unfixed --exit-code 1it exits 0.gh api repos/<action>/commits/<tag>). I also checked the trivy-action ignore-file handling (a single YAML file is passed through as is) and the buildx single-sourceimagetools create(it copies the original bytes, so the digest is kept).Scan imagejob (Trivy; its SARIF reached code scanning, so theTrivycode scanning check passes), tests, Helm, docs and Compose smoke test.Build and publish app imageis skipped on PRs, as intended.Not exercised (needs a push to
dev, a release tag or the schedule; no releases were triggered and no tags pushed):publishjob), which runs on the next push todevafter the merge;scanjob and thepublishjob (push by digest, check, attest, sign, tag, chart attestation and bundle);workflow_dispatchafter the merge;The weekly scan of the current
latest(an old pre-0.3.0 image) will probably fail until v0.3.0 is released, because that image is old.Declined review findings
.trivyignore.yamlentries are matched by purl only, so they would also hide a normally installed urllib3 2.7.0, msgpack 1.1.2 or setuptools 70.3.0 (adversarial, medium if confirmed). I tested it: Trivy reports pip's vendored packages, which come from pip's SBOM, without a path, so an entry restricted withpaths:no longer matches them. The installed urllib3 is 2.8.0. The entries expire on 2027-01-31, and the limitation is explained in the file.permissionskey raise the token's permissions on Dependabotpull_requestruns, and the adversarial reviewer confirmed this. I'll check it on the first Dependabot PR after the merge.X.Y.Zto a new digest (adversarial, low). This was already the case before (docker pushon re-run). It is now documented, and the earlier digest stays signed. Reusing an existing digest would need its own logic and a decision.Scan imageis not a required check (adversarial, low). The release requires a green CI push run, and the release workflow now scans again, so making it required is optional.scan.yaml, and "Determine image name" is duplicated (quality, low).DOCKERHUB_ORGexists only in the environments, and the weekly scan needs no credentials. The name is the one documented indocs/development.md.Open questions
None.
What the user must set up
Nothing. There are no new secrets or environments. Code scanning accepts SARIF uploads on public repositories without setup. Optionally, make
Scan imagea required check.🤖 Generated with Claude Code
Summary by Sourcery
Secure container and chart publishing with attestations, signatures, digest-based releases, and vulnerability scanning.
New Features:
Enhancements:
CI:
Documentation:
Chores: