Skip to content

ci: check chart before signing anything - #354

Merged
uniqueg merged 5 commits into
devfrom
ci/353-chart-check
Oct 31, 2026
Merged

uniqueg merged 5 commits into
devfrom
ci/353-chart-check

Conversation

@uniqueg

@uniqueg uniqueg commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

Summary

Ports the chart check of elixir-cloud-aai/cloud-registry#296 to the release workflow:

  • prepare records the packaged chart's file name and SHA-256 (step chart, outputs chart_file, chart_sha256); the upload keeps overwrite: true, so full re-runs replace the chart.
  • publish downloads the chart right after the digest check and checks it (Check chart: expected name and checksum formats, exactly one file in dist/, hidden files included via shopt -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 provenance and Sign chart use dist/${{ needs.prepare.outputs.chart_file }} instead of dist/*.tgz.
  • Tests (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-.tgz name, short, empty and uppercase hash.
  • The workflow header comment and docs/development.md (release section, re-runs) describe the check.

Closes #353

Verification

  • pytest: 1053 passed, 169 skipped (after merging dev; the skips need helm locally and run in CI).
  • pre-commit run --files on the changed files (ruff, mypy, semgrep, ast-grep, actionlint, gitleaks): passed.
  • Mutation check: removing the file-count condition from the script makes extra-after fail.
  • Not verifiable without a release: the workflow run itself (needs a tag and the release environment).
  • CI: all checks passed (gate 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, no pipefail; the step has no shell:).

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, no continue-on-error, a non-.tgz artifact that only the name guard rejects). All threads resolved; CI passed again.

Declined review findings

  • Replace the positional/boolean parameters of test_release_chart_check_runs with 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.
  • Assert only "${CHART}" in the sign command and add a _steps helper (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.
  • Attribution trailer (low): it matches the session's attribution.
  • A full re-run of an already published release fails at the asset check if helm package is 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:

  • Verify that the downloaded release chart is exactly the chart packaged during preparation before any release attestations, signatures, tags, or publication occur.

Enhancements:

  • Record the packaged chart filename and SHA-256 checksum for use by the publish job.
  • Restrict chart attestation and signing to the verified chart file instead of matching arbitrary chart archives.
  • Document release rerun behavior and chart integrity checks.

Tests:

  • Add workflow assertions and execution tests covering chart identity, checksum validation, artifact contents, filename validation, hidden files, and step ordering.

uniqueg and others added 3 commits October 31, 2026 15:38
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]>
@sourcery-ai

sourcery-ai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

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

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

Flow diagram for chart validation before release signing

flowchart 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]
Loading

File-Level Changes

Change Details Files
Capture the packaged chart’s exact filename and SHA-256 as prepare outputs, while allowing reruns to replace the uploaded artifact.
  • Assign an ID to chart packaging and expose its filename and digest.
  • Keep chart artifact uploads configured with overwrite enabled.
.github/workflows/release.yml
Validate the downloaded chart before any image or chart attestation, signing, tagging, or release creation.
  • Require the expected chart filename and lowercase 64-character SHA-256 format.
  • Require exactly one file in dist/, including hidden files, and verify its checksum strictly.
  • Use the recorded chart path for provenance attestation and single-file signing.
  • Move chart download and validation ahead of all signing and attestation steps.
.github/workflows/release.yml
Document chart integrity validation and rerun behavior in the release workflow and development guide.
  • Explain that mismatches fail before anything is attested or signed.
  • Document that full reruns replace the chart artifact and validate the newly packaged chart.
.github/workflows/release.yml
docs/development.md
Add workflow-structure and behavioral tests covering chart output wiring, ordering, artifact replacement, and validation failures.
  • Assert output mappings, overwrite configuration, exact attestation/signing subjects, and security-sensitive step order.
  • Execute the workflow check script against valid, tampered, renamed, empty, extra, hidden, malformed-name, and malformed-checksum cases.
tests/test_workflows.py

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

@read-the-docs-community

read-the-docs-community Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 proTES | 🛠️ Build #35547060 | 📁 Comparing 82ffc4b against latest (4244881)

  🔍 Preview build  

4 files changed
+ plugin-images/index.html
± deployment/index.html
± development/index.html
± plugins/index.html

@codecov

codecov Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (e07e96d) to head (82ffc4b).

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.
📢 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 31, 2026 15:32

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


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

Comment thread .github/workflows/release.yml Resolved
Comment thread tests/test_workflows.py Resolved
Comment thread tests/test_workflows.py Resolved
uniqueg and others added 2 commits October 31, 2026 16:55
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]>
@uniqueg
uniqueg merged commit d0ef3e8 into dev Oct 31, 2026
19 checks passed
@uniqueg
uniqueg deleted the ci/353-chart-check branch October 31, 2026 16:15
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: check chart before signing anything

1 participant