ci(signing): Linux DEV signer with stock rcodesign, and its fixture test

Merged
TE
25d ago
+641-0

First of two PRs that move the cmux NEXT DEV signing off a Mac. This one adds the Linux signer and its test (631 lines). Nothing calls it yet; the second PR switches the cmux-next-dev-daily.yml sign job to Blacksmith Linux and keeps the Mac verify job as the codesign check of the Linux output. Agreed with the publisher's owner after the DEV feed stalled for 6 h behind a single macOS runner label (fixed for now by #25371, which moved sign to the 6 vCPU Mac).

Change

  • scripts/ci/rcodesign-sign-bundle-dev.sh: the Linux counterpart of feat-cmux-next's scripts/sign-cmux-bundle.sh (blob 6b967e0c). The DEV app is a feat-cmux-next app, so it follows that branch's order, not main's. It uses the stock apple-codesign 0.29.0 release.

    • Signing order, step by step:
      • Entitlements: reconciled with the embedded profile, refusing the Cloud tunnel and SystemExtensions.
      • 0. Server launchd plists: LaunchDaemons and LaunchAgents are stamped from the final app (plistlib; same labels, BundleProgram, arguments, MachServices). A com.cmuxterm.app bundle id drops them.
      • 1. Resources/bin and libexec: helper entitlements. cmux-server-helper gets none and its fixed identifier. Scripts stay sealed by the bundle.
      • tui-ssh payloads: signed on their own, re-pinned in manifest.json, then excluded from the bundle pass.
      • 2. Computer Use: helper entitlements on its executable.
      • 3. PlugIns: none.
      • Sparkle sandbox XPC services: removed.
      • 4. CEF (as sign-cef.sh): the framework, libraries and shim get none. Each * Helper (GPU).app and * Helper (Renderer).app gets allow-jit, the other helpers none.
      • Remote browser host (as rbh_sign): its helpers follow the same jit rule; the host app gets none.
      • Other frameworks: none.
      • 5. Main bundle: the reconciled entitlements.
    • Signing options: hardened runtime on every Mach-O, --for-notarization (Developer ID plus Apple's time stamp), and rcodesign verify on every signed Mach-O.
    • Pre-sign checks: the CLI alias symlink check and the entitlement-content checks (application-identifier, web-browser and personal-information keys present, no NetworkExtension, no application-identifier in the helper entitlements) run on the entitlement files before signing.
    • Inherited entitlements: rcodesign keeps entitlements that codesign --force drops, so a component signed "with no entitlements" whose current signature has some gets an empty set. A failed print-signature-info probe fails the job and names the path.
    • Helpers absent on main: the feat-cmux-next helpers (sign-cmux-bundle-helpers.sh, sign-cef.sh, remote-browser-host-layout.sh, bundle-server-helper.sh) don't exist on main, which the DEV sign job checks out for trusted scripts. Their rules are written into this script, with each source's blob named.
    • Key material: the PKCS#12 is decoded into a 0700 mktemp -d directory that an EXIT trap removes. openssl reads stdin and takes the password via -passin env:, and rcodesign gets only the PEM path. No secret is on any argv.
    • Output differences: the output differs from codesign only in bytes codesign --verify --deep --strict accepts:
      • 4 KiB page hashes;
      • signature reservation and __LINKEDIT;
      • DER rather than BER framing;
      • re-serialized entitlements XML;
      • signing time, time stamp and RSA, which differ between any two runs.
  • Steps not done on Linux, and why:

    • Keychain unlock: there is no keychain.
    • CMUX_SIGN_MODE other than all, and CMUX_NEXT_CEF_ON_DEMAND: the DEV job uses neither, so the script refuses both.
    • Checks that need Apple's codesign or run bundle code: codesign --verify --deep --strict, the Computer Use verify, the diff sidecar, check-bundled-browser-host.sh --hardened, and codesign -d reads of the signed result. They move to the workflow's Mac verify job in the second PR, which publish waits on.
  • tests/test_rcodesign_sign_bundle_dev.py: a fake-rcodesign fixture (6 tests). It checks:

    • per-path runtime and entitlements, including allow-jit on CEF and remote-browser-host GPU/Renderer;
    • clearing of the other helpers, cmux-server-helper and a CEF library;
    • the server helper's identifier, and both launchd plists' exact contents;
    • ordering: the bundle pass sees the stamped plists and no XPC or ._ files, and the payload is signed before the bundle seals its new pin;
    • the tunnel and SystemExtensions refusals;
    • non-zero exits on a failed sign, a failed verify, a failed probe, a bad password and identity mismatches;
    • the key path only after --pem-file, no secret on any argv, and no temp files left.

    Breaking the script on purpose is caught each time, eleven ways in all. It runs in ci-guards.yml's release-notary group.

Not in this PR

  • The workflow switch comes in the second PR: sign on Blacksmith Linux; the tip DMG built, signed and submitted in the Mac tip job; verify on an owned Mac first (Blacksmith 6 vCPU as the fallback) with the codesign checks above; publish gated on verify. So does the pinned rcodesign installer.
  • Today's Mac job signs this app with main's script. That means allow-jit on CEF GPU/Renderer, the server helper's identifier and the plist stamping differ from what the Mac job produces now. The published DEV app has no CEF framework or helpers today, so allow-jit has nothing to apply to yet.

Numbers

None yet: no job uses this until the second PR. It is the script that lets the DEV sign job (today a blacksmith-6vcpu-macos-26 job of about 3-5 min per publish) run on Linux.

Agent session: agent session

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Improved Linux DEV app signing checks, including validation of app bundles and their signed components. Signing failures are now detected during automated checks.
  • Tests
    • Added coverage for signing success and failure cases, helping catch issues with Linux DEV builds before release.