Skip to content

ci: check chart artifact before signing - #296

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

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

Conversation

@uniqueg

@uniqueg uniqueg commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

Summary

The publish job of the release workflow attested, signed and released whatever the downloaded chart artifact 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:

  • prepare outputs the packaged chart's file name and SHA-256 (chart_file, chart_sha256).
  • publish downloads 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 that dist/ 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).
  • The attestation (subject-path) and the cosign signature now name the checked file exactly instead of dist/*.tgz. This goes beyond trs-filer: the attest action's glob matches hidden files, which trs-filer's check doesn't count (see below).
  • The chart upload sets overwrite: true (as in trs-filer), so that re-running all jobs replaces the earlier attempt's chart, and the new checksum matches.
  • Image: no change needed. publish gets the digest as a job output of push, not as an artifact, so other jobs can't change it, and it already checks the digest's format.
  • Docs: docs/development.md (the release steps and re-runs) and the header comment of release.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) and test_release_chart_check_runs, which runs the step's script with bash -e -o pipefail against 7 cases: good, wrong hash, extra file, hidden file, renamed chart, bad name output, bad checksum output. Mutation check: dropping dotglob makes the hidden case fail.
  • Full suite with coverage: 1540 passed, 262 skipped (tests that need services or Helm), 100% coverage of cloud_registry and scripts.
  • pre-commit run --all-files passed (ruff, semgrep, gitleaks, actionlint, ast-grep, mypy).
  • Local dry run of the check script taken from the workflow, outside pytest. Cases: good chart OK; wrong hash, extra file, hidden file, renamed chart, empty artifact, invalid name output and invalid checksum output all fail with a clear error.
  • CI on 05fb32b: all checks passed; CI on 955fa45 (step reorder after the Sourcery review): all checks passed, Sourcery review passed (approved) (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.
  • Not verifiable locally: a real release run (artifact upload/download, attestation, signing). It runs at the next tag.

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

  • Skip guard for missing 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 nullglob without dotglob, attestation of dist/*.tgz), so it should get the same follow-up there.

Open questions

None.

🤖 Generated with Claude Code

uniqueg and others added 3 commits October 31, 2026 12:05
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]>
@uniqueg uniqueg added this to the v1.0.0-rc1 milestone Oct 31, 2026
@uniqueg uniqueg added type: ci / cd Related to continuous integration / delivery type: security Related to security labels Oct 31, 2026
@sourcery-ai

sourcery-ai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

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

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

File-Level Changes

Change Details Files
Records the packaged chart’s exact filename and SHA-256 as prepare outputs, and replaces the uploaded artifact on full reruns.
  • Adds chart packaging outputs for filename and checksum.
  • Enables artifact overwrite so reruns publish the newly packaged chart.
.github/workflows/release.yml
Validates the downloaded chart before any attestation, signing, or release operation.
  • Validates filename and checksum formats.
  • Requires dist/ to contain exactly one entry, including hidden files, with the expected name.
  • Verifies the downloaded file using strict SHA-256 checking.
  • Targets attestation and cosign signing at the validated file rather than a glob.
.github/workflows/release.yml
Documents the chart integrity check and rerun behavior.
  • Describes the recorded name/checksum verification during publishing.
  • Explains that full reruns replace the chart artifact and validate the replacement.
docs/development.md
Adds workflow wiring assertions and executable coverage for chart validation.
  • Checks prepare outputs, overwrite configuration, step ordering, and exact attestation/signing subjects.
  • Runs the workflow check script against valid, tampered, renamed, extra-file, hidden-file, and malformed-input 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

The release version must not be hard-coded (test_version_mentions).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@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 (893c1c5) to head (955fa45).

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.
📢 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 12:28

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


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

Comment thread .github/workflows/release.yml Resolved
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]>

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

Sourcery assessment

Approved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: ci / cd Related to continuous integration / delivery type: security Related to security

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Release: verify chart artifact before signing

1 participant