feat(m0): complete scaffold, logging and signature checks (T0.2-T0.6)
Add os.Logger categories, OSSignposter wrapper and shortHash helper; enforce exact Debug/Release/install signatures; lint tests; update M0 docs and progress.
This commit is contained in:
1 parent
374085ec2f
commit
7ca5c710ec
17 files changed
+331
-9
No files matched your search
Executable
+80
@@ -0,0 +1,80 @@
|
||||
#!/usr/bin/env bash
|
||||
# Verify a signed Sprachmittler.app has the expected entitlements and, where required,
|
||||
# Hardened Runtime. Called by scripts/verify.sh and `make install` (T0.2, SP-10).
|
||||
#
|
||||
# Usage: scripts/check-signature.sh <app-path> <debug|release|install>
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
APP="${1:-}"
|
||||
PROFILE="${2:-}"
|
||||
if [[ -z "$APP" || ! -d "$APP" ]]; then
|
||||
echo "usage: scripts/check-signature.sh <app-path> <debug|release|install>" >&2
|
||||
exit 2
|
||||
fi
|
||||
case "$PROFILE" in
|
||||
debug | release | install) ;;
|
||||
*)
|
||||
echo "unknown profile '$PROFILE' (expected debug, release or install)" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
command -v jq >/dev/null || { echo "jq required (brew install jq)" >&2; exit 1; }
|
||||
|
||||
codesign --verify --strict "$APP"
|
||||
|
||||
tmp=$(mktemp "${TMPDIR:-/tmp}/sprachmittler-entitlements.XXXXXX")
|
||||
err=$(mktemp "${TMPDIR:-/tmp}/sprachmittler-entitlements-error.XXXXXX")
|
||||
trap 'rm -f "$tmp" "$err"' EXIT
|
||||
|
||||
# codesign writes the entitlement plist to stdout. Capture stderr separately so a signing
|
||||
# failure is visible, without printing the executable path on every successful run.
|
||||
if ! codesign -d --entitlements :- "$APP" > "$tmp" 2> "$err"; then
|
||||
cat "$err" >&2
|
||||
exit 1
|
||||
fi
|
||||
if ! json=$(plutil -convert json -o - "$tmp"); then
|
||||
echo "✗ $PROFILE signature: no readable entitlements" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
app_sandbox=$(jq -r 'if has("com.apple.security.app-sandbox") then .["com.apple.security.app-sandbox"] else "missing" end' <<<"$json")
|
||||
if [[ "$app_sandbox" != "false" ]]; then
|
||||
echo "✗ $PROFILE signature: com.apple.security.app-sandbox must be false (ADR-003)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
get_task_allow=$(jq -r 'if has("com.apple.security.get-task-allow") then .["com.apple.security.get-task-allow"] else "absent" end' <<<"$json")
|
||||
keys=$(jq -r 'keys[]' <<<"$json" | sort)
|
||||
|
||||
if [[ "$PROFILE" == "debug" ]]; then
|
||||
# Xcode normally injects get-task-allow for the debugger, but the AC only requires that it
|
||||
# may be present. Accept either the exact sandbox-only set or sandbox + get-task-allow=true.
|
||||
if [[ "$get_task_allow" == "true" ]]; then
|
||||
expected=$'com.apple.security.app-sandbox\ncom.apple.security.get-task-allow'
|
||||
suffix=" + get-task-allow"
|
||||
elif [[ "$get_task_allow" == "absent" ]]; then
|
||||
expected='com.apple.security.app-sandbox'
|
||||
suffix=""
|
||||
else
|
||||
echo "✗ debug signature: get-task-allow must be true when present" >&2
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
expected='com.apple.security.app-sandbox'
|
||||
if [[ "$get_task_allow" != "absent" ]]; then
|
||||
echo "✗ $PROFILE signature: get-task-allow must not be present" >&2
|
||||
exit 1
|
||||
fi
|
||||
codesign -dvv "$APP" 2>&1 | grep -Eq 'flags=.*runtime' \
|
||||
|| { echo "✗ $PROFILE signature: Hardened Runtime flag is missing" >&2; exit 1; }
|
||||
suffix=" + Hardened Runtime"
|
||||
fi
|
||||
|
||||
if [[ "$keys" != "$expected" ]]; then
|
||||
echo "✗ $PROFILE signature: unexpected entitlements" >&2
|
||||
diff <(printf '%s\n' "$expected") <(printf '%s\n' "$keys") >&2 || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✓ $PROFILE signature: app-sandbox=false$suffix"
|
||||
@@ -18,6 +18,9 @@ h=$(hits 'Log(ger)?\.[a-z]+\(.*\\\((text|translation|prompt|string|pasteboard|ap
|
||||
[[ -n "$h" ]] && { report "SP-2: possible content logging without privacy: .private"; echo "$h"; }
|
||||
h=$(hits '^\s*(print|debugPrint|NSLog)\(' $SRC -g '!**/sprachmittler-cli/**')
|
||||
[[ -n "$h" ]] && { report "SP-2: print/NSLog outside the CLI"; echo "$h"; }
|
||||
# short hashes are correlatable; they are still logged with privacy: .private
|
||||
h=$(hits 'shortHash' $SRC -g '!**/LogRedaction.swift' | rg -v 'privacy: *\.private' || true)
|
||||
[[ -n "$h" ]] && { report "SP-2: shortHash must be logged with privacy: .private"; echo "$h"; }
|
||||
|
||||
# SP-3: no telemetry or crash-reporting SDKs
|
||||
h=$(hits -i 'firebase|crashlytics|sentry|amplitude|mixpanel|segment\.io|appcenter|bugsnag|datadog' Packages/SprachmittlerKit/Package.swift project.yml $SRC)
|
||||
|
||||
+11
-1
@@ -10,7 +10,7 @@ step "Format check"
|
||||
if command -v swiftformat >/dev/null; then swiftformat App "$PKG" --lint; else echo "skip: swiftformat not installed"; fi
|
||||
|
||||
step "Lint"
|
||||
if command -v swiftlint >/dev/null; then swiftlint lint --strict --quiet App "$PKG/Sources"; else echo "skip: swiftlint not installed"; fi
|
||||
if command -v swiftlint >/dev/null; then swiftlint lint --strict --quiet App "$PKG/Sources" "$PKG/Tests"; else echo "skip: swiftlint not installed"; fi
|
||||
|
||||
step "Shell syntax"
|
||||
for f in scripts/*.sh; do bash -n "$f"; done
|
||||
@@ -37,6 +37,16 @@ if command -v xcodegen >/dev/null && command -v xcodebuild >/dev/null; then
|
||||
xcodegen generate --spec project.yml --quiet
|
||||
xcodebuild -project Sprachmittler.xcodeproj -scheme Sprachmittler -configuration Debug \
|
||||
-derivedDataPath .build/xcode -destination 'platform=macOS,arch=arm64' -quiet build
|
||||
scripts/check-signature.sh .build/xcode/Build/Products/Debug/Sprachmittler.app debug
|
||||
else
|
||||
echo "skip: xcodegen/xcodebuild not available (make bootstrap)"
|
||||
fi
|
||||
|
||||
step "Release build and signature"
|
||||
if command -v xcodegen >/dev/null && command -v xcodebuild >/dev/null; then
|
||||
xcodebuild -project Sprachmittler.xcodeproj -scheme Sprachmittler -configuration Release \
|
||||
-derivedDataPath .build/xcode-release -destination 'platform=macOS,arch=arm64' -quiet build
|
||||
scripts/check-signature.sh .build/xcode-release/Build/Products/Release/Sprachmittler.app release
|
||||
else
|
||||
echo "skip: xcodegen/xcodebuild not available (make bootstrap)"
|
||||
fi
|
||||
|
||||
Reference in new issue
Block a user