Repository navigation
ci: check chart before signing anything - #354
Conversation
Record the chart's file name and SHA-256 in prepare, and check the downloaded chart artifact against them in publish (one file in dist/, hidden files included), before the image or the chart is attested or signed, as any job of the run can overwrite artifacts. Attest and sign the chart by its checked file name instead of dist/*.tgz. Tests pin the outputs, the overwrite, the exact subjects and the step order, and run the check script for good, tampered, extra, hidden, renamed and missing files and for bad outputs. Closes #353 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Pass an empty checksum to the check script as it is (it was replaced by the real one), and run the script with the options of the runner's default shell (bash -e, no pipefail). Say in the docs that a mismatch fails the job before anything is attested or signed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideThe release workflow now records a packaged chart’s filename and digest, verifies the downloaded artifact is exactly that chart before any release signing or attestation, signs and attests only the verified path, and documents and tests the protections including rerun behavior. Sequence diagram for verified chart signing in the release workflowsequenceDiagram
participant Prepare as prepare
participant Artifact as Chart artifact
participant Publish as publish
participant Signer as Sigstore
Prepare->>Prepare: Package chart
Prepare->>Prepare: sha256sum package
Prepare->>Artifact: Upload chart with overwrite true
Prepare-->>Publish: chart_file and chart_sha256
Publish->>Artifact: Download chart
Publish->>Publish: Check chart
alt chart name, checksum, file count, and digest match
Publish->>Signer: Attest chart provenance
Publish->>Signer: Sign chart
else validation fails
Publish-->>Publish: Exit before attestation or signing
end
Flow diagram for chart validation before release signingflowchart TD
A[Package chart] --> B[Record chart_file and chart_sha256]
B --> C[Upload chart with overwrite true]
C --> D[Download chart in publish]
D --> E{Check chart}
E -->|Valid name, SHA-256, single file, matching digest| F[Attest image and chart]
F --> G[Sign image and chart]
E -->|Any check fails| H[Fail publish before attestation or signing]
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Documentation build overview
4 files changed+ plugin-images/index.html± deployment/index.html± development/index.html± plugins/index.html |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #354 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 23 23
Lines 2209 2209
=========================================
Hits 2209 2209 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've found 3 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path=".github/workflows/release.yml" line_range="361" />
<code_context>
+ # 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). Checked first, so that a rejected chart leaves nothing
+ # attested or signed, the image included
+ - name: Check chart
+ env:
</code_context>
<issue_to_address>
**Rejected charts leave image attested**
When the downloaded chart fails the check, the `push` job publishes the image’s SBOM and provenance attestations before `publish` runs `Check chart`, so rejecting the chart still leaves the image attested, contrary to the comment and release instructions.
Move chart validation before image attestations, or revise the comment and release instructions to reflect that the image is already attested.
Also at `.github/workflows/release.yml:362`, `docs/development.md:282-283`.
</issue_to_address>
### Comment 2
<location path="tests/test_workflows.py" line_range="201" />
<code_context>
+ sign = steps["Sign chart"]["run"]
+ assert sign == 'cosign sign-blob --yes --bundle "${CHART}.sigstore.json" "${CHART}"'
+ names = list(steps)
+ assert names.index("Download chart") < names.index("Check chart")
+ # A rejected chart leaves the image unattested and unsigned too
+ assert names.index("Check chart") < names.index("Attest build provenance")
</code_context>
<issue_to_address>
**Wrong artifact path goes unnoticed**
When the `Download chart` step's path is changed from `dist/`, when the download step writes to a directory other than `dist/`, `test_release_chart_checked` checks only step order at `tests/test_workflows.py:201`, while `test_release_chart_check_runs` creates `dist/` itself at `:264-265` and skips the download step. Both tests pass even though the release check finds no downloaded chart and fails.
Assert that the download step's configured path is `dist/` in `test_release_chart_checked`.
Also at `tests/test_workflows.py:265`.
</issue_to_address>
### Comment 3
<location path="tests/test_workflows.py" line_range="224" />
<code_context>
+ None, "protes-9.9.9.tgz", False, False, CHART, None, False, id="renamed"
+ ),
+ pytest.param(None, None, False, True, CHART, None, False, id="empty"),
+ pytest.param(None, None, False, False, "../x.tgz", None, False, id="bad-name"),
+ pytest.param(
+ None, None, False, False, "protes-1.tar", None, False, id="not-tgz"
</code_context>
<issue_to_address>
**Invalid chart names bypass the test**
When the filename-format guard is removed and the artifact's only file has the same invalid name as `FILE`, when the downloaded file has the same invalid name as `FILE`, `test_release_chart_check_runs` still passes if the filename-format guard is removed: its `bad-name` and `not-tgz` cases at `tests/test_workflows.py:224-227` leave the fixture named `CHART` (`:266`), so the later path comparison rejects them. A matching invalid filename would pass the remaining checks.
Use a matching invalid artifact filename in at least one case so that acceptance depends on the filename-format guard.
Also at `tests/test_workflows.py:226`.
</issue_to_address>Linked issues
#353 ci: check chart before signing anything · 5 of 5 met
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | prepare outputs the chart file name and SHA-256 |
✅ Met | The chart step emits both values, and the prepare job exposes them as chart_file and chart_sha256. |
| 2 | publish checks the downloaded chart before attesting or signing the image or chart |
✅ Met | The check validates the expected name and checksum formats, requires exactly one entry in dist/ including hidden entries, and verifies the SHA-256 before the attestation and signing steps. |
| 3 | Attest and sign the chart by its exact file name, and keep overwrite: true |
✅ Met | Both chart subject paths use the prepare file-name output, and the chart upload retains overwrite: true. |
| 4 | Test the workflow wiring, step order, and chart-check cases | ✅ Met | Tests pin the outputs, overwrite setting, subjects, and ordering, and run the check script against valid and rejected artifact cases. |
| 5 | Describe the chart check in the workflow header and docs/development.md |
✅ Met | Both the workflow comment and release documentation describe the recorded name and checksum check. |
Sourcery assessment
Approval pending. 3 findings to address first.
Blocking findings: .github/workflows/release.yml:361, tests/test_workflows.py:201, tests/test_workflows.py:224
Assert the download path and that a failed chart check stops the job, and give the non-.tgz case a matching artifact, so that only the name guard rejects it. Say that the image already carries its build's attestations from push; the check precedes GitHub attestation, signing and tagging. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
Ports the chart check of elixir-cloud-aai/cloud-registry#296 to the release workflow:
preparerecords the packaged chart's file name and SHA-256 (stepchart, outputschart_file,chart_sha256); the upload keepsoverwrite: true, so full re-runs replace the chart.publishdownloads the chart right after the digest check and checks it (Check chart: expected name and checksum formats, exactly one file indist/, hidden files included viashopt -s nullglob dotglob,sha256sum --check --strict) before the image or the chart is attested or signed, as any job of the run can overwrite artifacts.Attest chart provenanceandSign chartusedist/${{ needs.prepare.outputs.chart_file }}instead ofdist/*.tgz.tests/test_workflows.py) pin the outputs, the overwrite, the exact attest/sign subjects and the step order, and run the check script for: good, wrong hash, extra file (sorting before and after the chart), hidden file, renamed, empty, bad name, non-.tgzname, short, empty and uppercase hash.docs/development.md(release section, re-runs) describe the check.Closes #353
Verification
pytest: 1053 passed, 169 skipped (after mergingdev; the skips needhelmlocally and run in CI).pre-commit run --fileson the changed files (ruff, mypy, semgrep, ast-grep, actionlint, gitleaks): passed.extra-afterfail.releaseenvironment).CI passed).Review
Full review (adversarial-reviewer + quality-reviewer, 1 round; one medium, the rest low). Fixed: empty checksum passed as is (and tested), docs say a mismatch fails the job before anything is signed, the script test uses the runner's default shell options (
bash -e, nopipefail; the step has noshell:).Sourcery (3 threads): fixed the wording on attestations (the image already carries its build attestations from
push; the check precedes GitHub attestation, signing and tagging) and added test asserts (download path, nocontinue-on-error, a non-.tgzartifact that only the name guard rejects). All threads resolved; CI passed again.Declined review findings
test_release_chart_check_runswith a case dataclass or callable (medium): the test keeps the shape of the same test in cloud-registry and trs-filer, so the three repos stay comparable and changes can be ported one to one; the ids name each case."${CHART}"in the sign command and add a_stepshelper (low): the exact command is what the verification docs rely on (bundle name<chart>.tgz.sigstore.json), and the other tests in this file use the same inline lookup.helm packageis not reproducible (low, pre-existing): unchanged by this PR; the release assets check already reports what to do.🤖 Generated with Claude Code
Summary by Sourcery
Protect chart releases by validating the packaged artifact's name, contents, and checksum before signing or publishing release assets.
Bug Fixes:
Enhancements:
Tests: