Repository navigation
ci: attest, sign and scan published images - #414
Conversation
Build the release and dev images with Buildx, with SBOM and provenance (mode=max) attestations, and attest (GitHub artifact attestation, pushed to the registry) and sign (cosign keyless) the pushed digests; the same for the foca-common chart on GHCR. Publishing jobs get id-token and attestations write permissions only. Add an image scan workflow (Grype): on pull requests and pushes, build the images of all Python versions (a dry run of the release build that checks the attestations), report all vulnerabilities to code scanning and fail on fixable critical or high ones; weekly, scan the images of the latest release. Accepted findings go into .grype.yaml with a reason and an expiry date, which the workflow checks. Refs #403 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Explain how operators verify images and charts (gh attestation verify, cosign verify with the expected identity and issuer) and read SBOMs and provenance, and how contributors handle failed image scans. Refs #403 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Python 3.11 base images ship setuptools 79 and wheel 0.45, which have known vulnerabilities (wheel: GHSA-8rrh-rw8j-w5fx, high, fixed in 0.46.2), so that the image scan fails for them. FOCA needs neither at runtime, and pip builds packages in isolated environments; images of Python 3.12 and later do not ship them either. Refs #403 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Keep scheduled scans on the triggering commit, using only dev's ignore file, so that code scanning gets results for the right commit; reject impossible expiry dates; show Helm's output if pushing the chart fails; explain the dry run and the two scans; rewrap comments and docs; give the image scan docs a heading of their own. Refs #403 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Refs #403 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideThe PR upgrades image and chart publishing with Buildx SBOM/provenance attestations, GitHub attestations, and keyless Cosign signatures; introduces Grype-based vulnerability scanning with expiring ignore rules; removes vulnerable unused Python packages; and documents verification and scan workflows. Sequence diagram for attested and signed image publishingsequenceDiagram
participant Workflow as GitHub Actions workflow
participant Buildx as Docker Buildx
participant Registry as Docker Hub
participant Attest as actions/attest
participant Cosign as cosign
Workflow->>Buildx: build-push-action
Buildx->>Registry: push image tags and digest
Buildx-->>Workflow: outputs.digest
Workflow->>Attest: attest(subject-name, subject-digest)
Attest->>Registry: push GitHub artifact attestation
Workflow->>Cosign: cosign sign --yes image@digest
Cosign->>Registry: push keyless signature
Sequence diagram for image vulnerability scanningsequenceDiagram
participant Trigger as PR or dev push
participant Buildx as Docker Buildx
participant Archive as OCI archive
participant Docker as Docker image store
participant Grype as Grype
participant CodeScanning as GitHub code scanning
Trigger->>Buildx: build-push-action with sbom and provenance
Buildx->>Archive: write image and attestations
Trigger->>Archive: Check attestations
Trigger->>Buildx: build-push-action with load
Buildx->>Docker: load image
Trigger->>Grype: scan image
Grype-->>CodeScanning: upload SARIF findings
Trigger->>Grype: scan with only-fixed and severity-cutoff high
Grype-->>Trigger: fail on fixable high or critical findings
Sequence diagram for chart attestation and signingsequenceDiagram
participant Workflow as release-chart workflow
participant Helm as Helm
participant GHCR as GitHub Container Registry
participant Attest as actions/attest
participant Cosign as cosign
Workflow->>Helm: helm push chart
Helm->>GHCR: publish chart OCI artifact
Helm-->>Workflow: chart digest
Workflow->>GHCR: Docker login
Workflow->>Attest: attest chart digest
Attest->>GHCR: push chart attestation
Workflow->>Cosign: cosign sign --yes chart@digest
Cosign->>GHCR: push keyless signature
Flow diagram for expiring vulnerability ignore rulesflowchart TD
A[Load .grype.yaml] --> B[Check reason]
B --> C[Parse expires as YYYY-MM-DD]
C --> D{Date from today to three months ahead?}
D -->|Yes| E[Run image scan]
D -->|No| F[Fail ignores job]
File-Level Changes
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 #414 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 27 27
Lines 2777 2777
=========================================
Hits 2777 2777
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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/release-chart.yml" line_range="149-151" />
<code_context>
+ fi
+ echo "${output}"
+ digest="$(sed -n 's/^Digest: \(sha256:[0-9a-f]\{64\}\)$/\1/p' <<< "${output}")"
+ if [ -z "${digest}" ]; then
+ echo "::error::Could not find the digest of the pushed chart"
+ exit 1
+ fi
+ echo "digest=${digest}" >> "${GITHUB_OUTPUT}"
</code_context>
<issue_to_address>
**Published chart cannot be verified**
When the chart push succeeds but digest parsing, attestation, or signing fails, the workflow exits after publishing the chart, and the already-published check rejects the rerun, leaving the version without its attestation or signature; callers cannot verify it as documented.
Make reruns recover the pushed chart's digest and continue attestation and signing instead of rejecting an already-published version.
Also at `.github/workflows/release-chart.yml:162`.
</issue_to_address>
### Comment 2
<location path=".github/workflows/images.yml" line_range="155" />
<code_context>
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.13"
- - name: Determine version
</code_context>
<issue_to_address>
**Accepted vulnerabilities still fail scans**
When a fixable high or critical vulnerability is added to `.grype.yaml` as an accepted finding, the scan invocations do not pass `.grype.yaml` as Grype’s configuration. Grype therefore does not apply the repository’s ignore rules, so a vulnerability accepted there still appears in the results and can fail the fixable high/critical scan.
Pass `.grype.yaml` to every scan invocation as Grype’s configuration.
Also at `.github/workflows/images.yml:174`, `.github/workflows/images.yml:229`, `.github/workflows/images.yml:244`.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 2 findings to address first, and this adds Sigstore signatures and provenance attestations to published image and chart digests, so a mistaken build or signer configuration could leave externally distributed artifacts carrying a misleading trust claim. Reverting stops future runs but does not remove artifacts, signatures, or attestations already published; those need separate remediation.
Blocking findings: .github/workflows/release-chart.yml:151, .github/workflows/images.yml:155
Grype finds .grype.yaml in the working directory on its own; passing it makes the scans independent of that lookup. Refs #403 Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # README.md # docs/contributing.md
Use the setup of cloud-registry (#181) instead of Grype: the composite action .github/actions/scan-image (Trivy 0.75.0 via trivy-action 0.36.0) and .trivyignore.yaml (accepted findings by purl, with a statement and an expiry date). CI scans the images of all Python versions in a new `scan` job of checks.yml, which the dev image job needs; the release workflow scans the release commit's images again in a job without credentials before anything is published, and pushes the images by digest, attests and signs them, and only then tags that digest; the weekly scan of the latest release moves to scan.yml. Use actions/attest-build-provenance and step names as in cloud-registry. Refs #403 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Before attesting and signing a release image, check that it reports the release version; decide `latest` from freshly fetched tags merged into main, and scan the images of the highest such tag weekly, as cloud-registry does, so that stray tags are ignored. Refs #403 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Closes #403. Close it by hand after merging, as
devis not the default branch.This uses the same setup as cloud-registry (elixir-cloud-aai/cloud-registry#181): the same scan action, ignore file format, pins, step names and verification docs. The differences come from FOCA's four Python image variants and its OCI chart on GHCR.
Summary
Build, attest, sign
checks.yml, jobdocker):docker/build-push-action), with SBOM (sbom: true) and provenance (provenance: mode=max) attestations;actions/attest-build-provenance, withpush-to-registry: true;release.yml, jobdocker):docker buildx imagetools create, and each tag is checked against the signed digest;latestis now decided from freshly fetched tags that are merged intomain, so stray tags are ignored; the weekly scan does the same.release-chart.yml):foca-commongets the same attestation and signature. The digest is parsed fromhelm push. A Docker login to GHCR is added, because the attestation and signature are pushed with Docker's credentials.id-token: writeandattestations: writeare granted only on these publishing jobs.Scan
.github/actions/scan-image, copied from cloud-registry:scanjob inchecks.ymlbuilds and scans the images of Python 3.11 to 3.14. The SARIF upload is skipped for fork PRs. The devdockerjob needs this job.scanjob inrelease.ymlbuilds and scans the release commit's images again:contents: readonly, no environment and no secrets, so Trivy never runs next to publishing credentials orid-token;publishanddockerneed it, so a failing scan stops the release before anything immutable is published.scan.ymlscanselixircloud/foca:<latest final>-py3.x. The images are public, so it needs no secrets. Scheduled runs use the default branch (main), so the workflow takes.trivyignore.yamlfromdev..trivyignore.yaml, copied from cloud-registry. It accepts pip's vendored copies of setuptools 70.3.0, urllib3 2.7.0 and msgpack 1.1.2 by purl, each with a statement and an expiry date of 2027-01-31. Trivy reports vendored copies without a path, so the entries can't be limited by path.Dockerfile
The image no longer contains
setuptoolsandwheel, which only the Python 3.11 base image ships.0.16.0-py3.11image has wheel 0.45.1 (GHSA-8rrh-rw8j-w5fx, high, fixable), and the current base image has setuptools 79.0.1.--no-build-isolationorpython setup.pymust install setuptools themselves, as they already must on 3.12+.Docs
docs/deployment.md:gh attestation verifyandcosign verify(cosign 3 or later), with exact per-version identities and the issuer;devimages and the chart;docker buildx imagetools inspect.docs/contributing.md, on how to handle a failed scan.README.mdanddocs/helm-chart.md.Everything is free for public repositories and needs no new secrets: the existing
DOCKERHUB_*secrets andGITHUB_TOKENare enough.How it was verified
actionlint1.7.7 on all workflows, including the local composite action: no findings.https://spdx.dev/Documentandhttps://slsa.dev/provenance/v1), and the SARIF upload to code scanning worked.Scan image (Python 3.11-3.14)(Trivy, no fixable critical or high findings with the accepted pip-vendored entries), theTrivycode scanning check, Sourcery review, codecov and Read the Docs.Not exercised
Publishing paths: nothing can run before a tag or a push to
dev:attest-build-provenancewithpush-to-registry;cosign sign;imagetools createand the digest check;The same digest and tag flow is merged and in use in cloud-registry. The
devimage path runs for the first time once this PR is merged.Documented commands:
gh attestation verify,cosign verifyandimagetools inspecthave not been run against a FOCA image, as no FOCA image is signed yet.Release
scanjob: it is the same as the PRscanjob, plusFOCA_VERSION.Weekly scan: it starts only once
scan.ymlreachesmainwith 0.17.0. A manualworkflow_dispatchondevbefore then would fail for0.16.0-py3.11(wheel 0.45.1).Declined review findings
Recover the chart's digest on reruns and attest and sign it (Sourcery, medium): if the run attested and signed a digest recovered from the registry, it would vouch for an artifact it didn't build. This failure (push succeeds, then attest or sign fails) is rare, and
docs/helm-chart.mdsays to release a new version in that case.Grype-specific findings from earlier rounds: these are void now that the PR uses Trivy. The Grype ignore-file checker is gone too, as Trivy enforces
expired_atitself.OCI labels via
docker/metadata-action, as in cloud-registry (adversarial, low): FOCA's images never had version or commit labels; the provenance attestation records the commit. Adding them is a separate change that this PR doesn't need.Open questions
None.
What the user must set up
Nothing. Optionally, add the new
Scan image (Python 3.x)checks to the required checks of thedevruleset.🤖 Generated with Claude Code