fix(codesign): sign bundles with spaced paths; fail loudly on signing errors#116
Open
sepehr-safari wants to merge 1 commit into
Open
fix(codesign): sign bundles with spaced paths; fail loudly on signing errors#116sepehr-safari wants to merge 1 commit into
sepehr-safari wants to merge 1 commit into
Conversation
… errors `native package --signing adhoc|identity` composed the codesign invocation as a shell string run via `sh -c`, with the bundle path concatenated unquoted. An output path like "My App.app" word-split into "My" and "App.app", so codesign signed nothing and the command still exited 0 with an unsigned bundle (only the linker's inner-binary signature remained) — broken on Apple silicon with no error surfaced. Build the codesign / notarytool / stapler / ditto invocations as argv arrays spawned directly instead of `sh -c` strings. Passing argv straight to the OS keeps a spaced path a single argument and removes the command- injection surface from paths and identities. Make signing failures loud: when codesign runs and fails (or `--signing identity` is given no `--identity`), record the unsigned state in the signing plan and exit non-zero instead of shipping a broken bundle silently. A host that simply cannot sign (cross-packaging a macOS bundle off macOS, where codesign does not exist) stays tolerant and still succeeds with an unsigned bundle. Harden the test-package-signing gate to package to a spaced output path so the exact regression is covered end to end, and add argv unit tests that pin spaced paths as single arguments. Fixes vercel-labs#115.
|
@sepehr-safari is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
native package --signing adhoc|identitysilently shipped an unsigned macOS bundle when the output path contained spaces (e.g.My App.app). The command exited0, so a release built this way was broken with no error surfaced — on Apple silicon the unsigned bundle failscodesign --verifyand does not launch cleanly.Fixes #115.
Root cause
src/tooling/codesign.zigcomposed the codesign invocation as a shell string run viash -c, with the bundle path concatenated unquoted. A spaced path word-split (…/My App.app→…/My,App.app), so codesign errored with…/My: No such file or directory.runSigning()insrc/tooling/package.zigthen swallowed the failure — it noted the unsigned state insigning-plan.txtand returned normally, sonative packagestill exited0.Fix
sh -c.codesign/notarytool/stapler/dittoare now built as argv arrays and spawned directly (matching the existingsrc/tooling/ios.zigidiom). Passing argv straight to the OS keeps a spaced path a single argument and removes the shell command-injection surface from paths and identities.--signing identityis given no--identity— packaging now records the unsigned state and exits non-zero with a clear message, instead of shipping a broken bundle silently. A host that genuinely cannot sign (cross-packaging a macOS bundle off macOS, where codesign does not exist) stays tolerant and still succeeds with an unsigned bundle.test-package-signingnow packages to a spaced output path, so the exact scenario is covered end to end. New argv unit tests pin spaced paths as single arguments.Verification
zig build test— full suite green.scripts/gate.sh fast— all affected suites green.zig build test-package-signing(now a spaced path) —codesign --verify --strict --deeppasses; signature isflags=0x2(adhoc)(a real bundle seal, not the previous0x20002(adhoc,linker-signed)).package --signing adhoc --output "…/My App.app"→ exit 0, verify passes.--identity(codesign runs & fails) → exit 1 + clear message.--signing identitywith no--identity→ exit 1 + clear message.--signing none→ exit 0 (unchanged).Changelog
Adds a
fix:fragment underchangelog.d/.