Repository navigation
Add universal macOS release artifact guard #4744
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5e2a30e
Add universal macOS release artifact guard
austinywang a8d9c95
Tighten universal verifier coverage
austinywang 9eea928
Merge remote-tracking branch 'origin/main' into issue-293-intel-x86-6…
austinywang dbfbff9
Merge remote-tracking branch 'origin/main' into issue-293-intel-x86-6…
austinywang 37bee4a
Merge remote-tracking branch 'origin/main' into issue-293-intel-x86-6…
austinywang a849de9
merge: resolve conflicts with main
austinywang acf2897
fix: align workflow guard with universal verifier
austinywang de49750
fix: narrow CI workflow permissions
austinywang 9822afe
fix: address release verifier review feedback
austinywang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| usage() { | ||
| cat <<'EOF' | ||
| Usage: ./scripts/verify-universal-macos-app.sh <app-path> [--label <name>] | ||
|
|
||
| Verifies that the app executable, bundled cmux CLI, and bundled Ghostty helper | ||
| all contain both arm64 and x86_64 Mach-O slices. | ||
| EOF | ||
| } | ||
|
|
||
| APP_PATH="" | ||
| LABEL="macOS app" | ||
| while [[ $# -gt 0 ]]; do | ||
| case "$1" in | ||
| --label) | ||
| LABEL="${2:-}" | ||
| shift 2 | ||
| ;; | ||
|
austinywang marked this conversation as resolved.
Resolved
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| -h|--help) | ||
| usage | ||
| exit 0 | ||
| ;; | ||
| -*) | ||
| echo "Unknown option: $1" >&2 | ||
| usage >&2 | ||
| exit 1 | ||
| ;; | ||
| *) | ||
| if [[ -n "$APP_PATH" ]]; then | ||
| echo "Unexpected argument: $1" >&2 | ||
| usage >&2 | ||
| exit 1 | ||
| fi | ||
| APP_PATH="$1" | ||
| shift | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| if [[ -z "$APP_PATH" ]]; then | ||
| usage >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ -z "$LABEL" ]]; then | ||
| echo "Missing value for --label" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ ! -d "$APP_PATH" ]]; then | ||
| echo "error: app bundle not found at $APP_PATH" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| LIPO_BIN="${CMUX_LIPO:-lipo}" | ||
| if ! command -v "$LIPO_BIN" >/dev/null 2>&1; then | ||
| echo "error: lipo is required to verify universal macOS binaries" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| INFO_PLIST="$APP_PATH/Contents/Info.plist" | ||
| EXECUTABLE_NAME="" | ||
| if [[ -f "$INFO_PLIST" && -x /usr/libexec/PlistBuddy ]]; then | ||
| EXECUTABLE_NAME="$(/usr/libexec/PlistBuddy -c "Print :CFBundleExecutable" "$INFO_PLIST" 2>/dev/null || true)" | ||
| fi | ||
| if [[ -z "$EXECUTABLE_NAME" ]]; then | ||
| EXECUTABLE_NAME="$(basename "$APP_PATH" .app)" | ||
| fi | ||
|
|
||
| APP_BINARY="$APP_PATH/Contents/MacOS/$EXECUTABLE_NAME" | ||
| CLI_BINARY="$APP_PATH/Contents/Resources/bin/cmux" | ||
| HELPER_BINARY="$APP_PATH/Contents/Resources/bin/ghostty" | ||
|
|
||
| verify_binary_archs() { | ||
| local name="$1" | ||
| local path="$2" | ||
| local archs | ||
|
|
||
| if [[ ! -x "$path" ]]; then | ||
| echo "error: $name is missing or not executable at $path" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if ! archs="$("$LIPO_BIN" -archs "$path")"; then | ||
| echo "error: failed to inspect $name architectures at $path" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "$LABEL $name architectures: $archs" | ||
| for expected_arch in arm64 x86_64; do | ||
| case " $archs " in | ||
| *" $expected_arch "*) | ||
| ;; | ||
| *) | ||
| echo "error: $name at $path is missing $expected_arch slice" >&2 | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| done | ||
| } | ||
|
|
||
| verify_binary_archs "app binary" "$APP_BINARY" | ||
| verify_binary_archs "CLI binary" "$CLI_BINARY" | ||
| verify_binary_archs "Ghostty helper" "$HELPER_BINARY" | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)" | ||
| TMP_DIR="$(mktemp -d "${TMPDIR:-/tmp}/cmux-universal-verify.XXXXXX")" | ||
| trap 'rm -rf "$TMP_DIR"' EXIT | ||
|
|
||
| APP_PATH="$TMP_DIR/cmux.app" | ||
| FAKE_LIPO="$TMP_DIR/lipo" | ||
|
|
||
| mkdir -p "$APP_PATH/Contents/MacOS" "$APP_PATH/Contents/Resources/bin" | ||
| cat > "$APP_PATH/Contents/Info.plist" <<'EOF' | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
| <plist version="1.0"> | ||
| <dict> | ||
| <key>CFBundleExecutable</key> | ||
| <string>cmux</string> | ||
| </dict> | ||
| </plist> | ||
| EOF | ||
|
|
||
| touch "$APP_PATH/Contents/MacOS/cmux" | ||
| touch "$APP_PATH/Contents/Resources/bin/cmux" | ||
| touch "$APP_PATH/Contents/Resources/bin/ghostty" | ||
| chmod 755 \ | ||
| "$APP_PATH/Contents/MacOS/cmux" \ | ||
| "$APP_PATH/Contents/Resources/bin/cmux" \ | ||
| "$APP_PATH/Contents/Resources/bin/ghostty" | ||
|
|
||
| cat > "$FAKE_LIPO" <<'EOF' | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
| if [[ "${1:-}" != "-archs" || $# -ne 2 ]]; then | ||
| echo "unexpected lipo invocation" >&2 | ||
| exit 2 | ||
| fi | ||
| cat "$2.archs" | ||
| EOF | ||
| chmod +x "$FAKE_LIPO" | ||
|
|
||
| set_archs() { | ||
| printf '%s\n' "$2" > "$1.archs" | ||
| } | ||
|
|
||
| VERIFY_SCRIPT="$ROOT_DIR/scripts/verify-universal-macos-app.sh" | ||
| export CMUX_LIPO="$FAKE_LIPO" | ||
|
|
||
| set_archs "$APP_PATH/Contents/MacOS/cmux" "x86_64 arm64" | ||
| set_archs "$APP_PATH/Contents/Resources/bin/cmux" "arm64 x86_64" | ||
| set_archs "$APP_PATH/Contents/Resources/bin/ghostty" "arm64 x86_64" | ||
| "$VERIFY_SCRIPT" "$APP_PATH" --label "fixture app" >/dev/null | ||
|
|
||
| set_archs "$APP_PATH/Contents/Resources/bin/ghostty" "arm64" | ||
| if "$VERIFY_SCRIPT" "$APP_PATH" --label "fixture app" >"$TMP_DIR/missing-slice.out" 2>"$TMP_DIR/missing-slice.err"; then | ||
| echo "FAIL: verifier accepted a helper missing the x86_64 slice" >&2 | ||
| exit 1 | ||
| fi | ||
| if ! grep -Fq "missing x86_64 slice" "$TMP_DIR/missing-slice.err"; then | ||
| echo "FAIL: verifier did not explain the missing x86_64 slice" >&2 | ||
| cat "$TMP_DIR/missing-slice.err" >&2 | ||
| exit 1 | ||
| fi | ||
|
austinywang marked this conversation as resolved.
Resolved
|
||
|
|
||
| rm "$APP_PATH/Contents/Resources/bin/cmux" | ||
| if "$VERIFY_SCRIPT" "$APP_PATH" --label "fixture app" >"$TMP_DIR/missing-cli.out" 2>"$TMP_DIR/missing-cli.err"; then | ||
| echo "FAIL: verifier accepted an app bundle missing the embedded CLI" >&2 | ||
| exit 1 | ||
| fi | ||
| if ! grep -Fq "CLI binary is missing or not executable" "$TMP_DIR/missing-cli.err"; then | ||
| echo "FAIL: verifier did not explain the missing CLI" >&2 | ||
| cat "$TMP_DIR/missing-cli.err" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "PASS: universal macOS app verifier enforces app, CLI, and helper slices" | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--require-sdk-prefix "26.", which means an app accidentally built against macOS 15 (or any non-26 SDK) would pass this gate and continue through signing, notarization, and upload. Every other release path —release.yml,nightly.yml, and CIrelease-build— all pass--require-sdk-prefix "26.". The PR explicitly lists this script as one of the hardened paths.