Repository navigation
Refuse a Branch Git Would Not Name at the Release Gate, and Stop Printing It - #1530
Conversation
…ting It The branch input reached the job log raw in several places: the PyPI version step's log line, the validate-release gate's no-prerelease-suffix ::error::, and the upload and download artifact steps, which print an artifact name built from it. A value carrying a newline and a :: command, or a ##[ token the runner reads anywhere in a line, could form a workflow command at each of them. validate-release now refuses, before its smoke exit, any branch git would not accept as a name, using git check-ref-format --branch with both of its streams discarded since git echoes the name it checks. git's rules refuse ':', '[', and control characters, so every job that needs the gate sees a branch that cannot form either command. The PyPI log line and the gate's version message also stop printing the branch. Release-guard cases run the gate's own script: a develop prerelease and a valid smoke run pass, an injected branch is refused on smoke and non-smoke runs with nothing of it on stdout or stderr, and a valid branch still reaches the version check whose refusal names the version. The PyPI case asserts the version step prints no part of an injected branch. The branch's interpolation into a run: script elsewhere in the task is filed as #1529. Refs #1521 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🟡 Changes recommended
A newly added workflow error message uses a mid-sentence semicolon, which violates the repo's prose rules and may fail prose_lint.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR hardens the release workflow against GitHub Actions log-command injection by validating the branch input once at the validate-release gate using git check-ref-format --branch (with output suppressed), and by removing branch echoing from downstream log lines.
Changes:
- Add a
git check-ref-format --branchvalidation invalidate-releaseto reject branch inputs that Git would not accept, preventing::/##[/ control-character injection in logs. - Stop printing the branch in the PyPI version logging step and in the prerelease-suffix refusal message.
- Extend
scripts/tests/test_release_guards.pyto exercise the gate and ensure injected branch content is neither accepted nor echoed.
File summaries
| File | Description |
|---|---|
| scripts/tests/test_release_guards.py | Adds regression tests ensuring injected branch content is refused and never printed. |
| .github/workflows/build-release-task.yml | Validates inputs.branch with git check-ref-format --branch early and removes branch from an error message. |
| .github/actions/pypi-build-default/action.yml | Removes branch interpolation from the version log line (prints version only). |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
The branch refusal validate-release now emits read "...is not a valid git branch name; refusing to build.", a mid-sentence semicolon in agent-authored text, which the fleet's prose rules forbid. It now reads "...is not a valid git branch name, so the build is refused." Refs #1521 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
There was a problem hiding this comment.
🔵 Needs a closer look
The new git check-ref-format validation can incorrectly reject valid branch names that start with - unless option parsing is terminated with --.
Review details
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
.github/workflows/build-release-task.yml:139
git check-ref-formatwill treat a branch name starting with-as an option unless you terminate options with--, so this check can reject valid git branch names (e.g.-foo) even though the intent is to accept any name git would allow.
- Files reviewed: 3/3 changed files
- Comments generated: 0 new
- Review effort level: Lite
|
Answering the suppressed finding (1) in Copilot's review of 114a874, #1530 (review)
Disproven. A branch name starting with
|
…Hook SemVer2 (#1526) Promotes `develop` to `main`, carrying three merged pull requests. Closes #1521 ## What this promotes - [#1525](#1525) builds the hub `pypi-build-default` PEP 440 version from the `X.Y.Z` core of `SemVer2` instead of NBGV's `AssemblyFileVersion`. For a two-part `version.json` base NBGV fills that fourth segment from the commit id, so a default-branch package never matched the release tag cut beside it. - [#1528](#1528) drops two false statements from `WORKFLOW.md` D3.4 that review of this promotion raised: the promise that the develop `.dev0` build sorts above the default release, which NBGV height does not deliver since a promotion merge puts `main` one commit ahead of `develop`'s tip, and a *Prevents* clause crediting D3.4 with the renamed-branch protection D2.3's dispatch allowlist provides. It settles those two items of #1522. - [#1530](#1530) answers Copilot's finding on this promotion that the version step logged the `branch` input unsanitized. The release task's `validate-release` gate now refuses, before its smoke exit, any branch git would not accept as a name, so no value that reaches a later step can carry a newline and a `::` command or a `##[` token into the job log, and the PyPI version line and the gate's version message stop printing the branch. | #1521 item | Disposition | | --- | --- | | The default stamps `AssemblyFileVersion` (`M.N.P.B`) | Fixed: `SemVer2` with any prerelease or build segment dropped, `.dev0` on `develop` | | The `build-pypi` hook never receives `semver2` | Fixed: both the caller hook and the default receive it, as the `dotnet-publish` and `build-nuget` hooks already do | A value with no `X.Y.Z` core fails the step rather than stamping an empty or four-part version, and the rejected value is printed with every character outside SemVer's own set shown as `?`, so it can form no workflow command. `WORKFLOW.md` "Versioning", D3.4, and the section 6 `pypi` walkthrough state the new source. ## Adopter impact No fleet repository runs the hub default for a release yet, so no published package version changes. A caller `build-pypi` hook keeps receiving `assembly-file-version`, and one that does not declare the new `semver2` input draws only the runner's unexpected-input warning. ## Left open deliberately - [#1522](#1522): D2.2 names `github-release` as a job that does not opt out of the smoke skip, where the build jobs are the ones that do not. Its other two items are settled by #1528. - [#1523](#1523), [#1524](#1524), and [#1527](#1527): older `WORKFLOW.md` statements the tree contradicts, found by whole-unit review of the sections these changes touched and not introduced by them. - [#1529](#1529): the release task's asset-delete step and the documented publisher stubs interpolate the branch into a `run:` script, which crosses no permission boundary. - [#1531](#1531): `WORKFLOW.md` D2 does not yet describe the gate's branch-name refusal. ## Verification Each push ran whole-unit review over the `WORKFLOW.md` sections it touched and a local strict-review pass over the whole diff, then the hosted reviews. - The whole-unit rounds found the defects these changes themselves wrote, all fixed: a strip described as prerelease-only, a section 6 line still naming `AssemblyFileVersion`, a package-matches-tag claim that fails when `SemVer2` carries build metadata, and, once the ordering was dropped, a `--pre`-selectable sentence that read as a promise `pip install --pre` installs the develop build. - The local diff pass on #1525's fix caught that printing the rejected value through `printf %q` still let a legacy `##[` workflow command through, which the runner reads anywhere in a line. The value now prints through SemVer's own character set, and the test pinning that fails against the `%q` version. - Copilot reviewed every head at full coverage. On #1525 its findings were fixed or declined with evidence, on this promotion's first head its three findings were the ordering promise #1528 then dropped, and on #1528 its one finding was the *Prevents* clause, fixed there. - CodeRabbit reviewed #1525 on request, and its one finding was the same ordering promise. - #1530's local review rounds ran past the two-round budget twice, each time with the maintainer's explicit go-ahead. When each fix to one print surfaced the next print of the same unreachable input, the maintainer chose validating the branch once at the gate over sanitizing each print. Copilot's last round there raised one suppressed remark, disproven with git's own refusal of a branch name starting with `-`. - The new release-guard test fails four ways against the unfixed action, the full suite of 1388 tests passes, and the Docker linters, prose gate, spec validation, and generated-skill check are green. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Summary
Answers a Copilot finding on the promotion pull request #1526, that the
pypi-build-defaultversion step logged thebranchinput unsanitized. A value carrying a newline and a::command, or a##[token the runner reads anywhere in a line, could form a workflow command in the job log. The same raw branch also reached the log through thevalidate-releasegate's::error::and through the upload and download artifact steps, which print an artifact name built from it, so the fix validates the input once at the entry rather than chasing each print..github/workflows/build-release-task.yml:validate-releasenow refuses, before its smoke exit, any branch git would not accept as a name, throughgit check-ref-format --branchwith both streams discarded, since git echoes the name it checks. git's rules refuse:,[, and control characters, so every job that needs the gate receives a branch that cannot form either command. The gate's no-prerelease-suffix message also stops printing the branch..github/actions/pypi-build-default/action.yml: the version log line prints the version alone,PyPI version: <version>, since the step only compares the branch.scripts/tests/test_release_guards.py: cases run the gate's own script. A develop prerelease and a valid smoke run pass, an injected branch is refused on smoke and non-smoke runs with nothing of it on stdout or stderr, and a valid branch still reaches the version check, whose refusal names the version. The PyPI case asserts the version step prints no part of an injected branch. The gate test fails against the task without the new check.In practice the input is a real ref name,
mainordevelopon a publish, so a documented caller never trips the check. What changes is that a hand-supplied value git would reject now fails at the entry instead of flowing on.The pre-push review also found
${{ inputs.branch }}interpolated into arun:script in the task's release-asset delete step, and the same shape withgithub.ref_namein the documented stubs. That crosses no permission boundary and is filed as #1529.Verification
python3 -m unittest discover -s scripts/tests: all tests pass.scripts/docker_lint.py,prose_lint.py --diff origin/develop,spec/validate.py, andbuild_dist.py --checkpass. No carried canonical unit changes.🤖 Generated with Claude Code