Open source CapCut alternative.
TypeScript
fix(ci): scope bundled-tool library-validation entitlement to yt-dlp
David Le2e213d18610f
diff --git a/docs/guides/releasing-donkey.md b/docs/guides/releasing-donkey.mdindex 3d8a1948..49dd959f 100644--- a/docs/guides/releasing-donkey.md+++ b/docs/guides/releasing-donkey.md@@ -61,7 +61,12 @@ to know what to fetch). It runs on demand and whenever the tools recipe changes.Every tool is re-signed during the build: relocating their bundled librariesinvalidates the original signature, and macOS will not run an unsigned binary onApple Silicon. Without the secrets below the tools are only ad-hoc signed — fine-for local development, not for distribution.+for local development, not for distribution. `yt-dlp` additionally gets the+library-validation exception (`com.apple.security.cs.disable-library-validation`):+it self-extracts and loads its own Python framework at launch, which the hardened+runtime would otherwise reject for not sharing our Team ID. The other tools don't+get it — they load only the sibling libraries we re-sign, so they stay fully+hardened.Standalone CLI binaries cannot be stapled (only app/dmg/pkg bundles can), sonotarization here is the online proof that the Developer ID signature is good;diff --git a/scripts/sign-bundled-tools.sh b/scripts/sign-bundled-tools.shindex 48437eba..e1f4d480 100755--- a/scripts/sign-bundled-tools.sh+++ b/scripts/sign-bundled-tools.sh@@ -31,14 +31,42 @@ if [ "$IDENTITY" != "-" ]; thenreal_identity=truefi+# A PyInstaller onefile tool (yt-dlp) unpacks a private Python.framework to a temp dir at launch and+# dlopen()s it. Under the hardened runtime, library validation rejects that load ("mapping process and+# mapped file have different Team IDs") because the extracted framework isn't signed by our Team. The+# library-validation exception is the supported fix, scoped to exactly the executables that need it: every+# other bundled tool is self-contained or loads only the sibling dylibs we re-sign below (same Team ID, so+# validation passes), and keeps the hardened runtime fully enforced. Verified by signing each tool without+# the exception and launching it — only yt-dlp fails. Add a name here if a future bundled tool self-extracts+# a foreign-signed library. Entitlements belong on the executable that spawns the process, never on dylibs.+needs_library_validation_exception() {+ case "$(basename "$1")" in+ yt-dlp) return 0 ;;+ *) return 1 ;;+ esac+}+ENTITLEMENTS="$(mktemp -t donkey-tools-entitlements)"+trap 'rm -f "$ENTITLEMENTS"' EXIT+cat > "$ENTITLEMENTS" <<'PLIST'+<?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>com.apple.security.cs.disable-library-validation</key>+ <true/>+</dict>+</plist>+PLIST+is_macho() { file -b "$1" 2>/dev/null | grep -q "Mach-O"; }# A signing failure under a real identity must abort (an unsigned prod binary is a broken release); under-# ad-hoc it's tolerated so a non-Mach-O file (e.g. the exiftool Perl script) is simply skipped.+# ad-hoc it's tolerated so a non-Mach-O file (e.g. the exiftool Perl script) is simply skipped. Extra+# codesign args after the file (e.g. --entitlements for executables) are passed through.sign_one() {- local f="$1"+ local f="$1"; shiftis_macho "$f" || return 0- if codesign "${sign_opts[@]}" "$f" >/dev/null 2>&1; then+ if codesign "${sign_opts[@]}" "$@" "$f" >/dev/null 2>&1; thenreturn 0fiif $real_identity; then@@ -47,12 +75,18 @@ sign_one() {fi}-# Inside-out: dylibs (the dependencies) before the executables that load them.+# Inside-out: dylibs (the dependencies) before the executables that load them. Dylibs carry no+# entitlements; an executable gets the library-validation exception only if it self-extracts a+# foreign-signed library (see needs_library_validation_exception).while IFS= read -r -d '' f; do sign_one "$f"; done \< <(find "$VENDOR_DIR" -type f -name "*.dylib" -print0)while IFS= read -r -d '' f; docase "$f" in *.dylib) continue ;; esac- sign_one "$f"+ if needs_library_validation_exception "$f"; then+ sign_one "$f" --entitlements "$ENTITLEMENTS"+ else+ sign_one "$f"+ fidone < <(find "$VENDOR_DIR" -maxdepth 1 -type f -perm -u+x -print0)if $real_identity; then