Skip to content

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

Merged
uniqueg merged 6 commits into
devfrom
ci/234-attest-sign-scan
Oct 23, 2026
Merged

uniqueg merged 6 commits into
devfrom
ci/234-attest-sign-scan

Conversation

@uniqueg

@uniqueg uniqueg commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Summary

Attest, sign and scan the published images and the Helm chart, as in cloud-registry (elixir-cloud-aai/cloud-registry#181 and elixir-cloud-aai/cloud-registry#192):

  • Shared scan action .github/actions/scan-image/action.yml, verbatim from cloud-registry dev (8ce016b, ci: upload only fixable scan findings cloud-registry#202; same blob): fails on fixable critical and high findings, uploads only the findings that have a fix to code scanning, and with report: "true" (weekly scan) keeps a full report (JSON and table), unfixed findings included, as a workflow artifact.
  • CI (checks.yaml): pull requests build the image locally and scan it. Pushes to dev push the image by digest, untagged, with SBOM and provenance attestations (mode=max) (Push app image), scan exactly <image>@<digest> in a job without credentials, signing identity or id-token (Scan image), and only then attest the build provenance (actions/attest-build-provenance, pushed to the registry), sign the digest with cosign (keyless) and tag it dev and sha-<commit> with imagetools create, checking that each tag resolves to the signed digest (Publish app image). id-token: write and attestations: write only on that job.
  • Release (release.yaml): the same for release images (new scan job between push and publish, both still approved in the release environment), plus a provenance attestation and a Sigstore bundle (protes-X.Y.Z.tgz.sigstore.json, attached to the release) for the chart.
  • Weekly scan (scan.yaml) of latest, with vars.DOCKERHUB_ORG || 'elixircloud', keeping the full report as an artifact.
  • .trivyignore.yaml: the four findings of pip's vendored copies in the base image (same as cloud-registry; checked against elixircloud/protes:dev with Trivy 0.75.0: these are the only fixable high/critical findings, and msgpack/setuptools/urllib3 2.7.0 are not installed in site-packages), each with reason and expiry date.
  • Dependabot also updates the composite action.
  • Docs: "Verifying images and charts" on the operations page (gh attestation verify, cosign verify, cosign verify-blob, SBOM and provenance); release steps (two approvals in the release environment, scan between them, tags can't be moved) and the image scans in the development docs; index.

Required checks: the dev ruleset of proTES currently lists no required status checks, so no names change for it; existing job names are unchanged except the image job, which is now Publish app image (as in cloud-registry), with the new Push app image and Scan image.

Verification

  • pre-commit run --all-files (incl. actionlint, check-yaml, semgrep, ast-grep, mypy): passed.
  • mkdocs build --strict: passed.
  • pytest tests/test_build.py (Python version of setup-python in all workflows): passed.
  • Image jobs of checks.yaml compared with cloud-registry dev: identical apart from the image name; release workflow differs from cloud-registry only in the pre-existing, out-of-scope parts (release notes format, chart dependency handling).
  • Trivy 0.75.0 on elixircloud/protes:dev (fixable high/critical): only the four ignored pip-vendored findings.
  • CI on this PR: all checks passed, incl. Scan image (local build, fixable findings uploaded to code scanning, Trivy check passed); Push app image and Publish app image are skipped on pull requests, as intended. The dev path (push by digest, scan, attest, sign, tag) runs on the merge to dev.
  • The release path can't run before a tag; read end to end.

Full review lane (release workflow): adversarial and quality reviewer subagents, no high findings; fixed: comment/doc wrapping (now verbatim cloud-registry text).

Declined review findings

  • Adversarial (medium): the weekly scan targets protes:latest, which is still the last pre-release-workflow image (pushed by the old dev workflow before ci!: release from signed version tags #230 merged), unsigned, so the weekly scan may fail on its fixable findings until the first release. Kept as in cloud-registry: latest is what users pull, so scanning it is the point, and the first release replaces it. The reviewer's concern that stale branches keep pushing latest does not hold: their old workflows trigger only on pushes to dev (and pull requests, which never published).
  • Adversarial (low): :latest is resolved by each Trivy run of the weekly scan, so a release during the scan could mix images. Kept identical to cloud-registry (shared action/workflow); a digest pin in scan.yaml would be a change for all three repos.
  • Quality (medium): the action header says the copies in FOCA, cloud-registry and proTES are identical. It is cloud-registry's text verbatim and true with this PR (blob 26a6593 in cloud-registry dev).
  • Quality (low): four Trivy runs with report; kept identical to the shared action.
  • Sourcery: jq -r .digest of imagetools inspect --format '{{ json .Manifest }}' would be null. It isn't: .Manifest is the descriptor, and it prints the index digest (checked on elixircloud/cloud-registry:dev, published by the same step).
  • Sourcery: the pip-vendored ignores could also hide installed copies. They can't be scoped by path (Trivy reports the vendored copies without one), they are pinned by purls to the exact versions and expire on 2027-01-31; same as cloud-registry and FOCA.
  • Quality (low): .trivyignore.yaml note dated 2026-10-23 instead of 2026-10-22: checked for the proTES image on that date, so kept.

Open questions

None.

Notes for the maintainers

  • Code scanning must be enabled for the SARIF uploads (free for public repositories).
  • To require the scan as for cloud-registry, add Scan image to the required checks of dev (the proTES ruleset currently has none).
  • No docs/releases/ notes exist yet; the first release's notes should mention signed images and chart.

Closes #234

🤖 Generated with Claude Code

uniqueg and others added 6 commits October 23, 2026 16:23
Scan the image of every pull request with Trivy, through the shared
composite action `.github/actions/scan-image` (as in cloud-registry),
and upload the findings that have a fix to code scanning. On pushes to
`dev`, push the image by digest, untagged, with SBOM and provenance
attestations, scan exactly that digest in a job without credentials or
signing identity, and only then attest its provenance, sign it with
Sigstore keyless signing and tag it `dev` and `sha-<commit>`, checking
that each tag resolves to the signed digest.

Scan `latest` weekly (`scan.yaml`), keeping a full report, also of the
findings without a fix, as a workflow artifact. Accept the pip-vendored
findings of the base image in `.trivyignore.yaml`, with reasons and
expiry dates, and let Dependabot update the composite action too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Push the release image by digest with SBOM and provenance attestations,
scan exactly that digest in a job of its own, without the release
credentials, the `contents: write` token and the signing identity, and
only then attest its build provenance, sign it (Sigstore keyless) and
tag it. Attest the chart's provenance and attach a Sigstore bundle of
its signature (`.tgz.sigstore.json`) to the release. As in
cloud-registry; the publishing job alone gets `id-token: write` and
`attestations: write`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add "Verifying images and charts" to the operations page: how to check
the GitHub artifact attestations and Sigstore signatures of release and
`dev` images and of the released chart, and how to read an image's SBOM
and provenance. Describe the scan, attest and sign steps of the release
and the image scans in the development docs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Take the scan action of elixir-cloud-aai/cloud-registry#202 (fixable
findings to code scanning; the weekly full report as JSON and as a
table), so that the copies in FOCA, cloud-registry and proTES stay
identical, and align the docs with it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Take the scan job comment of cloud-registry `dev` verbatim, and rewrap
the scan paragraphs of the operations and development docs.

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

The PR introduces a shared Trivy-based image scanning workflow and gates development and release publication on scanning exact immutable digests, then adds SBOM/provenance attestations, keyless image and chart signing, and verification documentation.

Sequence diagram for digest scanning and signed image publication

sequenceDiagram
    participant Workflow as GitHub Actions
    participant Registry as Docker Hub
    participant Scanner as Trivy scan
    participant Attestor as Provenance attestation
    participant Cosign as Cosign

    Workflow->>Registry: Build and push image by digest
    Workflow->>Scanner: Scan image@digest
    Scanner-->>Workflow: Pass or fail on fixable HIGH/CRITICAL
    alt scan passes
        Workflow->>Attestor: Attest build provenance for digest
        Workflow->>Cosign: cosign sign image@digest
        Workflow->>Registry: Tag signed digest as dev or release tags
    else scan fails
        Workflow-->>Registry: Leave digest untagged and unsigned
    end
Loading

Sequence diagram for signed Helm chart release artifacts

sequenceDiagram
    participant Release as Release workflow
    participant Attestor as GitHub attestation
    participant Cosign as Cosign
    participant GitHub as GitHub release

    Release->>Attestor: Attest chart provenance
    Release->>Cosign: cosign sign-blob chart.tgz
    Cosign-->>Release: Write chart.tgz.sigstore.json
    Release->>GitHub: Attach chart and Sigstore bundle
Loading

File-Level Changes

Change Details Files
Centralize Trivy scanning with fixable-finding reporting, failure thresholds, and optional full reports.
  • Scan local, digest-pinned, and weekly images with the same composite action.
  • Upload fixable findings to code scanning and weekly JSON/table reports as artifacts.
  • Ignore four explicitly scoped vendored-package findings with reasons and expiry dates.
.github/actions/scan-image/action.yml
.trivyignore.yaml
.github/workflows/scan.yaml
Change development CI to publish only scanned, attested, signed image digests.
  • Build and push images by digest with SBOM and max-mode provenance on pushes.
  • Scan the exact pushed digest in an isolated job before publication.
  • Attest provenance, sign keylessly, and create verified dev and commit tags only after the scan passes.
.github/workflows/checks.yaml
Apply the scan, attestation, signing, and chart-verification flow to releases.
  • Scan the release digest between the approved push and publish environments.
  • Attest and keylessly sign the image, then tag the scanned digest.
  • Attest and sign the Helm chart and attach its Sigstore bundle to the GitHub release.
.github/workflows/release.yaml
Document verification, release controls, and image scanning behavior.
  • Describe GitHub attestation, cosign, SBOM, provenance, and chart-bundle verification commands.
  • Document approvals, immutable tags, scan timing, accepted findings, and rerun behavior.
  • Add the operations verification section to the documentation index.
docs/operations.md
docs/development.md
docs/index.md
Enable dependency updates for the new local composite action.
  • Extend the GitHub Actions Dependabot configuration to cover the scan action directory.
.github/dependabot.yml

Assessment against linked issues

Issue Objective Addressed Explanation
#234 Publish container images with SBOM and provenance, GitHub build-provenance attestations, and keyless Sigstore signatures; attest and sign the published Helm chart. ✅
#234 Scan images on pull requests and pushes, scan the latest release image weekly, fail on fixable high/critical vulnerabilities, report findings, and provide reasoned, expiring exceptions. ✅
#234 Document how operators verify images and charts and inspect image SBOMs, and add a release-notes entry describing the changes. ❌ The PR documents verification and SBOM inspection, but does not add a release-notes entry. Its notes explicitly say that no release notes exist yet and that the first release's notes should mention signed images and the chart.

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.

@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 proTES | 🛠️ Build #35357727 | 📁 Comparing d62a7e7 against latest (18d3c63)

  🔍 Preview build  

3 files changed
± index.html
± development/index.html
± operations/index.html

@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 (18d3c63) to head (d62a7e7).

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #256   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           26        26           
  Lines         1517      1517           
=========================================
  Hits          1517      1517           

☔ 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 15:18

@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 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path=".github/workflows/checks.yaml" line_range="483-484" />
<code_context>
+          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)"
+            if [[ "${actual}" != "${DIGEST}" ]]; then
+              echo "::error::${tag} points to ${actual}, expected ${DIGEST}"
+              exit 1
</code_context>
<issue_to_address>
**Dev image publishing always fails**

When a push reaches the `Tag image` step, the `imagetools inspect` format serializes the OCI manifest or index, whose top-level data has no `digest` field. `jq -r .digest` therefore returns `null`, so the comparison fails after tagging and the `Publish app image` job reports failure on every push.

Read the digest from a registry descriptor or another inspect field that actually exposes the resolved digest, then compare that value with `DIGEST`.
</issue_to_address>

### Comment 2
<location path=".trivyignore.yaml" line_range="24-37" />
<code_context>
+  # copies without a path, so the entries can't be limited with `paths`; they
+  # would also hide these versions if installed normally
+  - id: CVE-2025-47273
+    purls: ["pkg:pypi/[email protected]"]
+    statement: Vendored by pip, not used by the app (path traversal in PackageIndex, which pip doesn't use)
+    expired_at: 2027-01-31
+  - id: CVE-2026-97687
+    purls: ["pkg:pypi/[email protected]"]
+    statement: Vendored by pip, not used by the app (pip only runs at build time)
+    expired_at: 2027-01-31
+  - id: CVE-2026-97689
</code_context>
<issue_to_address>
**Runtime vulnerabilities get ignored**

When a runtime dependency later includes one of the listed package versions with the corresponding vulnerability, trivy applies these vulnerability-ID/PURL ignores without checking whether the package is pip-vendored or installed for the app. If a runtime dependency later matches one of these entries, the scan passes and the image can be signed and tagged despite the vulnerability.

Remove the broad ignores by updating the base image’s vendored packages, or use path-scoped ignores if Trivy can identify the vendored paths.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 2 findings to address first, and if the digest or signing flow is wrong, CI could publish and sign an unintended image that consumers may deploy or trust; tags and signatures already pushed to the registry are not undone by reverting the workflow. The scan gate also changes what can be published, but a mistake there does not by itself create the vulnerabilities it fails to detect.

Blocking findings: .github/workflows/checks.yaml:484, .trivyignore.yaml:37


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

Comment thread .github/workflows/checks.yaml Resolved
Comment thread .trivyignore.yaml Resolved
@uniqueg
uniqueg merged commit 7ca49bb into dev Oct 23, 2026
18 checks passed
@uniqueg
uniqueg deleted the ci/234-attest-sign-scan branch October 23, 2026 16:02
@uniqueg uniqueg mentioned this pull request Oct 23, 2026
8 tasks
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