Repository Public
1#!/usr/bin/env bash2# Author: Simon-Pierre Boucher — contact@spboucher.ai3# File: Scripts/verify-release.sh4# Description: Checks the signed Release app AND each embedded extension (widgets, share extension, notification service): signature,5# hardened runtime, sandbox and entitlements, shared App Group and keychain group, embedded profile per bundle, no development switch,6# no plain-HTTP exception, no secret in the bundle, both localisations present.7#8# Usage: Scripts/verify-release.sh [path/to/SP Mail.app] (exit code ≠ 0 when a check fails)9set -u # no pipefail: `strings | grep -q` must report grep's verdict, not the SIGPIPE of strings10cd "$(dirname "$0")/.."11APP="${1:-dist/SP Mail.app}"; BIN="$APP/Contents/MacOS/SP Mail"; FAIL=012ok() { echo " ✓ $1"; }; ko() { echo " ✗ $1"; FAIL=1; }13[[ -d "$APP" ]] || { echo "ERROR: $APP not found" >&2; exit 1; }14echo "== Signature"15codesign --verify --deep --strict "$APP" 2>/dev/null && ok "codesign --verify --deep --strict" || ko "signature invalid"16INFO="$(codesign -dvv "$APP" 2>&1)"17grep -q "Authority=Developer ID Application" <<<"$INFO" && ok "$(grep -m1 '^Authority=' <<<"$INFO")" || ko "not signed with Developer ID Application"18grep -Eq "flags=.*runtime" <<<"$INFO" && ok "hardened runtime enabled" || ko "hardened runtime missing"19grep -q "^Timestamp=" <<<"$INFO" && ok "secure timestamp present" || ko "no secure timestamp"20grep -q "^Identifier=ai.spboucher.spmail$" <<<"$INFO" && ok "identifier ai.spboucher.spmail" || ko "unexpected identifier: $(grep -m1 '^Identifier=' <<<"$INFO")"21echo "== Entitlements"22ENT="$(codesign -d --entitlements :- "$APP" 2>/dev/null)"23grep -A1 "com.apple.security.app-sandbox" <<<"$ENT" | grep -q "<true/>" && ok "App Sandbox on" || ko "App Sandbox off"24grep -q "com.apple.security.network.client" <<<"$ENT" && ok "network client" || ko "network client missing"25grep -q "com.apple.security.files.user-selected.read-write" <<<"$ENT" && ok "user-selected files read/write" || ko "user-selected files missing"26grep -q "webcredentials:mail.spboucher.ai" <<<"$ENT" && ok "associated domain webcredentials:mail.spboucher.ai (passkeys)" || ko "associated domain missing (passkeys would fail)"27grep -q "3YM54G49SN.ai.spboucher.spmail</string>" <<<"$ENT" && ok "keychain group 3YM54G49SN.ai.spboucher.spmail" || ko "keychain group missing"28grep -q "3YM54G49SN.group.ai.spboucher.spmail</string>" <<<"$ENT" && ok "shared App Group / keychain group 3YM54G49SN.group.ai.spboucher.spmail" || ko "shared group missing (extensions could not read the session or the snapshot)"29grep -q "spmail\.dev" <<<"$ENT" && ko "a development group or identifier is in the entitlements" || ok "no development group in the entitlements"30grep -A1 "aps-environment" <<<"$ENT" | grep -q "production" && ok "push environment: production" || ko "aps-environment is not production"31grep -q "get-task-allow" <<<"$ENT" && ko "get-task-allow present (debug entitlement)" || ok "no get-task-allow"32for 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.files.all com.apple.security.files.downloads; do33 grep -q "$bad" <<<"$ENT" && ko "unexpected entitlement $bad"; done; ok "no runtime exception, no server socket, no broad file access"34[[ -f "$APP/Contents/embedded.provisionprofile" ]] && ok "provisioning profile embedded" || ko "embedded.provisionprofile missing"35echo "== Release, not development"36# The only tolerated mention of the development variant is the NAME of its App Group, a constant of the shared package that a Release37# build never selects (SharedEnvironment.running). Anything else — a launch argument, a test server, the .dev bundle identifier — fails.38devswitch() { strings -a "$1" | grep -E "spmDevToken|spmSelfTest|spmBaseURL|spmFakePush|spmNoPrompts|spmOpenSettings|dev-secrets|localhost:8[0-9][0-9][0-9]|spmail\.dev" | grep -v "^group\.ai\.spboucher\.spmail\.dev$" | grep -q .; }39devswitch "$BIN" && ko "development switch or test server in the binary" || ok "no development switch, no test server, no .dev identifier"40/usr/libexec/PlistBuddy -c 'Print :CFBundleURLTypes' "$APP/Contents/Info.plist" | grep -q "spmail-dev" && ko "development URL scheme registered" || ok "URL schemes: mailto and spmail (no development scheme)"41grep -q "NSAllowsLocalNetworking\|NSAllowsArbitraryLoads" "$APP/Contents/Info.plist" && ko "App Transport Security exception present" || ok "no App Transport Security exception"42strings -a "$BIN" | grep -q "https://mail.spboucher.ai" && ok "production server compiled in" || ko "production server URL not found"43echo "== Extensions"44APPV="$(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$APP/Contents/Info.plist") ($(/usr/libexec/PlistBuddy -c 'Print :CFBundleVersion' "$APP/Contents/Info.plist"))"45for pair in "SPMailWidgets:widgets:com.apple.widgetkit-extension" "SPMailShare:share:com.apple.share-services" "SPMailNotifications:notifications:com.apple.usernotifications.service"; do46 NAME="${pair%%:*}"; REST="${pair#*:}"; KIND="${REST%%:*}"; POINT="${REST#*:}"; X="$APP/Contents/PlugIns/$NAME.appex"; XB="$X/Contents/MacOS/$NAME"47 [[ -d "$X" ]] || { ko "$NAME.appex is missing"; continue; }48 XI="$(codesign -dvv "$X" 2>&1)"; XE="$(codesign -d --entitlements :- "$X" 2>/dev/null)"; P="$NAME"49 codesign --verify --strict "$X" 2>/dev/null || { ko "$P: signature invalid"; continue; }50 grep -q "Authority=Developer ID Application" <<<"$XI" && grep -Eq "flags=.*runtime" <<<"$XI" && grep -q "^Timestamp=" <<<"$XI" || ko "$P: not Developer ID + hardened runtime + timestamp"51 grep -q "^Identifier=ai.spboucher.spmail.$KIND$" <<<"$XI" || ko "$P: unexpected identifier $(grep -m1 '^Identifier=' <<<"$XI")"52 [[ "$(/usr/libexec/PlistBuddy -c 'Print :NSExtension:NSExtensionPointIdentifier' "$X/Contents/Info.plist" 2>/dev/null)" == "$POINT" ]] || ko "$P: wrong extension point"53 grep -A1 "com.apple.security.app-sandbox" <<<"$XE" | grep -q "<true/>" || ko "$P: App Sandbox off"54 grep -q "3YM54G49SN.group.ai.spboucher.spmail</string>" <<<"$XE" || ko "$P: shared group missing"55 grep -q "3YM54G49SN.ai.spboucher.spmail.$KIND</string>" <<<"$XE" || ko "$P: application identifier missing"56 grep -q "get-task-allow\|spmail\.dev" <<<"$XE" && ko "$P: debug entitlement or development group"57 if [[ "$KIND" == share ]]; then grep -q "com.apple.security.network.client" <<<"$XE" || ko "$P: network client missing"; else grep -q "com.apple.security.network" <<<"$XE" && ko "$P: unexpected network entitlement"; fi58 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.files.all; do grep -q "$bad" <<<"$XE" && ko "$P: unexpected entitlement $bad"; done59 if [[ -f "$X/Contents/embedded.provisionprofile" ]]; then60 security cms -D -i "$X/Contents/embedded.provisionprofile" 2>/dev/null | grep -q "3YM54G49SN.ai.spboucher.spmail.$KIND</string>" || ko "$P: embedded profile is for another identifier"61 else ko "$P: embedded.provisionprofile missing"; fi62 devswitch "$XB" && ko "$P: development switch or test server in the binary"63 grep -q "NSAllowsLocalNetworking\|NSAllowsArbitraryLoads" "$X/Contents/Info.plist" && ko "$P: App Transport Security exception present"64 XV="$(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$X/Contents/Info.plist") ($(/usr/libexec/PlistBuddy -c 'Print :CFBundleVersion' "$X/Contents/Info.plist"))"65 [[ "$XV" == "$APPV" ]] || ko "$P: version $XV differs from the app's $APPV"66 [[ -f "$X/Contents/Resources/en.lproj/Localizable.strings" ]] || ko "$P: English localisation missing"67 [[ $FAIL == 0 ]] && ok "$NAME.appex — ai.spboucher.spmail.$KIND, Developer ID, hardened runtime, sandbox, shared group, own profile, $(lipo -archs "$XB")"68done69[[ "$(ls -d "$APP"/Contents/PlugIns/*.appex 2>/dev/null | wc -l | tr -d ' ')" == 3 ]] && ok "exactly three embedded extensions" || ko "unexpected set of embedded extensions"70echo "== Secrets"71if 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"; fi72echo "== Bundle"73# French is the source language of the String Catalog (its strings are the keys): only en.lproj is emitted, fr is declared in Info.plist74[[ -f "$APP/Contents/Resources/en.lproj/Localizable.strings" ]] && /usr/libexec/PlistBuddy -c 'Print :CFBundleLocalizations' "$APP/Contents/Info.plist" | grep -q "fr" && [[ "$(/usr/libexec/PlistBuddy -c 'Print :CFBundleDevelopmentRegion' "$APP/Contents/Info.plist")" == fr ]] && ok "French (source, default) and English localisations" || ko "a localisation is missing"75[[ -f "$APP/Contents/Resources/AppIcon.icns" || -f "$APP/Contents/Resources/Assets.car" ]] && ok "icon assets present" || ko "icon missing"76echo " 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") · min macOS $(/usr/libexec/PlistBuddy -c 'Print :LSMinimumSystemVersion' "$APP/Contents/Info.plist") · $(du -sh "$APP" | cut -f1)"77exit $FAIL78