Repository navigation
ci: check chart artifact before signing - #296
Conversation
The publish job of the release workflow attested, signed and released whatever the downloaded chart artifact contained, although any job of the run can replace it. prepare now outputs the chart's file name and SHA-256, and publish checks that dist/ holds exactly that file before attesting or signing it. The chart is uploaded with overwrite: true, so that re-running all jobs replaces the chart of the earlier attempt. Ported from elixir-cloud-aai/trs-filer#180. Closes #295 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The chart check listed dist/ without dotglob, so a hidden file added to the artifact passed it, and the provenance attestation (whose glob matches hidden files) would have covered it too. The check now counts hidden files, and the chart is attested and signed by its exact name from prepare instead of by glob. A test runs the check's script against good and bad artifacts. The workflow header and the re-run docs mention the check. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Drop the assertions on the script text of the chart check, which the test that runs the script covers, and tidy comments and docs wrapping. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideThe release workflow now binds the published chart to the file produced by prepare: it records the chart name and SHA-256, safely replaces artifacts on full reruns, validates the downloaded artifact—including hidden and extra files—before publishing, and uses the exact validated path for attestation and signing. Documentation and executable workflow tests cover the new integrity guarantees and rerun behavior. Sequence diagram for validated chart publishingsequenceDiagram
participant Prepare
participant Artifact as ChartArtifact
participant Publish
participant Attest as Attestation
participant Cosign
participant Release
Prepare->>Prepare: Package chart
Prepare->>Prepare: sha256sum package
Prepare->>Artifact: Upload chart with overwrite: true
Prepare-->>Publish: chart_file, chart_sha256
Publish->>Artifact: Download chart
Publish->>Publish: Check chart name and checksum formats
Publish->>Publish: Check dist/ has exactly expected file
Publish->>Publish: sha256sum --check --strict
Publish->>Attest: Attest exact validated chart path
Publish->>Cosign: Sign exact validated chart path
Publish->>Release: Attach chart and signature
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
The release version must not be hard-coded (test_version_mentions). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #296 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 22 22
Lines 2356 2356
=========================================
Hits 2356 2356 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path=".github/workflows/release.yml" line_range="381" />
<code_context>
+ # be exactly the chart that `prepare` packaged: a single file with the
+ # name and checksum of `prepare`. Hidden files count too, so that
+ # nothing else is in `dist/` (globs of actions match hidden files).
+ - name: Check chart
+ env:
+ FILE: ${{ needs.prepare.outputs.chart_file }}
</code_context>
<issue_to_address>
**Failed releases still sign image**
When the downloaded chart artifact has been replaced or otherwise fails the new check, `Attest build provenance` and `Sign image` have already published attestations and a release-identity signature for the image digest before `Check chart` rejects the artifact, so the release run fails while the image remains signed.
Run the chart download and integrity check before attesting or signing the image, so a rejected chart leaves no release-identity image signature.
</issue_to_address>Linked issues
#295 Release: verify chart artifact before signing · 4 of 4 met
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | prepare outputs the packaged chart's file name and SHA-256. |
✅ Met | The chart step writes both outputs, and prepare exposes them as job outputs. |
| 2 | publish checks immediately after download that dist/ holds exactly the expected file with the expected name and checksum, before attesting or signing it. |
✅ Met | The check counts hidden entries too, and attestation and signing use the checked file's exact name. |
| 3 | prepare uploads the chart with overwrite: true. |
✅ Met | |
| 4 | Tests pin the check and its order before attestation, signing, and release. | ✅ Met | The workflow test checks the wiring and step order; a separate test runs the check script against valid and invalid artifacts. |
Sourcery assessment
Needs a human reviewer. 1 finding to address first, and if the check fails to detect a substituted chart, the workflow could attest, sign, and publish that chart as a release artifact; reverting would not undo copies already downloaded or relied on. The check is designed to fail closed, so an ordinary mismatch would instead block publication and be recoverable by fixing or reverting the workflow.
Blocking findings: .github/workflows/release.yml:381
A rejected chart failed the run only after the image had been attested and signed with the release identity. The chart is now downloaded and checked before anything is attested or signed (Sourcery review). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
The
publishjob of the release workflow attested, signed and released whatever the downloadedchartartifact contained, although any job of the same run can replace that artifact with the run's token. Ported from elixir-cloud-aai/trs-filer#180 (merge 8d00e12), hardened further after review:prepareoutputs the packaged chart's file name and SHA-256 (chart_file,chart_sha256).publishdownloads the chart first, before anything is attested or signed (so a rejected chart also leaves the image unsigned; Sourcery review), and checks it in a new step, "Check chart". It checks the name format and the checksum format, then checks thatdist/holds exactly one entry, with hidden files counted (shopt -s nullglob dotglob), that this entry has the expected name, and that its checksum matches (sha256sum --check --strict).subject-path) and the cosign signature now name the checked file exactly instead ofdist/*.tgz. This goes beyond trs-filer: the attest action's glob matches hidden files, which trs-filer's check doesn't count (see below).overwrite: true(as in trs-filer), so that re-running all jobs replaces the earlier attempt's chart, and the new checksum matches.publishgets the digest as a job output ofpush, not as an artifact, so other jobs can't change it, and it already checks the digest's format.docs/development.md(the release steps and re-runs) and the header comment ofrelease.yml.Closes #295
Verification
pytest tests/test_workflows.py: 15 passed. New tests:test_release_chart_checked(outputs,overwrite, exact attest/sign subjects, step order) andtest_release_chart_check_runs, which runs the step's script withbash -e -o pipefailagainst 7 cases: good, wrong hash, extra file, hidden file, renamed chart, bad name output, bad checksum output. Mutation check: droppingdotglobmakes thehiddencase fail.cloud_registryandscripts.pre-commit run --all-filespassed (ruff, semgrep, gitleaks, actionlint, ast-grep, mypy).CI passed, Test, Lint, Chart, Docs, Smoke test, Scan image, CodeQL, codecov). The first run failed because a test hard-coded the release version (test_version_mentions); fixed with a placeholder in 05fb32b.Review
Full review (release workflow): adversarial-reviewer and quality-reviewer, two rounds. Round 1 found that hidden files got past the check while the attestation glob would still match them (medium; fixed), and that the test only asserted strings (medium; fixed with the script-running test). Round 2 found no problems. Sourcery: one finding (the image was attested and signed before the chart check), fixed in 955fa45 by moving the chart download and check first.
Declined review findings
sha256sum(low): the tests run on GitHub's Ubuntu runners and the dev setup is Linux; the docstring states the dependency.Note for trs-filer
trs-filer's check has the same hidden-file gap (
shopt -s nullglobwithoutdotglob, attestation ofdist/*.tgz), so it should get the same follow-up there.Open questions
None.
🤖 Generated with Claude Code