Skip to content

ci: attest, sign and scan published images - #181

Merged
uniqueg merged 4 commits into
devfrom
ci/attest-sign-scan
Oct 22, 2026
Merged

uniqueg merged 4 commits into
devfrom
ci/attest-sign-scan

Conversation

@uniqueg

@uniqueg uniqueg commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes #172.

  • Build: dev images (checks.yaml) and release images (release.yaml) are built with docker/build-push-action with sbom: true and provenance: mode=max.
  • Attest and sign: actions/attest-build-provenance (push-to-registry: true) and cosign sign (keyless, the workflow's OIDC identity) on the pushed digest. Only the publishing jobs get id-token: write and attestations: write.
  • Release flow: a new scan job builds the release commit's image and scans it. It has no environment, no secrets and only contents: read, and publish needs 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 it X.Y.Z (and latest) with docker buildx imagetools create. It checks that each tag resolves to the signed digest. Before, the image was loaded locally and pushed with docker push, which can't carry attestations.
  • Chart: the release .tgz gets 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 in prepare is unchanged.
  • Scan: a composite action, .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:
    • the new CI job Scan image (every PR and push; publish now needs it);
    • the release workflow's own scan job (gate only, no upload). Trivy never runs in the job that holds the Docker Hub credentials, the contents: write token 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.
    • the new weekly scan.yaml, which scans elixircloud/cloud-registry:latest (public image, so it needs no secrets).
  • .trivyignore.yaml: each entry has purls, a statement and an expired_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.
  • Dependabot now also updates the composite action (directories). The Trivy version itself has to be bumped by hand (documented).
  • Docs: "Verifying images and charts" in docs/operations.md (gh attestation verify, cosign verify/verify-blob with the exact identity and issuer, how to read the SBOM and provenance), maintainer notes in docs/development.md, and an entry in the docs/releases/0.3.0.md notes.

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).
  • Trivy v0.75.0, run locally against 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.yaml and --severity CRITICAL,HIGH --ignore-unfixed --exit-code 1 it exits 0.
  • Action pins checked against their tags (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-source imagetools create (it copies the original bytes, so the digest is kept).
  • CI on this PR: all checks pass, including the new Scan image job (Trivy; its SARIF reached code scanning, so the Trivy code scanning check passes), tests, Helm, docs and Compose smoke test. Build and publish app image is 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):

  • signing and attesting dev images (publish job), which runs on the next push to dev after the merge;
  • the whole release workflow: the scan job and the publish job (push by digest, check, attest, sign, tag, chart attestation and bundle);
  • the weekly scan, which can be started with workflow_dispatch after the merge;
  • the verification commands in the docs, which apply to images from v0.3.0 on.

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.yaml entries 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 with paths: 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.
  • Dependabot PRs can't upload SARIF (quality, medium). GitHub lets the permissions key raise the token's permissions on Dependabot pull_request runs, and the adversarial reviewer confirmed this. I'll check it on the first Dependabot PR after the merge.
  • Release re-runs move X.Y.Z to a new digest (adversarial, low). This was already the case before (docker push on 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 image is 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.
  • The image name is hardcoded in scan.yaml, and "Determine image name" is duplicated (quality, low). DOCKERHUB_ORG exists only in the environments, and the weekly scan needs no credentials. The name is the one documented in docs/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 image a 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:

  • Add vulnerability scanning for pull requests, pushes, releases, and the latest published image through a reusable Trivy composite action and scheduled workflow.
  • Publish Docker images with SBOMs, provenance attestations, and keyless Sigstore signatures, and attest and sign release charts.

Enhancements:

  • Change release publishing to verify, attest, and sign a single image digest before assigning version and latest tags.
  • Document verification procedures for image and chart signatures, attestations, SBOMs, and provenance.

CI:

  • Separate image scanning from publishing jobs and restrict credentials and signing permissions to publishing workflows.
  • Configure Dependabot to update actions used by the local scanning action.

Documentation:

  • Document vulnerability scan policy, accepted findings, release signing, and artifact verification in development, operations, index, and release documentation.

Chores:

  • Add expiring, justified Trivy exceptions for findings from pip-vendored packages.

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

sourcery-ai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

The 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 image

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

Sequence diagram for image scanning in isolated CI jobs

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

Entity relationship diagram for signed release artifacts

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

File-Level Changes

Change Details Files
Introduces a reusable Trivy scanning action and integrates vulnerability scanning across CI, releases, and scheduled checks.
  • Builds images locally for PR/push and release-commit scanning, uploads SARIF where permitted, and fails on fixable HIGH/CRITICAL findings.
  • Adds a weekly scan of the public latest image.
  • Adds documented, expiring package-specific Trivy exceptions and Dependabot coverage for the composite action.
.github/actions/scan-image/action.yml
.github/workflows/checks.yaml
.github/workflows/release.yaml
.github/workflows/scan.yaml
.trivyignore.yaml
.github/dependabot.yml
Adds SBOM generation, provenance attestations, and keyless Sigstore signing to published container images while isolating scanning from publishing credentials.
  • Enables SBOM and max-mode provenance during image builds.
  • Attests and signs dev images by digest using GitHub OIDC and registry-backed attestations.
  • Restricts id-token and attestation permissions to publishing jobs.
.github/workflows/checks.yaml
.github/workflows/release.yaml
Reworks releases to publish, verify, attest, sign, and then tag one immutable image digest.
  • Builds and pushes the release image by digest, checks its embedded application version, and signs the exact digest.
  • Uses imagetools to create version/latest tags from the signed digest and verifies each tag resolves to it.
  • Makes publishing depend on the isolated release scan job.
.github/workflows/release.yaml
Adds provenance attestations and Sigstore bundles for release chart artifacts.
  • Attests packaged charts with GitHub artifact attestations.
  • Signs chart archives with cosign and attaches the generated bundles to GitHub releases.
.github/workflows/release.yaml
Documents verification, maintenance, and release behavior for signed artifacts and vulnerability scanning.
  • Provides GitHub CLI and cosign commands for verifying image/chart attestations, signatures, SBOMs, and provenance.
  • Documents scan gates, ignore-file maintenance, OIDC permissions, and release rerun semantics.
  • Adds the security features to the 0.3.0 release notes and documentation navigation.
docs/operations.md
docs/development.md
docs/index.md
docs/releases/0.3.0.md

Assessment against linked issues

Issue Objective Addressed Explanation
#172 Build and publish dev and release images with OCI SBOM and provenance, GitHub artifact provenance attestations, and keyless Sigstore signatures, using publishing-job-only OIDC and attestation permissions. ✅
#172 Scan images on every pull request and push, before release publication, and weekly for newly discovered vulnerabilities; fail on fixable critical/high findings, report findings through SARIF, and document reasoned, expiring exceptions. ✅
#172 Provide verifiable provenance and signatures for the Helm chart, and document how operators verify images and charts and inspect image SBOMs, with a release-notes entry. ✅

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

@github-advanced-security

Copy link
Copy Markdown

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:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

@codecov

codecov Bot commented Oct 22, 2026

Copy link
Copy Markdown

Codecov Report

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

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.
📢 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 22, 2026 22:52

@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 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.


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

@uniqueg
uniqueg merged commit 2a9e64c into dev Oct 22, 2026
17 checks passed
@uniqueg
uniqueg deleted the ci/attest-sign-scan branch October 22, 2026 22:59
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: attest, sign and scan published images

2 participants