Files

37 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# Static checks for docs/SECURITY_PRIVACY.md invariants. Extended in T8.5.
set -uo pipefail
cd "$(dirname "$0")/.."
SRC="Packages/VorleserKit/Sources App"
fail=0
if ! command -v rg >/dev/null; then echo "warning: ripgrep (rg) not installed — privacy checks skipped (brew install ripgrep)"; exit 0; fi
report() { echo "✗ $1"; fail=1; }
# SP-1: no AX observers on other apps
if rg -n 'AXObserverCreate' $SRC >/dev/null 2>&1; then report "SP-1: AXObserverCreate found"; rg -n 'AXObserverCreate' $SRC; fi
# SP-4: networking only in VorleserOllama
hits=$(rg -n 'URLSession|URLRequest\(' $SRC -g '!**/VorleserOllama/**' -g '!**/VorleserTestSupport/**' 2>/dev/null || true)
[[ -n "$hits" ]] && { report "SP-4: networking outside VorleserOllama"; echo "$hits"; }
# SP-2: logger interpolation of text-like values without privacy: .private
hits=$(rg -n 'Log(ger)?\.[a-z]+.*\\\((text|selection\.text|segment\.text|input)[^)]*\)' $SRC 2>/dev/null | rg -v 'privacy: *\.private|\.count' || true)
[[ -n "$hits" ]] && { report "SP-2: possible text logging without privacy: .private"; echo "$hits"; }
# AX APIs only in VorleserCapture
hits=$(rg -n 'AXUIElement|kAXSelectedText' $SRC -g '!**/VorleserCapture/**' -g '!**/VorleserTestSupport/**' 2>/dev/null || true)
[[ -n "$hits" ]] && { report "Boundary: Accessibility APIs outside VorleserCapture"; echo "$hits"; }
# Ollama contract: never send speed/instructions
hits=$(rg -n '"(speed|instructions)"' Packages/VorleserKit/Sources/VorleserOllama 2>/dev/null || true)
[[ -n "$hits" ]] && { report "Contract: unsupported speech option in request"; echo "$hits"; }
# SP-10: no unused permission usage strings
if rg -n 'NS(Microphone|Camera|ScreenCapture|AppleEvents)UsageDescription' App/Info.plist >/dev/null 2>&1; then report "SP-10: unexpected usage description in Info.plist"; fi
# ATS
if rg -n 'NSAllowsArbitraryLoads' App/Info.plist >/dev/null 2>&1; then report "SP-5: NSAllowsArbitraryLoads present"; fi
[[ $fail -eq 0 ]] && echo "✓ privacy checks passed"
exit $fail