Repository Public
1#!/usr/bin/env bash2# Author: Simon-Pierre Boucher — contact@spboucher.ai3# File: Scripts/verify-release.sh4# Description: Checks the signed application and its File Provider extension: signatures, hardened runtime, sandbox and entitlements, embedded profiles, no web engine, no debug entitlement, no development switch, no secrets in the bundle.5#6# Usage: Scripts/verify-release.sh [path/to/SP Drive.app] (exit code ≠ 0 when a check fails)7set -uo pipefail8cd "$(dirname "$0")/.."9APP="${1:-dist/SP Drive.app}"; BIN="$APP/Contents/MacOS/SP Drive"; EXT="$APP/Contents/PlugIns/SPDriveFileProvider.appex"; EXTBIN="$EXT/Contents/MacOS/SPDriveFileProvider"; FAIL=010ok() { echo " ✓ $1"; }; ko() { echo " ✗ $1"; FAIL=1; }11[[ -d "$APP" ]] || { echo "ERROR: $APP not found" >&2; exit 1; }12for target in "$APP" "$EXT"; do13 echo "== Signature: $(basename "$target")"14 codesign --verify --deep --strict "$target" 2>/dev/null && ok "codesign --verify --deep --strict" || ko "signature invalid"15 INFO="$(codesign -dvv "$target" 2>&1)"16 grep -q "Authority=Developer ID Application" <<<"$INFO" && ok "$(grep -m1 '^Authority=' <<<"$INFO")" || ko "not signed with Developer ID Application"17 grep -Eq "flags=.*runtime" <<<"$INFO" && ok "hardened runtime enabled" || ko "hardened runtime missing"18 grep -q "^Timestamp=" <<<"$INFO" && ok "secure timestamp present" || ko "no secure timestamp"19 grep -q "^Identifier=ai.spboucher.spdrive\(.fileprovider\)\?$" <<<"$INFO" && ok "$(grep -m1 '^Identifier=' <<<"$INFO")" || ko "unexpected identifier: $(grep -m1 '^Identifier=' <<<"$INFO")"20 ENT="$(codesign -d --entitlements :- "$target" 2>/dev/null)"21 grep -A1 "com.apple.security.app-sandbox" <<<"$ENT" | grep -q "<true/>" && ok "App Sandbox on" || ko "App Sandbox off"22 grep -q "3YM54G49SN.ai.spboucher.spdrive</string>" <<<"$ENT" && ok "app group 3YM54G49SN.ai.spboucher.spdrive" || ko "app group missing"23 grep -q "3YM54G49SN.ai.spboucher.spdrive.shared" <<<"$ENT" && ok "shared keychain group" || ko "shared keychain group missing"24 grep -q "get-task-allow" <<<"$ENT" && ko "get-task-allow present (debug entitlement)" || ok "no get-task-allow"25 for bad in com.apple.security.cs.disable-library-validation com.apple.security.cs.allow-unsigned-executable-memory com.apple.security.cs.allow-jit com.apple.security.network.server com.apple.security.device.camera com.apple.security.files.all com.apple.developer.fileprovider.testing-mode; do26 grep -q "$bad" <<<"$ENT" && ko "unexpected entitlement $bad"; done; ok "no runtime exception, no server socket, no testing mode, no broad file access"27 [[ -f "$target/Contents/embedded.provisionprofile" ]] && ok "provisioning profile embedded" || ko "embedded.provisionprofile missing"28done29echo "== Application entitlements"30ENT="$(codesign -d --entitlements :- "$APP" 2>/dev/null)"31grep -q "webcredentials:drive.spboucher.ai" <<<"$ENT" && ok "associated domain webcredentials:drive.spboucher.ai (passkeys)" || ko "associated domain missing (passkeys would fail)"32echo "== File Provider extension"33/usr/libexec/PlistBuddy -c 'Print :NSExtension:NSExtensionPointIdentifier' "$EXT/Contents/Info.plist" 2>/dev/null | grep -q "com.apple.fileprovider-nonui" && ok "extension point com.apple.fileprovider-nonui" || ko "wrong extension point"34[[ "$(/usr/libexec/PlistBuddy -c 'Print :NSExtension:NSExtensionFileProviderDocumentGroup' "$EXT/Contents/Info.plist" 2>/dev/null)" == "3YM54G49SN.ai.spboucher.spdrive" ]] && ok "document group = the app group" || ko "document group mismatch"35echo "== Native only"36LIBS="$(for b in "$BIN" "$EXTBIN"; do for a in $(lipo -archs "$b"); do otool -arch "$a" -L "$b"; done; done; find "$APP/Contents" -name '*.dylib' -o -name '*.framework')"37grep -Eiq "WebKit|JavaScriptCore|Electron|Chromium" <<<"$LIBS" && ko "a web engine is linked" || ok "no WebKit / JavaScriptCore / Chromium linked"38find "$APP" \( -name '*.html' -o -name '*.js' -o -name '*.css' \) | grep -q . && ko "web resources in the bundle" || ok "no HTML / JS / CSS resources"39echo "== Release, not development"40for b in "$BIN" "$EXTBIN"; do41 strings -a "$b" | grep -Eq "spdAutoLink|spdSelfTest|127\.0\.0\.1:8665|spdrive\.dev" && ko "development switch or test server in $(basename "$b")" || ok "$(basename "$b"): no development switch, no test server, no .dev identifier"42done43grep -q "NSAllowsLocalNetworking" "$APP/Contents/Info.plist" "$EXT/Contents/Info.plist" && ko "plain-HTTP exception present" || ok "no App Transport Security exception"44echo "== Secrets"45if grep -rlaE "(sk-ant-|sk-proj-|BEGIN (EC |RSA )?PRIVATE KEY|Bearer [A-Za-z0-9_-]{40})" "$APP" >/dev/null 2>&1; then ko "something that looks like a secret is in the bundle"; else ok "no API key, private key or session token in the bundle"; fi46echo "== Bundle"47echo " version $(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$APP/Contents/Info.plist") ($(/usr/libexec/PlistBuddy -c 'Print :CFBundleVersion' "$APP/Contents/Info.plist")) · archs $(lipo -archs "$BIN") / ext $(lipo -archs "$EXTBIN") · min macOS $(/usr/libexec/PlistBuddy -c 'Print :LSMinimumSystemVersion' "$APP/Contents/Info.plist") · $(du -sh "$APP" | cut -f1)"48[[ -f "$APP/Contents/Resources/AppIcon.icns" || -f "$APP/Contents/Resources/Assets.car" ]] && ok "icon assets present" || ko "icon missing"49exit $FAIL50