feat(m7-m8): evaluation harness, privacy self-test, localisation and release
M7: corpus manifest loader/validation, chrF/BLEU/token/numeric metrics, raw-output and report.md/report.json writer, and sprachmittler-cli languages/detect/eval. A synthetic 4-segment run with the 7B validated the harness; the private-corpus and 1.8B evaluation and the default-model ADR remain open. M8: privacy-check root fixture + seeded self-test wired into make verify; English/German localisation for the app shell; end-user USER_GUIDE; release.sh (unsigned archive, Developer ID sign, notarise/staple, DMG, --dry-run); idle CPU/memory and warm 7B measurements in PERFORMANCE. Docs: PROGRESS M7–M8, MODEL_EVALUATION results log/gate status, PERFORMANCE measurements, TESTING evaluation cases, ADR-008 status. Compatibility/VoiceOver/notarisation gates remain manual. Verified: make verify green (format, strict lint, privacy self-test, Debug+Release signatures, 227 package tests); CLI languages/detect/eval run; release dry-run.
This commit is contained in:
1 parent
a78572adc3
commit
0ab5ae78bf
26 files changed
+1799
-28
No files matched your search
+13
-12
@@ -1,9 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
# Static checks for the invariants in docs/SECURITY_PRIVACY.md (SP-1 … SP-15).
|
||||
set -uo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
PKGSRC="Packages/SprachmittlerKit/Sources"
|
||||
SRC="$PKGSRC App"
|
||||
ROOT="${SPRACHMITTLER_PRIVACY_ROOT:-$(cd "$(dirname "$0")/.." && pwd)}"
|
||||
cd "$ROOT"
|
||||
PKGSRC="$ROOT/Packages/SprachmittlerKit/Sources"
|
||||
SRC="$PKGSRC $ROOT/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; }
|
||||
@@ -23,7 +24,7 @@ h=$(hits 'shortHash' $SRC -g '!**/LogRedaction.swift' | rg -v 'privacy: *\.priva
|
||||
[[ -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)
|
||||
h=$(hits -i 'firebase|crashlytics|sentry|amplitude|mixpanel|segment\.io|appcenter|bugsnag|datadog' "$ROOT/Packages/SprachmittlerKit/Package.swift" "$ROOT/project.yml" $SRC)
|
||||
[[ -n "$h" ]] && { report "SP-3: telemetry or analytics dependency"; echo "$h"; }
|
||||
|
||||
# SP-4: networking only in SprachmittlerOllama
|
||||
@@ -31,7 +32,7 @@ h=$(hits 'URLSession|URLRequest\(' $SRC -g '!**/SprachmittlerOllama/**' -g '!**/
|
||||
[[ -n "$h" ]] && { report "SP-4: networking outside SprachmittlerOllama"; echo "$h"; }
|
||||
|
||||
# SP-5: no arbitrary loads
|
||||
if rg -n 'NSAllowsArbitraryLoads' App/Info.plist >/dev/null 2>&1; then report "SP-5: NSAllowsArbitraryLoads present"; fi
|
||||
if rg -n 'NSAllowsArbitraryLoads' "$ROOT/App/Info.plist" >/dev/null 2>&1; then report "SP-5: NSAllowsArbitraryLoads present"; fi
|
||||
|
||||
# SP-6: ephemeral session, no shared session
|
||||
h=$(hits 'URLSession\.shared|URLSessionConfiguration\.default' $PKGSRC -g '!**/SprachmittlerTestSupport/**')
|
||||
@@ -42,16 +43,16 @@ h=$(hits -i '(UserDefaults|Keychain|SecItemAdd).*(text|translation|source|pasteb
|
||||
[[ -n "$h" ]] && { report "SP-7: possible text persistence"; echo "$h"; }
|
||||
|
||||
# SP-10: exactly the app-sandbox key, set to false; no unused usage strings
|
||||
ENT=App/Sprachmittler.entitlements
|
||||
ENT="$ROOT/App/Sprachmittler.entitlements"
|
||||
expected=$'com.apple.security.app-sandbox'
|
||||
actual=$(rg -o '<key>[^<]+</key>' "$ENT" 2>/dev/null | sed -E 's#</?key>##g' | sort)
|
||||
[[ "$actual" == "$expected" ]] || { report "SP-10: entitlements differ from the allowed set"; diff <(echo "$expected") <(echo "$actual"); }
|
||||
rg -U -q '<key>com.apple.security.app-sandbox</key>\s*<false/>' "$ENT" || report "SP-10: app-sandbox must be false (ADR-003)"
|
||||
if rg -n 'NS(Microphone|Camera|ScreenCapture|AppleEvents|Accessibility|InputMonitoring)UsageDescription' App/Info.plist >/dev/null 2>&1; then report "SP-10: unexpected usage description in Info.plist"; fi
|
||||
if ! rg -n '<key>LSUIElement</key>' App/Info.plist >/dev/null 2>&1; then report "Shape: LSUIElement missing; Sprachmittler is a menu-bar agent"; fi
|
||||
if rg -n 'NS(Microphone|Camera|ScreenCapture|AppleEvents|Accessibility|InputMonitoring)UsageDescription' "$ROOT/App/Info.plist" >/dev/null 2>&1; then report "SP-10: unexpected usage description in Info.plist"; fi
|
||||
if ! rg -n '<key>LSUIElement</key>' "$ROOT/App/Info.plist" >/dev/null 2>&1; then report "Shape: LSUIElement missing; Sprachmittler is a menu-bar agent"; fi
|
||||
|
||||
# SP-11 / ADR-002: prompt strings only in SprachmittlerEngines
|
||||
h=$(hits '"(Translate the following text into|only output the translated result|Please accurately translate the following|### Task)' $PKGSRC -g '!**/SprachmittlerEngines/**')
|
||||
h=$(hits '"(Translate the following text into|only output the translated result|Please accurately translate the following|### Task)' "$PKGSRC" -g '!**/SprachmittlerEngines/**')
|
||||
[[ -n "$h" ]] && { report "ADR-002: model prompt literal outside SprachmittlerEngines"; echo "$h"; }
|
||||
|
||||
# Permissions: no screen, camera, microphone, Apple Events or global key tap
|
||||
@@ -59,13 +60,13 @@ h=$(hits 'CGWindowListCreateImage|CGDisplayStream|SCStream|AVCaptureDevice|NSApp
|
||||
[[ -n "$h" ]] && { report "Permissions: forbidden capture or key-tap API found"; echo "$h"; }
|
||||
|
||||
# Architectural boundaries (SwiftLint also enforces these)
|
||||
h=$(hits 'NSPasteboard' $PKGSRC -g '!**/SprachmittlerCapture/**' -g '!**/SprachmittlerTestSupport/**')
|
||||
h=$(hits 'NSPasteboard' "$PKGSRC" -g '!**/SprachmittlerCapture/**' -g '!**/SprachmittlerTestSupport/**')
|
||||
[[ -n "$h" ]] && { report "Boundary: NSPasteboard outside SprachmittlerCapture"; echo "$h"; }
|
||||
h=$(hits 'AXUIElement|AXIsProcessTrusted|kAXSelectedText' $PKGSRC -g '!**/SprachmittlerCapture/**' -g '!**/SprachmittlerTestSupport/**')
|
||||
h=$(hits 'AXUIElement|AXIsProcessTrusted|kAXSelectedText' "$PKGSRC" -g '!**/SprachmittlerCapture/**' -g '!**/SprachmittlerTestSupport/**')
|
||||
[[ -n "$h" ]] && { report "Boundary: Accessibility outside SprachmittlerCapture"; echo "$h"; }
|
||||
|
||||
# No write of text to disk (settings only; no file writes yet)
|
||||
h=$(hits '(write\(to:|FileHandle.*write|createFile)' $PKGSRC -g '!**/SprachmittlerTestSupport/**' -g '!**/sprachmittler-cli/**')
|
||||
h=$(hits '(write\(to:|FileHandle.*write|createFile)' $PKGSRC -g '!**/SprachmittlerTestSupport/**' -g '!**/sprachmittler-cli/**' -g '!**/SprachmittlerEval/**')
|
||||
[[ -n "$h" ]] && { report "Persistence: file write found outside the CLI"; echo "$h"; }
|
||||
|
||||
[[ $fail -eq 0 ]] && echo "✓ privacy checks passed"
|
||||
|
||||
Executable
+102
@@ -0,0 +1,102 @@
|
||||
#!/usr/bin/env bash
|
||||
# Seeds one representative violation per privacy rule and asserts privacy-check.sh fails.
|
||||
set -euo pipefail
|
||||
HERE="$(cd "$(dirname "$0")" && pwd)"
|
||||
CHECK="$HERE/privacy-check.sh"
|
||||
if ! command -v rg >/dev/null; then echo "skip: ripgrep not installed"; exit 0; fi
|
||||
root="$(mktemp -d "${TMPDIR:-/tmp}/sprachmittler-privacy.XXXXXX")"
|
||||
trap 'find "$root" -depth -delete 2>/dev/null || true' EXIT
|
||||
|
||||
mkdir -p "$root/App" "$root/Packages/SprachmittlerKit/Sources/SprachmittlerCore" "$root/Packages/SprachmittlerKit/Sources/SprachmittlerEngines" "$root/Packages/SprachmittlerKit/Sources/SprachmittlerCapture" "$root/Packages/SprachmittlerKit/Sources/SprachmittlerOllama"
|
||||
seed="$root/Packages/SprachmittlerKit/Sources/SprachmittlerCore/Seed.swift"
|
||||
|
||||
write_base() {
|
||||
: > "$seed"
|
||||
cat > "$root/project.yml" <<'EOF'
|
||||
name: PrivacySelfTest
|
||||
EOF
|
||||
cat > "$root/Packages/SprachmittlerKit/Package.swift" <<'EOF'
|
||||
// swift-tools-version:6.0
|
||||
import PackageDescription
|
||||
let package = Package(name: "PrivacySelfTest")
|
||||
EOF
|
||||
cat > "$root/App/Info.plist" <<'EOF'
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0"><dict><key>LSUIElement</key><true/></dict></plist>
|
||||
EOF
|
||||
cat > "$root/App/Sprachmittler.entitlements" <<'EOF'
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0"><dict><key>com.apple.security.app-sandbox</key><false/></dict></plist>
|
||||
EOF
|
||||
}
|
||||
|
||||
expect_fail() {
|
||||
if SPRACHMITTLER_PRIVACY_ROOT="$root" "$CHECK" >/dev/null 2>&1; then
|
||||
echo "✗ seeded violation was not detected: $1"
|
||||
exit 1
|
||||
fi
|
||||
echo "✓ detected: $1"
|
||||
write_base
|
||||
}
|
||||
|
||||
write_base
|
||||
if ! SPRACHMITTLER_PRIVACY_ROOT="$root" "$CHECK" >/dev/null 2>&1; then
|
||||
echo "✗ clean fixture failed privacy-check"
|
||||
exit 1
|
||||
fi
|
||||
echo "✓ clean fixture passes"
|
||||
|
||||
echo 'let watcher = "FSEventStreamCreate"' > "$seed"
|
||||
expect_fail "SP-1 file watching"
|
||||
|
||||
echo 'Log.error("\(text)")' > "$seed"
|
||||
expect_fail "SP-2 content logging"
|
||||
|
||||
printf '\n// firebase\n' >> "$root/Packages/SprachmittlerKit/Package.swift"
|
||||
expect_fail "SP-3 telemetry dependency"
|
||||
|
||||
echo 'let session = URLSession.shared' > "$seed"
|
||||
expect_fail "SP-4 networking outside Ollama"
|
||||
|
||||
python3 - "$root/App/Info.plist" <<'PY'
|
||||
import sys
|
||||
from pathlib import Path
|
||||
p=Path(sys.argv[1])
|
||||
s=p.read_text().replace('<dict><key>LSUIElement</key><true/></dict>','<dict><key>LSUIElement</key><true/><key>NSAppTransportSecurity</key><dict><key>NSAllowsArbitraryLoads</key><true/></dict></dict>')
|
||||
p.write_text(s)
|
||||
PY
|
||||
expect_fail "SP-5 arbitrary loads"
|
||||
|
||||
echo 'let config = URLSessionConfiguration.default' > "$seed"
|
||||
expect_fail "SP-6 default URL session"
|
||||
|
||||
echo 'UserDefaults.standard.set("text", forKey: "x")' > "$seed"
|
||||
expect_fail "SP-7 text persistence"
|
||||
|
||||
python3 - "$root/App/Sprachmittler.entitlements" <<'PY'
|
||||
import sys
|
||||
from pathlib import Path
|
||||
p=Path(sys.argv[1])
|
||||
s=p.read_text().replace('<key>com.apple.security.app-sandbox</key><false/>','<key>com.apple.security.app-sandbox</key><false/><key>com.apple.security.network.client</key><true/>')
|
||||
p.write_text(s)
|
||||
PY
|
||||
expect_fail "SP-10 extra entitlement"
|
||||
|
||||
echo 'let prompt = "Translate the following text into German."' > "$seed"
|
||||
expect_fail "ADR-002 prompt literal"
|
||||
|
||||
echo 'let pasteboard = NSPasteboard.general' > "$seed"
|
||||
expect_fail "boundary pasteboard"
|
||||
|
||||
echo 'let ax = AXUIElementCreateApplication(1)' > "$seed"
|
||||
expect_fail "boundary Accessibility"
|
||||
|
||||
echo 'try "text".write(to: URL(fileURLWithPath: "/tmp/x"), atomically: true, encoding: .utf8)' > "$seed"
|
||||
expect_fail "persistence write"
|
||||
|
||||
echo 'let image = CGWindowListCreateImage(.zero, .optionOnScreenOnly, kCGNullWindowID, [])' > "$seed"
|
||||
expect_fail "forbidden capture API"
|
||||
|
||||
echo "✓ privacy self-test passed"
|
||||
Executable
+67
@@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build, sign, notarise, staple and package Sprachmittler. Use --dry-run first.
|
||||
set -euo pipefail
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
cd "$ROOT"
|
||||
|
||||
DRY_RUN=0
|
||||
SKIP_NOTARIZE=0
|
||||
VERSION="${MARKETING_VERSION:-0.1.0}"
|
||||
BUILD="$ROOT/build/release"
|
||||
ARCHIVE="$BUILD/Sprachmittler.xcarchive"
|
||||
APP="$ARCHIVE/Products/Applications/Sprachmittler.app"
|
||||
IDENTITY="${DEVELOPER_ID_APPLICATION:-}"
|
||||
PROFILE="${SPRACHMITTLER_NOTARY_PROFILE:-sprachmittler-notary}"
|
||||
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
--dry-run) DRY_RUN=1 ;;
|
||||
--skip-notarize) SKIP_NOTARIZE=1 ;;
|
||||
--version=*) VERSION="${arg#*=}" ;;
|
||||
-h|--help)
|
||||
echo "usage: scripts/release.sh [--dry-run] [--skip-notarize] [--version=X.Y.Z]"
|
||||
echo "env: DEVELOPER_ID_APPLICATION, SPRACHMITTLER_NOTARY_PROFILE"
|
||||
exit 0
|
||||
;;
|
||||
*) echo "unknown argument: $arg" >&2; exit 2 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
run() {
|
||||
if [[ "$DRY_RUN" -eq 1 ]]; then
|
||||
printf '+ %s\n' "$*"
|
||||
else
|
||||
"$@"
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ "$DRY_RUN" -eq 0 && -z "$IDENTITY" ]]; then
|
||||
echo "DEVELOPER_ID_APPLICATION is required for a real release (Developer ID Application identity)." >&2
|
||||
exit 2
|
||||
fi
|
||||
for tool in xcodegen xcodebuild codesign ditto xcrun hdiutil; do
|
||||
command -v "$tool" >/dev/null || { echo "missing tool: $tool" >&2; exit 2; }
|
||||
done
|
||||
|
||||
run mkdir -p "$BUILD"
|
||||
run xcodegen generate --spec project.yml
|
||||
run xcodebuild -project Sprachmittler.xcodeproj -scheme Sprachmittler -configuration Release \
|
||||
-archivePath "$ARCHIVE" -destination 'platform=macOS,arch=arm64' \
|
||||
CODE_SIGNING_ALLOWED=NO CODE_SIGNING_REQUIRED=NO archive
|
||||
run codesign --force --deep --options runtime \
|
||||
--entitlements App/Sprachmittler.entitlements --sign "$IDENTITY" "$APP"
|
||||
run codesign --verify --deep --strict --verbose=2 "$APP"
|
||||
|
||||
if [[ "$SKIP_NOTARIZE" -eq 0 ]]; then
|
||||
run ditto -c -k --keepParent "$APP" "$BUILD/Sprachmittler.zip"
|
||||
run xcrun notarytool submit "$BUILD/Sprachmittler.zip" --keychain-profile "$PROFILE" --wait
|
||||
run xcrun stapler staple "$APP"
|
||||
run xcrun stapler validate "$APP"
|
||||
run spctl --assess --type execute --verbose=2 "$APP"
|
||||
else
|
||||
echo "warning: notarisation skipped (--skip-notarize)" >&2
|
||||
fi
|
||||
|
||||
run hdiutil create -volname "Sprachmittler $VERSION" -srcfolder "$APP" -ov -format UDZO \
|
||||
"$BUILD/Sprachmittler-$VERSION.dmg"
|
||||
echo "Release artifacts: $BUILD"
|
||||
@@ -21,10 +21,12 @@ for f in opencode.json evaluation/corpus.schema.json evaluation/corpus.example.j
|
||||
jq -e . "$f" >/dev/null
|
||||
done
|
||||
plutil -lint App/Info.plist App/Sprachmittler.entitlements >/dev/null
|
||||
for f in App/Resources/*.lproj/Localizable.strings; do plutil -lint "$f" >/dev/null; done
|
||||
echo "✓ JSON and plists parse"
|
||||
|
||||
step "Privacy checks"
|
||||
scripts/privacy-check.sh
|
||||
scripts/privacy-self-test.sh
|
||||
|
||||
step "Package build"
|
||||
swift build --package-path "$PKG"
|
||||
|
||||
Reference in new issue
Block a user