Repository Public
1#!/usr/bin/env bash2# Verifies the release artefacts: signature, entitlements, hardened runtime, Gatekeeper and notarization ticket.3# Usage: scripts/verify-release.sh (exit status 0 only if every check that applies passes)4set -uo pipefail5cd "$(dirname "$0")/.."6APP="dist/SPBrowser.app"7DMG="dist/SPBrowser.dmg"8FAIL=09check() { local label="$1"; shift; if "$@" >/tmp/spb-verify.out 2>&1; then echo "PASS $label"; else echo "FAIL $label"; sed 's/^/ /' /tmp/spb-verify.out | head -6; FAIL=1; fi; }10[[ -d "$APP" ]] || { echo "FAIL $APP not found"; exit 1; }1112check "codesign --verify --deep --strict" codesign --verify --deep --strict --verbose=2 "$APP"13INFO="$(codesign -dvv "$APP" 2>&1)"14grep -q "^Authority=Developer ID Application:" <<<"$INFO" && echo "PASS signed with $(sed -n 's/^Authority=\(Developer ID Application: .*\)$/\1/p' <<<"$INFO" | head -1)" || { echo "FAIL not signed with a Developer ID Application identity"; FAIL=1; }15grep -q "flags=.*runtime" <<<"$INFO" && echo "PASS hardened runtime enabled" || { echo "FAIL hardened runtime missing"; FAIL=1; }16grep -q "^Timestamp=" <<<"$INFO" && echo "PASS secure timestamp present" || { echo "FAIL no secure timestamp"; FAIL=1; }1718ENT="$(codesign -d --entitlements - --xml "$APP" 2>/dev/null | plutil -convert json -o - - 2>/dev/null || echo '{}')"19echo "INFO entitlements: $(/usr/bin/python3 -c 'import json,sys; print(", ".join(sorted(k.replace("com.apple.security.","") for k,v in json.loads(sys.argv[1]).items() if v)))' "$ENT")"20grep -q '"com.apple.security.app-sandbox":true' <<<"$ENT" && echo "PASS App Sandbox enabled" || { echo "FAIL App Sandbox not enabled"; FAIL=1; }21grep -q 'get-task-allow' <<<"$ENT" && { echo "FAIL get-task-allow present (debug entitlement)"; FAIL=1; } || echo "PASS no debug entitlement"22for forbidden in cs.disable-library-validation cs.allow-jit cs.allow-unsigned-executable-memory network.server files.all; do23 grep -q "$forbidden" <<<"$ENT" && { echo "FAIL unexpected entitlement: $forbidden"; FAIL=1; }24done25echo "INFO architectures: $(lipo -archs "$APP/Contents/MacOS/SPBrowser")"2627if xcrun stapler validate "$APP" >/tmp/spb-verify.out 2>&1; then28 echo "PASS notarization ticket stapled to the application"29 check "Gatekeeper (spctl --assess --type execute)" spctl --assess --type execute --verbose "$APP"30 NOTARIZED=131else32 echo "WARN no notarization ticket on the application — it is NOT notarized"33 spctl --assess --type execute --verbose "$APP" 2>&1 | sed 's/^/ /'34 NOTARIZED=035fi36if [[ -f "$DMG" ]]; then37 check "disk image signature" codesign --verify --verbose=2 "$DMG"38 check "disk image ticket (stapler validate)" xcrun stapler validate "$DMG"39 check "disk image Gatekeeper" spctl --assess --type open --context context:primary-signature --verbose "$DMG"40else41 echo "INFO $DMG not present (it is only produced after a successful notarization)"42fi43echo "---"44if [[ $FAIL -eq 0 && $NOTARIZED -eq 1 ]]; then echo "RELEASE VERIFIED: signed, notarized, stapled"; exit 0; fi45if [[ $FAIL -eq 0 ]]; then echo "SIGNED BUT NOT NOTARIZED: suitable for this Mac only; other Macs will be blocked by Gatekeeper"; exit 3; fi46echo "VERIFICATION FAILED"; exit 147