Avoid common App Store and Google Play rejections. Open playbook and pre-submission guard with 117 documented rejection patterns and fixes, privacy manifest and Data safety checks, 95 tracked deadlines (EU AI Act, DSA, COPPA, age laws), and a skill for AI coding agents.
Shell accessibilityai-agentsandroidapp-review-guidelinesapp-storeapp-store-connectapp-store-rejectionapp-store-reviewclaude-codecoppadata-safetyeu-ai-actgdprgoogle-playgoogle-play-policyiosmobile-complianceplay-consolepre-submission-checklistprivacy-manifest
guard: fix vendor-dir platform detection and validate privacy manifest internals (#596)
Akash Sharma246bc5f992d4
diff --git a/agent-os/hooks/app-store-compliance-guard-test.sh b/agent-os/hooks/app-store-compliance-guard-test.shindex cacd274..9781cef 100755--- a/agent-os/hooks/app-store-compliance-guard-test.sh+++ b/agent-os/hooks/app-store-compliance-guard-test.sh@@ -10,6 +10,8 @@ GUARD="$HERE/app-store-compliance-guard.sh"PASS=0; FAIL=0ok() { PASS=$((PASS+1)); printf 'PASS %s\n' "$1"; }bad() { FAIL=$((FAIL+1)); printf 'FAIL %s\n' "$1"; }+# A privacy manifest is a plist. The validator rejects anything it cannot parse, so fixtures carry a real one.+PLIST_EMPTY='<?xml version="1.0" encoding="UTF-8"?><plist version="1.0"><dict/></plist>'mk_ios_bad() {local d; d="$(mktemp -d)"; mkdir -p "$d/App"@@ -20,7 +22,7 @@ mk_ios_bad() {mk_ios_clean() {local d; d="$(mktemp -d)"; mkdir -p "$d/App"printf '<plist><dict><key>NSCameraUsageDescription</key><string>Scan receipts to log expenses</string><key>NSLocationWhenInUseUsageDescription</key><string>Show nearby stores on the map</string><key>ITSAppUsesNonExemptEncryption</key><false/></dict></plist>' > "$d/App/Info.plist"- printf '{}' > "$d/App/PrivacyInfo.xcprivacy"+ printf '%s' "$PLIST_EMPTY" > "$d/App/PrivacyInfo.xcprivacy"printf 'import StoreKit\nimport CoreLocation\nimport AVFoundation\nclass A { func signIn(){} func createAccount(){} func deleteAccount(){} func restorePurchases(){} }\nlet dev=AVCaptureDevice.default(for:.video)\nlet m=CLLocationManager()\nlet p="https://api.realbackend.io"\nlet policy="https://realbackend.io/privacy-policy"\nlet prod:SKProduct?=nil\n' > "$d/App/X.swift"echo "$d"}@@ -37,7 +39,7 @@ mk_android_bad() {mk_ios_precision_safe() {local d; d="$(mktemp -d)"; mkdir -p "$d/App.xcodeproj" "$d/App" "$d/AppTests"printf 'INFOPLIST_KEY_NSLocationWhenInUseUsageDescription = "for prayer times";\nITSAppUsesNonExemptEncryption = NO;\n' > "$d/App.xcodeproj/project.pbxproj"- printf '{}' > "$d/App/PrivacyInfo.xcprivacy"+ printf '%s' "$PLIST_EMPTY" > "$d/App/PrivacyInfo.xcprivacy"printf 'import CoreLocation\nimport SwiftUI\nlet m = CLLocationManager()\nlet policy = "https://app.com/privacy-policy"\nvar base: String {\n#if DEBUG\nreturn "http://localhost:8787"\n#else\nreturn "https://prod.app.com"\n#endif\n}\nstruct V: View { var body: some View { TextField("Search", text: .constant("")) } }\nlet label = "Adjust times"\n' > "$d/App/Main.swift"printf 'let testURL = "https://example.com/x"\n' > "$d/AppTests/T.swift"echo "$d"@@ -493,6 +495,39 @@ OUT="$(bash "$GUARD" "$D" 2>&1)"echo "$OUT" | grep -q 'APPLE-ASCAPI-AGERATING-ENDPOINT-REMOVED' && ok "Removed ASC age-rating endpoint in a script fires" || bad "Removed ASC age-rating endpoint in a script fires"rm -rf "$D"+# 43 A vendored build.gradle.kts under node_modules must not switch the Android section on for an iOS-only app+D="$(mktemp -d)"; mkdir -p "$D/node_modules/react-native" "$D/ios"+printf '{"name":"x"}' > "$D/package.json"+touch "$D/node_modules/react-native/build.gradle.kts" "$D/ios/Podfile"+OUT="$(bash "$GUARD" "$D" 2>&1)"+if echo "$OUT" | grep -q 'Android=0' && ! echo "$OUT" | grep -Eq '^\s+\[(CRITICAL|HIGH|MEDIUM)\]\s+(ANDROID|GOOGLE)-'; then ok "Vendored gradle file does not flip Android on"; else bad "Vendored gradle file does not flip Android on"; fi+rm -rf "$D"++# 44 NSPrivacyTracking true with no NSPrivacyTrackingDomains is the ITMS-91064 upload rejection and must block+D="$(mktemp -d)"; mkdir -p "$D/App"+printf '<plist><dict><key>ITSAppUsesNonExemptEncryption</key><false/></dict></plist>' > "$D/App/Info.plist"+printf '<?xml version="1.0" encoding="UTF-8"?><plist version="1.0"><dict><key>NSPrivacyTracking</key><true/><key>NSPrivacyTrackingDomains</key><array/></dict></plist>' > "$D/App/PrivacyInfo.xcprivacy"+OUT="$(bash "$GUARD" "$D" 2>&1)"; RC=$?+echo "$OUT" | grep -q 'APPLE-ITMS-91064-TRACKING-NO-DOMAINS' && [ "$RC" -eq 2 ] && ok "Tracking true with empty domains blocks" || bad "Tracking true with empty domains blocks (rc=$RC)"+rm -rf "$D"++# 45 A manifest that is not a plist cannot be compiled by Xcode, so it is a finding, never a silent pass+D="$(mktemp -d)"; mkdir -p "$D/App"+printf '<plist><dict><key>ITSAppUsesNonExemptEncryption</key><false/></dict></plist>' > "$D/App/Info.plist"+printf '{}' > "$D/App/PrivacyInfo.xcprivacy"+OUT="$(bash "$GUARD" "$D" 2>&1)"+echo "$OUT" | grep -q 'APPLE-MANIFEST-UNREADABLE' && ok "Malformed manifest fires" || bad "Malformed manifest fires"+rm -rf "$D"++# 46 A manifest inside a Tests dir is a fixture, not a shipped manifest, and is not validated+D="$(mktemp -d)"; mkdir -p "$D/App" "$D/AppTests/Fixtures"+printf '<plist><dict><key>ITSAppUsesNonExemptEncryption</key><false/></dict></plist>' > "$D/App/Info.plist"+printf '%s' "$PLIST_EMPTY" > "$D/App/PrivacyInfo.xcprivacy"+printf '{}' > "$D/AppTests/Fixtures/PrivacyInfo.xcprivacy"+OUT="$(bash "$GUARD" "$D" 2>&1)"+echo "$OUT" | grep -q 'APPLE-MANIFEST-UNREADABLE' && bad "Manifest fixture under Tests is skipped" || ok "Manifest fixture under Tests is skipped"+rm -rf "$D"+echo ""echo "app-store-compliance-guard-test: $PASS passed, $FAIL failed"[ "$FAIL" -eq 0 ]diff --git a/agent-os/hooks/app-store-compliance-guard.sh b/agent-os/hooks/app-store-compliance-guard.shindex 560eb56..53784d9 100755--- a/agent-os/hooks/app-store-compliance-guard.sh+++ b/agent-os/hooks/app-store-compliance-guard.sh@@ -110,22 +110,22 @@ finding() { # severity id title fix# ----- platform detection -----IS_IOS=0; IS_AND=0; IS_WEB=0-find "$DIR" -maxdepth 4 \( -name '*.xcodeproj' -o -name '*.xcworkspace' -o -name 'Package.swift' -o -name 'Podfile' \) 2>/dev/null | grep -q . && IS_IOS=1-find "$DIR" -maxdepth 4 -name 'Info.plist' 2>/dev/null | grep -q . && IS_IOS=1-find "$DIR" -maxdepth 5 \( -name 'AndroidManifest.xml' -o -name 'build.gradle' -o -name 'build.gradle.kts' \) 2>/dev/null | grep -q . && IS_AND=1-find "$DIR" -maxdepth 4 \( -name 'package.json' -o -name 'index.html' -o -name 'webpack.config.js' -o -name 'next.config.js' \) 2>/dev/null | grep -q . && IS_WEB=1+find "$DIR" -maxdepth 4 \( -name '*.xcodeproj' -o -name '*.xcworkspace' -o -name 'Package.swift' -o -name 'Podfile' \) 2>/dev/null | grep -vE '/(node_modules|Pods|\.git|build|DerivedData|vendor|\.dart_tool|Carthage)/' | grep -q . && IS_IOS=1+find "$DIR" -maxdepth 4 -name 'Info.plist' 2>/dev/null | grep -vE '/(node_modules|Pods|\.git|build|DerivedData|vendor|\.dart_tool|Carthage)/' | grep -q . && IS_IOS=1+find "$DIR" -maxdepth 5 \( -name 'AndroidManifest.xml' -o -name 'build.gradle' -o -name 'build.gradle.kts' \) 2>/dev/null | grep -vE '/(node_modules|Pods|\.git|build|DerivedData|vendor|\.dart_tool|Carthage)/' | grep -q . && IS_AND=1+find "$DIR" -maxdepth 4 \( -name 'package.json' -o -name 'index.html' -o -name 'webpack.config.js' -o -name 'next.config.js' \) 2>/dev/null | grep -vE '/(node_modules|Pods|\.git|build|DerivedData|vendor|\.dart_tool|Carthage)/' | grep -q . && IS_WEB=1# ----- cross-platform framework detection -----# IS_IOS/IS_AND above still fire on the built artifact. This adds framework-specific checks.IS_FLUTTER=0; IS_RN=0; IS_IONIC=0-find "$DIR" -maxdepth 4 -name 'pubspec.yaml' 2>/dev/null | grep -q . && IS_FLUTTER=1+find "$DIR" -maxdepth 4 -name 'pubspec.yaml' 2>/dev/null | grep -vE '/(node_modules|Pods|\.git|build|DerivedData|vendor|\.dart_tool|Carthage)/' | grep -q . && IS_FLUTTER=1# Scan EVERY package.json within depth (not just the first), so a monorepo root's tooling# package.json never shadows a real apps/mobile/package.json deeper in the tree.while IFS= read -r pkg; dogrep -qE '"react-native"|"expo"' "$pkg" 2>/dev/null && IS_RN=1grep -qE '"@capacitor/core"|"@capacitor/ios"|"@capacitor/android"|"@ionic/(angular|react|vue)"|"cordova-android"|"cordova-ios"' "$pkg" 2>/dev/null && IS_IONIC=1done < <(find "$DIR" -maxdepth 4 -name 'package.json' 2>/dev/null | grep -vE '/(node_modules|ios/Pods)/')-find "$DIR" -maxdepth 4 -name 'capacitor.config.*' 2>/dev/null | grep -q . && IS_IONIC=1+find "$DIR" -maxdepth 4 -name 'capacitor.config.*' 2>/dev/null | grep -vE '/(node_modules|Pods|\.git|build|DerivedData|vendor|\.dart_tool|Carthage)/' | grep -q . && IS_IONIC=1# config.xml alone is ambiguous (Maven/NuGet/tooling also use that filename), so require the# Cordova widget marker before it counts as a signal.while IFS= read -r cfg; do@@ -306,6 +306,31 @@ if [ "$IS_IOS" -eq 1 ]; thenfinding critical "APPLE-PRIVACY-MANIFEST-MISSING" "Required reason APIs or SDKs present but no PrivacyInfo.xcprivacy" "Add a privacy manifest with approved reason codes and tracking domains, and confirm each SDK ships its signed manifest."fifi++ # A manifest that exists can still be internally inconsistent. Apple validates+ # these keys at upload and rejects by email (ITMS-91xxx) after processing, so+ # the binary installs from TestFlight and is still barred from review.+ MANIFEST_VALIDATOR=""+ for candidate in \+ "$(dirname "$0")/../../scripts/validate-privacy-manifest.py" \+ "$HOME/.claude/skills/app-store-compliance/scripts/validate-privacy-manifest.py"; do+ [ -f "$candidate" ] && { MANIFEST_VALIDATOR="$candidate"; break; }+ done+ if [ -n "$MANIFEST_VALIDATOR" ] && command -v python3 >/dev/null 2>&1; then+ # Same exclusions as the source file list. A pod's manifest is the vendor's job, a Tests fixture never ships.+ find "$DIR" -name 'PrivacyInfo.xcprivacy' 2>/dev/null \+ | grep -vE '/(node_modules|Pods|\.git|build|DerivedData|vendor|\.dart_tool|Carthage|[A-Za-z0-9_]*Tests|androidTest|__tests__)/' \+ | while IFS= read -r manifest; do+ python3 "$MANIFEST_VALIDATOR" "$manifest" 2>/dev/null+ done > "$FILELIST.manifest" 2>/dev/null || true+ if [ -s "$FILELIST.manifest" ]; then+ while IFS="$(printf '\t')" read -r sev id msg; do+ [ -n "$id" ] || continue+ finding "$sev" "$id" "$msg" "Correct the privacy manifest so its keys agree, then rebuild. Reference. https://developer.apple.com/documentation/bundleresources/privacy_manifest_files"+ done < "$FILELIST.manifest"+ fi+ rm -f "$FILELIST.manifest" 2>/dev/null || true+ figrep_has 'ITSAppUsesNonExemptEncryption' || finding high "APPLE-EXPORT-COMPLIANCE-MISSING" "ITSAppUsesNonExemptEncryption not set" "Set it in Info.plist or the build stalls in Missing Compliance and never reaches review."if grep_has 'SKProduct|Product\.purchase|StoreKit'; thengrep_has 'restorePurchases|restoreCompletedTransactions|AppStore\.sync|Restore Purchases' || finding high "APPLE-RESTORE-PURCHASES-MISSING" "StoreKit purchases without a Restore Purchases control" "Add a visible Restore Purchases control. Required for non consumables."diff --git a/scripts/validate-privacy-manifest-test.sh b/scripts/validate-privacy-manifest-test.shnew file mode 100755index 0000000..54387bb--- /dev/null+++ b/scripts/validate-privacy-manifest-test.sh@@ -0,0 +1,69 @@+#!/usr/bin/env bash+# Test suite for validate-privacy-manifest.py+set -uo pipefail+HERE="$(cd "$(dirname "$0")" && pwd)"+V="python3 $HERE/validate-privacy-manifest.py"+PASS=0; FAIL=0+ok(){ PASS=$((PASS+1)); printf 'PASS %s\n' "$1"; }+bad(){ FAIL=$((FAIL+1)); printf 'FAIL %s\n' "$1"; }+T=$(mktemp -d)+trap 'rm -rf "$T"' EXIT++write_manifest() { # file tracking domains_xml types_xml+ cat > "$1" <<PLIST+<?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>NSPrivacyTracking</key><$2/>+<key>NSPrivacyTrackingDomains</key>$3+<key>NSPrivacyCollectedDataTypes</key>$4+</dict></plist>+PLIST+}++TYPE_OK='<array><dict>+<key>NSPrivacyCollectedDataType</key><string>NSPrivacyCollectedDataTypeDeviceID</string>+<key>NSPrivacyCollectedDataTypeLinked</key><false/>+<key>NSPrivacyCollectedDataTypeTracking</key><true/>+<key>NSPrivacyCollectedDataTypePurposes</key><array><string>NSPrivacyCollectedDataTypePurposeDeveloperAdvertising</string></array>+</dict></array>'+DOMAINS='<array><string>att.attr.appsflyersdk.com</string></array>'++# 1 tracking true with no domains is the ITMS-91064 rejection+write_manifest "$T/a.xcprivacy" true '<array/>' "$TYPE_OK"+OUT="$($V "$T/a.xcprivacy" 2>&1)"+echo "$OUT" | grep -q 'APPLE-ITMS-91064-TRACKING-NO-DOMAINS' && ok "flags tracking true with empty domains" || bad "tracking/no-domains"++# 2 domains without tracking true is the converse+write_manifest "$T/b.xcprivacy" false "$DOMAINS" '<array/>'+OUT="$($V "$T/b.xcprivacy" 2>&1)"+echo "$OUT" | grep -q 'APPLE-ITMS-91064-DOMAINS-NO-TRACKING' && ok "flags domains with tracking false" || bad "domains/no-tracking"++# 3 a consistent manifest passes+write_manifest "$T/c.xcprivacy" true "$DOMAINS" "$TYPE_OK"+$V "$T/c.xcprivacy" >/dev/null 2>&1+[ $? -eq 0 ] && ok "consistent manifest passes" || bad "consistent manifest"++# 4 tracking false with no domains is valid, not a finding+write_manifest "$T/d.xcprivacy" false '<array/>' '<array/>'+$V "$T/d.xcprivacy" >/dev/null 2>&1+[ $? -eq 0 ] && ok "no tracking, no domains passes" || bad "no-tracking baseline"++# 5 a type used for tracking while the manifest says otherwise+write_manifest "$T/e.xcprivacy" false '<array/>' "$TYPE_OK"+OUT="$($V "$T/e.xcprivacy" 2>&1)"+echo "$OUT" | grep -q 'APPLE-MANIFEST-TRACKING-CONTRADICTION' && ok "flags per-type tracking contradiction" || bad "type contradiction"++# 6 unknown purpose constant+write_manifest "$T/f.xcprivacy" true "$DOMAINS" "${TYPE_OK/NSPrivacyCollectedDataTypePurposeDeveloperAdvertising/NSPrivacyCollectedDataTypePurposeMarketing}"+OUT="$($V "$T/f.xcprivacy" 2>&1)"+echo "$OUT" | grep -q 'APPLE-MANIFEST-BAD-PURPOSE' && ok "flags unknown purpose" || bad "bad purpose"++# 7 unreadable manifest exits 2 rather than passing silently+printf 'not a plist' > "$T/g.xcprivacy"+$V "$T/g.xcprivacy" >/dev/null 2>&1+[ $? -eq 2 ] && ok "unreadable manifest exits 2" || bad "unreadable exit code"++echo ""+echo "validate-privacy-manifest-test: $PASS passed, $FAIL failed"+[ "$FAIL" -eq 0 ]diff --git a/scripts/validate-privacy-manifest.py b/scripts/validate-privacy-manifest.pynew file mode 100755index 0000000..398371a--- /dev/null+++ b/scripts/validate-privacy-manifest.py@@ -0,0 +1,103 @@+#!/usr/bin/env python3+"""Validate the internals of an app's PrivacyInfo.xcprivacy.++The nutrition-label check in the guard only asks whether+NSPrivacyCollectedDataTypes exists. Apple additionally validates the manifest's+internal consistency at upload and rejects the build by email (ITMS-91xxx)+after processing, so a binary can install from TestFlight and still be barred+from review.++Usage: validate-privacy-manifest.py <path-to-PrivacyInfo.xcprivacy> [...]+Exit: 0 clean, 1 findings, 2 could not read a file.+Prints SEVERITY<TAB>ID<TAB>message per finding.+"""+import plistlib+import sys++VALID_PURPOSES = {+ "NSPrivacyCollectedDataTypePurposeThirdPartyAdvertising",+ "NSPrivacyCollectedDataTypePurposeDeveloperAdvertising",+ "NSPrivacyCollectedDataTypePurposeAnalytics",+ "NSPrivacyCollectedDataTypePurposeProductPersonalization",+ "NSPrivacyCollectedDataTypePurposeAppFunctionality",+ "NSPrivacyCollectedDataTypePurposeOther",+}++REQUIRED_ON_TYPE = (+ "NSPrivacyCollectedDataType",+ "NSPrivacyCollectedDataTypeLinked",+ "NSPrivacyCollectedDataTypeTracking",+ "NSPrivacyCollectedDataTypePurposes",+)+++def check(path):+ out = []+ try:+ with open(path, "rb") as fh:+ d = plistlib.load(fh)+ except Exception as exc: # unreadable or malformed+ return [("critical", "APPLE-MANIFEST-UNREADABLE",+ f"{path}: cannot parse privacy manifest ({exc})")], True++ tracking = d.get("NSPrivacyTracking", False)+ domains = d.get("NSPrivacyTrackingDomains", []) or []++ # ITMS-91064. Apple states the converse in the rejection email, but an+ # empty domain list alongside NSPrivacyTracking true is what fails.+ if tracking and not domains:+ out.append(("critical", "APPLE-ITMS-91064-TRACKING-NO-DOMAINS",+ f"{path}: NSPrivacyTracking is true but NSPrivacyTrackingDomains is empty. "+ "List every domain the app or its SDKs contact for tracking "+ "(an MMP such as AppsFlyer declares its own in the pod's manifest)."))+ if domains and not tracking:+ out.append(("critical", "APPLE-ITMS-91064-DOMAINS-NO-TRACKING",+ f"{path}: NSPrivacyTrackingDomains is non-empty but NSPrivacyTracking is false. "+ "Set NSPrivacyTracking to true, or remove the domains."))++ types = d.get("NSPrivacyCollectedDataTypes", [])+ for i, entry in enumerate(types):+ label = entry.get("NSPrivacyCollectedDataType", f"entry {i}")+ for key in REQUIRED_ON_TYPE:+ if key not in entry:+ out.append(("high", "APPLE-MANIFEST-TYPE-INCOMPLETE",+ f"{path}: collected data type {label} is missing {key}."))+ for purpose in entry.get("NSPrivacyCollectedDataTypePurposes", []):+ if purpose not in VALID_PURPOSES:+ out.append(("high", "APPLE-MANIFEST-BAD-PURPOSE",+ f"{path}: {label} declares unknown purpose {purpose}."))+ if not entry.get("NSPrivacyCollectedDataTypePurposes", []):+ out.append(("high", "APPLE-MANIFEST-NO-PURPOSE",+ f"{path}: {label} declares no purposes; at least one is required."))+ # Internally contradictory, but not a documented upload rejection, so it surfaces without blocking.+ if entry.get("NSPrivacyCollectedDataTypeTracking") and not tracking:+ out.append(("high", "APPLE-MANIFEST-TRACKING-CONTRADICTION",+ f"{path}: {label} is marked used for tracking but NSPrivacyTracking is false."))++ for api in d.get("NSPrivacyAccessedAPITypes", []):+ if not api.get("NSPrivacyAccessedAPITypeReasons"):+ out.append(("high", "APPLE-MANIFEST-API-NO-REASON",+ f"{path}: accessed API {api.get('NSPrivacyAccessedAPIType', '?')} "+ "declares no reason codes."))++ return out, False+++def main(argv):+ if len(argv) < 2:+ print("usage: validate-privacy-manifest.py <PrivacyInfo.xcprivacy> [...]", file=sys.stderr)+ return 2+ findings, unreadable = [], False+ for path in argv[1:]:+ got, bad = check(path)+ findings.extend(got)+ unreadable = unreadable or bad+ for sev, ident, msg in findings:+ print(f"{sev}\t{ident}\t{msg}")+ if unreadable:+ return 2+ return 1 if findings else 0+++if __name__ == "__main__":+ sys.exit(main(sys.argv))