Skip to content

fix(release): restore the Windows inner-binary signature gate (#6487) - #10719

Merged
OrcaWin merged 4 commits into
mainfrom
nwparker/fix-6487-signing-gate-7za
Jul 27, 2026
Merged

OrcaWin merged 4 commits into
mainfrom
nwparker/fix-6487-signing-gate-7za

Conversation

@nwparker

@nwparker nwparker commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

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 7za to extract the installer. It resolved that binary from a hardcoded path:

node_modules/7zip-bin/win/x64/7za.exe

electron-builder 26.9 dropped the bundled 7zip-bin dependency 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) — resolves 7za in priority order:

  1. ELECTRON_BUILDER_7ZIP_PATH override, if it points at an actual file
  2. the legacy 7zip-bin layout, if that package is present
  3. electron-builder toolset via app-builder-lib/out/toolsets/7zip.js → getPath7za()

Both workflows now call the resolver and throw if it fails, so an unresolvable 7za produces 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 visible ERRORED verdict 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-2022 runner, so I could not execute it locally (no pwsh on 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.mjs parses 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 with Write-Host "::warning::would normally throw here but continuing: $7za" — restoring the exact fail-open — left all tests green.

config/scripts/resolve-7za-path.test.mjs covers the resolver directly: override precedence, directory-as-override rejection (PowerShell's Test-Path is true for directories, so an existsSync-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.

# Mutation Result
M1 Revert release-cut to the hardcoded 7zip-bin path KILLED
M2 Same revert in the rehearsal workflow KILLED
M8 Move $policyFailure = $message after the evidence writes KILLED
M9 Move the policy throw inside the try (into the masking catch) KILLED
M15a Downgrade the resolver throw to a Write-Host mentioning "throw" KILLED
M15b Same downgrade in the rehearsal workflow KILLED
M16 Gut Add-GateEvidence's try/catch, leave "catch" in a comment KILLED
M17 Replace the PASSED verdict write with a comment containing it KILLED
M18 Replace Set-Content with Write-Host, keep it in a comment KILLED
M19 Drop -ErrorAction Stop from the summary write KILLED
M20 Gut Add-GateSummary's try/catch KILLED
M21 Rename the evidence file in the gate only KILLED
M22 Rename the evidence file in the upload step only KILLED

M15a/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.txt and the job summary:

Branch Verdict
Inner signing was skipped NOT VERIFIED
All inner binaries signed VERDICT: PASSED — All N inner binaries…
Unsigned binaries found VERDICT: FAILED — …found N problems
Any exception ERRORED — <exception>

Verdict persistence is best-effort (try/catch around 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.

  • Gate policy unchanged. ORCA_WINDOWS_INNER_SIGNATURE_REQUIRED stays '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.
  • Trade-off — releases get noisier before they get quieter. The next release cut will likely surface a FAILED or ERRORED verdict that the broken gate was hiding. That is the point, but it is a real change in what release engineers see.
  • Cross-platform: the resolver runs under Node on any host and does its own platform mapping; both .github steps are already if: matrix.platform == 'win' / shell: pwsh. config/scripts/ tests run on all three CI platforms and pass here on macOS.
  • Perf: no runtime path affected. The gate adds one node invocation 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:

  • Round 1 — 4 findings, all fixed (override precedence, mac/ vs darwin/ layout, VITEST log suppression, stdout contamination).
  • Round 2 — 3 findings, all fixed (directory-as-override, concurrent stdout restoration, $policyFailure hoisted before I/O).
  • Round 3 — BLOCKING. Two tests asserted keyword presence in text, not keyword as executed statement; I reproduced the survivor myself before fixing. The reviewer independently found the same defect plus a third instance, and flagged the upload-filename coupling. All fixed; final verdict on the product code was NON-BLOCKING ("the silent-degradation class is genuinely closed end-to-end").
  • Round 4 — NON-BLOCKING. An independent pass over the rebased tip ran its own 12 mutations against this branch (all killed) and built an exhaustive 7-row exit-path table confirming no branch exits without a verdict and none double-writes the summary. One accuracy finding: the earlier wording implied release-cut now hard-fails on resolver failure. It doesn't — the throw is inside the gate's outer try, so it yields a visible ERRORED verdict. Wording corrected above. Remaining items were nits I left as-is: if-no-files-found: warn, the pathToFileURL CLI-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-bin is absent from the tree, and the belt-and-braces existsSync(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 🐋

@coderabbitai

coderabbitai Bot commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a shared Node.js resolver for locating the 7za executable through environment overrides, legacy paths, or app-builder-lib. Updates Windows signing workflows to use the resolver, validate the executable, persist evidence verdicts, and defer required-mode failures until reports are written. Adds tests for path resolution, archive extraction, environment overrides, stdout behavior, workflow integration, verdict persistence, and failure handling.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 76.92% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning It covers the fix well, but it does not follow the required template and is missing Screenshots, Testing checklist, Security Audit, and Notes sections. Reformat the PR description to match the template with Summary, Screenshots, Testing checklist, AI Review Report, Security Audit, and Notes sections.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title is concise and accurately summarizes the main change: restoring the Windows inner-binary signature gate.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (5)
config/scripts/resolve-7za-path.mjs (2)

75-92: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low value

ELECTRON_BUILDER_7ZIP_PATH delete/restore is not concurrency-safe across the await.

Unlike the stdout diversion, this global mutation is not refcounted: with overlapping resolve7zaPath calls and a dangling override set, the first finally reinstates the stale value while another call is still inside getPath7za(), which is the hard-fail this block exists to avoid. Same refcount treatment as withStdoutDivertedToStderr would close it.


82-83: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Avoid depending on app-builder-lib internal 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. Keep electron-builder as the main dependency and resolve 7-Zip through a stable CLI/fallback instead of importing app-builder-lib internals directly.

config/scripts/resolve-7za-path.test.mjs (2)

29-36: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Prefer an explicit skip over an early return.

The bare return reports this as a pass even though nothing was asserted; ctx.skip() (or it.skipIf) surfaces it in the "skipped" count instead of inflating the green ones.


38-61: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

These tests can hit the network on a cold cache.

resolve7zaPath falls through to getPath7za(), which downloads the electron-builder toolset, and the cold-cache test at Line 151 forces that path with a fresh ELECTRON_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 win

The 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 regress opens a bogus string span that runs to the next quote and silently shifts every downstream code/text blanking — the failure mode is a vacuously passing assertion, which is what this suite exists to prevent. Narrowing the scan to the extracted run: block (you already slice it in innerBinaryStep) 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

📥 Commits

Reviewing files that changed from the base of the PR and between 54e2240 and a3c684c.

📒 Files selected for processing (5)
  • .github/workflows/release-cut.yml
  • .github/workflows/windows-signing-rehearsal.yml
  • config/scripts/resolve-7za-path.mjs
  • config/scripts/resolve-7za-path.test.mjs
  • config/scripts/windows-signing-gate-toolset.test.mjs

Comment thread .github/workflows/release-cut.yml Resolved
Comment on lines +77 to +90
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('')
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Suggested change
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('')
}

nwparker and others added 3 commits July 26, 2026 15:23
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]>
@nwparker
nwparker force-pushed the nwparker/fix-6487-signing-gate-7za branch from a3c684c to a30d4a9 Compare July 26, 2026 22:23
@OrcaWin
OrcaWin merged commit 39a200d into main Jul 27, 2026
22 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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]>
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.

2 participants