Commit e248180
authored
fix(build): run hole-punch before signing to preserve code signature (#1037)
## Summary
Fixes #1033 — nightly macOS binaries had an invalid code signature
because `script/build.ts` ran `binpunch.processBinary()` **after**
`fossilize` had already signed + notarized the binary. The mutated bytes
invalidated the signature, causing macOS AMFI to SIGKILL the downloaded
binary, which surfaced as the opaque `Setup failed with exit code 1`
during `cli upgrade` — leaving the install bricked.
## Root cause
`postProcessTarget()` in `build.ts` called `processBinary(outfile)` at
line 388, **after** fossilize returned (which includes signing +
notarization on `main`/`release` builds). The hole-punched bytes broke
the signature.
### Why CI didn't catch it
The issue claimed "the darwin binary is never executed on macOS in CI" —
that's incorrect. CI runs the darwin-arm64 smoke test on `macos-latest`
with `can-test: true`, and it **passes** even on signed+hole-punched
`main` builds ([run
26542990891](https://github.com/getsentry/cli/actions/runs/26542990891)).
The real reason: AMFI only SIGKILLs an invalid-signature binary when it
carries the `com.apple.quarantine` xattr (i.e. after being
**downloaded**). A freshly-built binary on the build machine is not
quarantined.
## Changes
### 1. Move hole-punch into fossilize (`--hole-punch` flag)
- **Depends on
[BYK/fossilize#18](BYK/fossilize#18
(fossilize 0.8.0)
- Remove `binpunch` devDep and the post-sign `processBinary()` call from
`build.ts`
- Pass `--hole-punch` to the fossilize CLI invocation — fossilize now
runs binpunch internally between `chmod` and `sign+notarize`, so the
signature covers the final bytes
### 2. CI signature verification gate
- Add a `Verify code signature (darwin)` step using `rcodesign verify`
after the smoke tests, gated on `FOSSILIZE_SIGN=y` (main/release pushes)
+ darwin targets
- This catches broken signatures that execution-based smoke tests miss
(no quarantine xattr on CI)
### 3. Upgrade resilience (SIGKILL detection)
- In `spawnWithRetry()`: capture the `signal` parameter from the child's
`close` event
- When `signal === 'SIGKILL'`: throw a clear `UpgradeError` explaining
the likely cause (invalid code signature) instead of the opaque `Setup
failed with exit code 1`
### 4. Cleanup
- Remove duplicate top-level `patchedDependencies` (already present in
`pnpm` block)
- Update `.lore.md` pipeline description to reflect hole-punch running
inside fossilize
## Pipeline order (fixed)
```
download → unsign → strip → inject SEA → chmod → HOLE-PUNCH → sign + notarize → gzip
```
## Blocked on
- [ ] [BYK/fossilize#18](BYK/fossilize#18)
merged + released as 0.8.0 on npm (CI will fail to install
`fossilize@^0.8.0` until then)1 parent 5e68ac2 commit e248180
6 files changed
Lines changed: 46 additions & 31 deletions
File tree
- .github/workflows
- script
- src/commands/cli
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
308 | 308 | | |
309 | 309 | | |
310 | 310 | | |
311 | | - | |
| 311 | + | |
312 | 312 | | |
313 | 313 | | |
314 | 314 | | |
| |||
350 | 350 | | |
351 | 351 | | |
352 | 352 | | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
353 | 366 | | |
354 | 367 | | |
355 | 368 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | 29 | | |
31 | 30 | | |
32 | 31 | | |
33 | 32 | | |
34 | 33 | | |
35 | | - | |
| 34 | + | |
36 | 35 | | |
37 | 36 | | |
38 | 37 | | |
| |||
124 | 123 | | |
125 | 124 | | |
126 | 125 | | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
| 126 | + | |
133 | 127 | | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
37 | 36 | | |
38 | 37 | | |
39 | 38 | | |
| |||
321 | 320 | | |
322 | 321 | | |
323 | 322 | | |
| 323 | + | |
324 | 324 | | |
325 | 325 | | |
326 | 326 | | |
| |||
342 | 342 | | |
343 | 343 | | |
344 | 344 | | |
345 | | - | |
| 345 | + | |
346 | 346 | | |
347 | 347 | | |
348 | 348 | | |
| |||
361 | 361 | | |
362 | 362 | | |
363 | 363 | | |
364 | | - | |
| 364 | + | |
365 | 365 | | |
366 | 366 | | |
367 | 367 | | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
368 | 371 | | |
369 | 372 | | |
370 | 373 | | |
| |||
383 | 386 | | |
384 | 387 | | |
385 | 388 | | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | 389 | | |
396 | 390 | | |
397 | 391 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
432 | 432 | | |
433 | 433 | | |
434 | 434 | | |
435 | | - | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
436 | 452 | | |
437 | 453 | | |
438 | 454 | | |
| |||
0 commit comments