Repository navigation
fix(release): restore the Windows inner-binary signature gate (#6487) - #10719
Conversation
📝 WalkthroughWalkthroughAdds a shared Node.js resolver for locating the 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
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.
Actionable comments posted: 2
🧹 Nitpick comments (5)
config/scripts/resolve-7za-path.mjs (2)
75-92: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low value
ELECTRON_BUILDER_7ZIP_PATHdelete/restore is not concurrency-safe across theawait.Unlike the stdout diversion, this global mutation is not refcounted: with overlapping
resolve7zaPathcalls and a dangling override set, the firstfinallyreinstates the stale value while another call is still insidegetPath7za(), which is the hard-fail this block exists to avoid. Same refcount treatment aswithStdoutDivertedToStderrwould close it.
82-83: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAvoid depending on
app-builder-libinternal toolset paths.
require('app-builder-lib/out/toolsets/7zip.js')is not part of the package’s documented public surface, so future path or export changes can break the release. Keepelectron-builderas the main dependency and resolve 7-Zip through a stable CLI/fallback instead of importingapp-builder-libinternals directly.config/scripts/resolve-7za-path.test.mjs (2)
29-36: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valuePrefer an explicit skip over an early
return.The bare
returnreports this as a pass even though nothing was asserted;ctx.skip()(orit.skipIf) surfaces it in the "skipped" count instead of inflating the green ones.
38-61: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winThese tests can hit the network on a cold cache.
resolve7zaPathfalls through togetPath7za(), which downloads the electron-builder toolset, and the cold-cache test at Line 151 forces that path with a freshELECTRON_BUILDER_CACHE. On an offline or rate-limited runner the suite fails for reasons unrelated to the change. Consider tagging these as an integration project (or gating on a network-availability check) so the default unit run stays hermetic.config/scripts/windows-signing-gate-toolset.test.mjs (1)
26-74: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winThe scanner treats any apostrophe in YAML prose as a string opener.
The whole workflow file is scanned, not just the PowerShell blocks, so a future step named e.g.
Verify the installer doesn't regressopens a bogus string span that runs to the next quote and silently shifts every downstreamcode/textblanking — the failure mode is a vacuously passing assertion, which is what this suite exists to prevent. Narrowing the scan to the extractedrun:block (you already slice it ininnerBinaryStep) would contain the blast radius.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 00f1444d-58ba-4a05-ad51-9eeeb2e9be96
📒 Files selected for processing (5)
.github/workflows/release-cut.yml.github/workflows/windows-signing-rehearsal.ymlconfig/scripts/resolve-7za-path.mjsconfig/scripts/resolve-7za-path.test.mjsconfig/scripts/windows-signing-gate-toolset.test.mjs
| function blank(source, spans, kinds) { | ||
| const chars = [...source] | ||
| for (const span of spans) { | ||
| if (!kinds.includes(span.kind)) { | ||
| continue | ||
| } | ||
| for (let i = span.start; i < span.end; i += 1) { | ||
| if (chars[i] !== '\n') { | ||
| chars[i] = ' ' | ||
| } | ||
| } | ||
| } | ||
| return chars.join('') | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
[...source] splits by code point but the span offsets are UTF-16 indices.
Any astral character (an emoji in a workflow comment or step name) desynchronizes chars[i] from span.start/end, and chars.join('') no longer has the same length the doc comment promises — every index-based assertion below then silently targets the wrong text. source.split('') keeps UTF-16 alignment.
🛠️ Proposed fix
- const chars = [...source]
+ const chars = source.split('')📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| function blank(source, spans, kinds) { | |
| const chars = [...source] | |
| for (const span of spans) { | |
| if (!kinds.includes(span.kind)) { | |
| continue | |
| } | |
| for (let i = span.start; i < span.end; i += 1) { | |
| if (chars[i] !== '\n') { | |
| chars[i] = ' ' | |
| } | |
| } | |
| } | |
| return chars.join('') | |
| } | |
| function blank(source, spans, kinds) { | |
| const chars = source.split('') | |
| for (const span of spans) { | |
| if (!kinds.includes(span.kind)) { | |
| continue | |
| } | |
| for (let i = span.start; i < span.end; i += 1) { | |
| if (chars[i] !== '\n') { | |
| chars[i] = ' ' | |
| } | |
| } | |
| } | |
| return chars.join('') | |
| } |
electron-builder 26.9+ dropped the bundled 7zip-bin package, so the gate's hardcoded node_modules/7zip-bin path stopped resolving in 1d2cd33. The gate is fail-open, so it swallowed the error and 11 releases shipped with no signature verification and an evidence artifact that looked clean. Resolve 7za through app-builder-lib's toolset instead, and always record a verdict so a degraded gate can't pass for a healthy one. Refs #6487
… code, not text
The round-2 harness matched /\bthrow\b/ and /\bcatch\b/ against raw block text, so
the word satisfied the assertion wherever it appeared. Downgrading the resolver
throw to `Write-Host "...would normally throw..."` — the exact silent fail-open
this PR exists to kill — left all 11 tests green.
Every span is now classified once (code / string / comment) by the same walk that
pairs braces, and assertions run against the string-and-comment-blanked view.
Blanking preserves length, so indices still line up across views.
Also re-anchors the catch-ordering test: `blockAfter(step, '} catch {')` picked
the first catch in the step, which stopped being the gate's own once the
persistence helpers grew theirs — moving the policy throw inside the try was
passing again.
Co-authored-by: Orca <[email protected]>
…he upload collects The upload step is `if-no-files-found: ignore`, so renaming the evidence file on one side and not the other ships a green run whose artifact silently omits the verdict — the same silent-degradation class this PR exists to close. Co-authored-by: Orca <[email protected]>
a3c684c to
a30d4a9
Compare
…ai#6487) (stablyai#10719) * fix(release): restore the Windows inner-binary signature gate electron-builder 26.9+ dropped the bundled 7zip-bin package, so the gate's hardcoded node_modules/7zip-bin path stopped resolving in 816f5ce. The gate is fail-open, so it swallowed the error and 11 releases shipped with no signature verification and an evidence artifact that looked clean. Resolve 7za through app-builder-lib's toolset instead, and always record a verdict so a degraded gate can't pass for a healthy one. Refs stablyai#6487 * test(release): make the signing-gate structural tests assert executed code, not text The round-2 harness matched /\bthrow\b/ and /\bcatch\b/ against raw block text, so the word satisfied the assertion wherever it appeared. Downgrading the resolver throw to `Write-Host "...would normally throw..."` — the exact silent fail-open this PR exists to kill — left all 11 tests green. Every span is now classified once (code / string / comment) by the same walk that pairs braces, and assertions run against the string-and-comment-blanked view. Blanking preserves length, so indices still line up across views. Also re-anchors the catch-ordering test: `blockAfter(step, '} catch {')` picked the first catch in the step, which stopped being the gate's own once the persistence helpers grew theirs — moving the policy throw inside the try was passing again. Co-authored-by: Orca <[email protected]> * test(release): pin the evidence filename the gate writes to the one the upload collects The upload step is `if-no-files-found: ignore`, so renaming the evidence file on one side and not the other ships a green run whose artifact silently omits the verdict — the same silent-degradation class this PR exists to close. Co-authored-by: Orca <[email protected]> * fix(release): preserve 7za resolver failures --------- Co-authored-by: Orca <[email protected]> Co-authored-by: OrcaWin <[email protected]>
Fixes the fail-open failure of the Windows inner-binary signature gate (#6487, #7785).
What was broken
The gate that verifies every PE file inside the shipped NSIS installer is signed shells out to
7zato extract the installer. It resolved that binary from a hardcoded path:electron-builder 26.9 dropped the bundled
7zip-bindependency in favour of a toolset it downloads on demand, so that path stopped existing. The gate emitted a warning from its outer catch, but because the gate is deliberately warn-only, the step remained green and the evidence artifact had no terminal verdict.It has therefore skipped signature verification across multiple releases while the overall release job remained green.
ELI5
We have a security guard who checks every box in a shipping crate. Someone moved the crowbar he uses to open the crate. The guard called out that he could not inspect it, but his alarm was advisory, so shipping continued and the inspection report had no clear verdict.
This PR (a) tells him where the crowbar actually lives, and (b) makes "I can't open the crate" a clear verdict instead of an ambiguous green result.
The fix
config/scripts/resolve-7za-path.mjs(new) — resolves7zain priority order:ELECTRON_BUILDER_7ZIP_PATHoverride, if it points at an actual file7zip-binlayout, if that package is presentapp-builder-lib/out/toolsets/7zip.js→getPath7za()Both workflows now call the resolver and throw if it fails, so an unresolvable
7zaproduces a visible error instead of an ambiguous green result.Note on what "aborts" means per workflow, because they differ: in the rehearsal the throw is uncaught and fails the job. In release-cut it lands inside the gate's own outer
try, so it becomes a visibleERROREDverdict in the evidence file and job summary rather than a blocked release. That is deliberate while the gate is warn-only — but it means this PR makes resolver failure loud, not fatal, on the release path.Fix proof
The failure mode is a CI-only PowerShell gate on a
windows-2022runner, so I could not execute it locally (nopwshon this machine). Proof is therefore structural + mutation-based rather than a screenshot of a green run — pinning the invariants so the degradation cannot silently return.config/scripts/windows-signing-gate-toolset.test.mjsparses the workflow YAML with a PowerShell-aware scanner that classifies every span as code, string, or comment, then asserts against the code-only view. That distinction is load-bearing: an earlier revision of these tests matched/\bthrow\b/against raw text, and replacing the resolver throw withWrite-Host "::warning::would normally throw here but continuing: $7za"— restoring the exact fail-open — left all tests green.config/scripts/resolve-7za-path.test.mjscovers the resolver directly: override precedence, directory-as-override rejection (PowerShell'sTest-Pathis true for directories, so anexistsSync-only check would let a folder satisfy the gate and fail later as an opaque exec error), toolset fallback, and concurrent stdout restoration.Mutation testing
Every mutation below was applied to the workflow or resolver, the suite was run, and the result recorded. 13 applied, 13 killed.
7zip-binpath$policyFailure = $messageafter the evidence writestry(into the masking catch)throwto aWrite-Hostmentioning "throw"Add-GateEvidence's try/catch, leave "catch" in a commentSet-ContentwithWrite-Host, keep it in a comment-ErrorAction Stopfrom the summary writeAdd-GateSummary's try/catchM15a/M16/M17 are the ones the earlier text-matching harness let through. M21/M22 pin a gap the reviewer found: the upload is
if-no-files-found: ignore, so a one-sided rename would ship a green run whose artifact silently omits the verdict.Evidence contract
A gate that writes nothing is indistinguishable from a gate that passed, so every terminal branch now leaves a verdict in both
inner-signing-evidence.txtand the job summary:NOT VERIFIEDVERDICT: PASSED — All N inner binaries…VERDICT: FAILED — …found N problemsERRORED — <exception>Verdict persistence is best-effort (
try/catcharound each write): while the gate is warn-only, a disk-full or read-only runner must not become the thing that fails a release.Regressions / risk
0 regressions. No product code is touched — the diff is two CI workflows plus a build script and its tests. Nothing here ships in the app bundle.
ORCA_WINDOWS_INNER_SIGNATURE_REQUIREDstays'false', so this PR does not start blocking releases. It changes a warn-only gate with an ambiguous green result into one that visibly reports FAILED/ERRORED. Flipping to'true'is deliberate follow-up under Windows: bundled node-pty conpty_console_list.node flagged by antivirus as Trojan.Win64.YOGI #7785..githubsteps are alreadyif: matrix.platform == 'win'/shell: pwsh.config/scripts/tests run on all three CI platforms and pass here on macOS.nodeinvocation per Windows release job.getPath7za()memoises at module level, and its download-progress output is diverted to stderr so it cannot corrupt the path the workflow reads from stdout (refcounted, so concurrent callers cannot leave a diverting stub installed permanently).Review loop
Reviewed by sub-agents (gpt-5.6-sol ↔ fable) over 3 rounds, plus my own independent verification of each finding:
mac/vsdarwin/layout, VITEST log suppression, stdout contamination).$policyFailurehoisted before I/O).try, so it yields a visibleERROREDverdict. Wording corrected above. Remaining items were nits I left as-is:if-no-files-found: warn, thepathToFileURLCLI-guard idiom, and appending the partial report on mid-loop exceptions.Two guards remain untested and I am flagging rather than hiding them: override-vs-legacy ordering is unobservable while
7zip-binis absent from the tree, and the belt-and-bracesexistsSync(toolsetPath)check has no failing input available. Both are defensive-only; mutating either survives the suite.Final state: 14 workflow-gate tests + 15 resolver tests green; 451 passed / 4 skipped across
config/scripts/; both workflows parse as valid YAML; typecheck, oxfmt and oxlint clean.Made with Orca 🐋