appstore-precheck 1.19.0 → 1.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/README.md +81 -39
  3. package/package.json +2 -2
  4. package/skills/appstore-precheck/SKILL.md +39 -146
  5. package/skills/appstore-precheck/guidelines-baseline.json +284 -35
  6. package/skills/appstore-precheck/guidelines-fingerprints.json +307 -93
  7. package/skills/appstore-precheck/references/finding-commentary.md +93 -0
  8. package/skills/appstore-precheck/references/methodology.md +56 -19
  9. package/skills/appstore-precheck/references/optional-review.md +56 -0
  10. package/skills/appstore-precheck/references/pierre-deep-review.md +292 -47
  11. package/skills/appstore-precheck/references/review-catalog.json +500 -13
  12. package/skills/appstore-precheck/references/screenshot-vision-review.md +8 -8
  13. package/skills/appstore-precheck/references/simulator-dynamic-review.md +72 -12
  14. package/skills/appstore-precheck/references/typesafe.md +15 -0
  15. package/skills/appstore-precheck/scripts/artifact-review.sh +10 -0
  16. package/skills/appstore-precheck/scripts/augment-json.py +29 -0
  17. package/skills/appstore-precheck/scripts/build-run.sh +5 -0
  18. package/skills/appstore-precheck/scripts/coverage-sections.sh +6 -0
  19. package/skills/appstore-precheck/scripts/dynamic-run.sh +94 -9
  20. package/skills/appstore-precheck/scripts/dynamic.sh +25 -1
  21. package/skills/appstore-precheck/scripts/evidence.sh +8 -3
  22. package/skills/appstore-precheck/scripts/findings.sh +8 -0
  23. package/skills/appstore-precheck/scripts/lib/artifact-review.py +518 -0
  24. package/skills/appstore-precheck/scripts/lib/asc-client.py +293 -0
  25. package/skills/appstore-precheck/scripts/lib/build-evidence.py +50 -0
  26. package/skills/appstore-precheck/scripts/lib/build-exec.py +50 -0
  27. package/skills/appstore-precheck/scripts/lib/build-plan.py +106 -0
  28. package/skills/appstore-precheck/scripts/lib/build-plan.sh +15 -0
  29. package/skills/appstore-precheck/scripts/lib/build-run.py +177 -0
  30. package/skills/appstore-precheck/scripts/lib/coverage-run.sh +23 -0
  31. package/skills/appstore-precheck/scripts/lib/coverage-sections.py +244 -0
  32. package/skills/appstore-precheck/scripts/lib/dyn-demo-login.py +111 -0
  33. package/skills/appstore-precheck/scripts/lib/dyn-device.sh +32 -4
  34. package/skills/appstore-precheck/scripts/lib/dyn-explore.py +312 -0
  35. package/skills/appstore-precheck/scripts/lib/dyn-guideline-capture.py +301 -0
  36. package/skills/appstore-precheck/scripts/lib/dyn-guidelines.py +112 -0
  37. package/skills/appstore-precheck/scripts/lib/dyn-guidelines.sh +23 -0
  38. package/skills/appstore-precheck/scripts/lib/dyn-process.py +75 -0
  39. package/skills/appstore-precheck/scripts/lib/dyn-quorum.sh +28 -30
  40. package/skills/appstore-precheck/scripts/lib/dyn-scrub.py +79 -0
  41. package/skills/appstore-precheck/scripts/lib/dyn-signals.sh +2 -2
  42. package/skills/appstore-precheck/scripts/lib/metadata-review.py +369 -0
  43. package/skills/appstore-precheck/scripts/lib/optin-scan.sh +73 -0
  44. package/skills/appstore-precheck/scripts/lib/optional-records.py +60 -0
  45. package/skills/appstore-precheck/scripts/lib/runtime-blocking.py +26 -0
  46. package/skills/appstore-precheck/scripts/lib/safe_write.py +61 -0
  47. package/skills/appstore-precheck/scripts/lib/scan-guidelines.sh +199 -0
  48. package/skills/appstore-precheck/scripts/lib/static-guidelines.py +341 -0
  49. package/skills/appstore-precheck/scripts/lib/static-reader.py +39 -0
  50. package/skills/appstore-precheck/scripts/metadata-review.sh +4 -0
  51. package/skills/appstore-precheck/scripts/opt-in-review.py +160 -0
  52. package/skills/appstore-precheck/scripts/runtime-review.sh +5 -0
  53. package/skills/appstore-precheck/scripts/scan.sh +56 -23
  54. package/skills/appstore-precheck/scripts/semantic/client.py +3 -1
  55. package/skills/appstore-precheck/scripts/semantic/collect.py +82 -38
  56. package/skills/appstore-precheck/scripts/semantic/engine.py +165 -127
  57. package/skills/appstore-precheck/scripts/semantic/questions.py +5 -1
  58. package/skills/appstore-precheck/scripts/semantic/review_v4.py +81 -0
@@ -0,0 +1,199 @@
1
+ #!/usr/bin/env bash
2
+ # Additional source checks are advisory; absent inputs remain additive coverage gaps.
3
+ # shellcheck disable=SC2034
4
+ COVERAGE_GAPS_JSON="${COVERAGE_GAPS_JSON:-[]}"
5
+ STATIC_GAP_COUNT=0 STATIC_GAP_SLUGS="" STATIC_GAP_REASON="" STATIC_EMOJI_STATUS=SKIP
6
+ STATIC_GUIDELINES_JSON='{}'
7
+ if command -v python3 >/dev/null 2>&1 && command -v jq >/dev/null 2>&1; then
8
+ STATIC_GUIDELINES_JSON="$(python3 -B "$SCRIPT_DIR/lib/static-reader.py" \
9
+ --root "$ROOT" --metadata "${META_DIR:-/nonexistent}" --plist "${INFO_PLIST:-/nonexistent}" \
10
+ "${GREP_PRUNE[@]+"${GREP_PRUNE[@]}"}" )" || STATIC_GUIDELINES_JSON='{"_reader_error":"reader invocation failed; see stderr"}'
11
+ fi
12
+
13
+ static_guideline_select() {
14
+ local row
15
+ STATIC_STATUS=SKIP STATIC_REASON="Python 3 or jq unavailable, or source reader failed." STATIC_FILE=""
16
+ if command -v jq >/dev/null 2>&1; then
17
+ STATIC_REASON="$(printf '%s' "$STATIC_GUIDELINES_JSON" | jq -r '._reader_error // "Python 3 or jq unavailable, or source reader failed."')"
18
+ row="$(printf '%s' "$STATIC_GUIDELINES_JSON" | jq -cer --arg id "$1" '.[$id] // empty' 2>/dev/null)" || return 0
19
+ STATIC_STATUS="$(printf '%s' "$row" | jq -r '.status')"
20
+ STATIC_REASON="$(printf '%s' "$row" | jq -jr '.reason' | tr '\n\r\t' ' ')"
21
+ STATIC_FILE="$(printf '%s' "$row" | jq -jr '.file' | tr '\n\r\t' ' ')"
22
+ fi
23
+ }
24
+
25
+ static_guideline_gap() {
26
+ local id="$1" guideline="$2" reason="$3"
27
+ STATIC_GAP_COUNT=$((STATIC_GAP_COUNT + 1))
28
+ STATIC_GAP_SLUGS="${STATIC_GAP_SLUGS}${STATIC_GAP_SLUGS:+, }$id"
29
+ STATIC_GAP_REASON="$reason"
30
+ if command -v jq >/dev/null 2>&1; then
31
+ COVERAGE_GAPS_JSON="$(printf '%s' "$COVERAGE_GAPS_JSON" | jq -c \
32
+ --arg id "$id" --arg guideline "$guideline" --arg reason "$reason" \
33
+ '. + [{rule_id:$id,guideline:$guideline,status:"SKIP",reason:$reason}]')"
34
+ else
35
+ # These two values come only from the literal call sites below, never input files.
36
+ COVERAGE_GAPS_JSON="${COVERAGE_GAPS_JSON%]}"
37
+ [[ "$COVERAGE_GAPS_JSON" == '[' ]] || COVERAGE_GAPS_JSON+=','
38
+ COVERAGE_GAPS_JSON+="{\"rule_id\":\"$id\",\"guideline\":\"$guideline\",\"status\":\"SKIP\",\"reason\":\"Optional Python 3/jq reader unavailable.\"}]"
39
+ fi
40
+ }
41
+
42
+ # §56 — 2.3.12: release-notes-specificity
43
+ set_rule "release-notes-specificity"
44
+ static_guideline_select "release-notes-specificity"
45
+ case "$STATIC_STATUS" in
46
+ WARN) warn "2.3.12 release-notes-specificity — $STATIC_REASON" "$STATIC_FILE" ;;
47
+ PASS) pass "2.3.12 release-notes-specificity — $STATIC_REASON" ;;
48
+ *) static_guideline_gap "release-notes-specificity" "2.3.12" "$STATIC_REASON" ;;
49
+ esac
50
+
51
+ # §57 — 2.4.4: device-restart-instructions
52
+ set_rule "device-restart-instructions"
53
+ static_guideline_select "device-restart-instructions"
54
+ case "$STATIC_STATUS" in
55
+ WARN) warn "2.4.4 device-restart-instructions — $STATIC_REASON" "$STATIC_FILE" ;;
56
+ PASS) pass "2.4.4 device-restart-instructions — $STATIC_REASON" ;;
57
+ *) static_guideline_gap "device-restart-instructions" "2.4.4" "$STATIC_REASON" ;;
58
+ esac
59
+
60
+ # §58 — 2.5.6: browser-engine
61
+ set_rule "browser-engine"
62
+ static_guideline_select "browser-engine"
63
+ case "$STATIC_STATUS" in
64
+ WARN) warn "2.5.6 browser-engine — $STATIC_REASON" "$STATIC_FILE" ;;
65
+ PASS) pass "2.5.6 browser-engine — $STATIC_REASON" ;;
66
+ *) static_guideline_gap "browser-engine" "2.5.6" "$STATIC_REASON" ;;
67
+ esac
68
+
69
+ # §59 — 2.5.11: intent-handler-parity
70
+ set_rule "intent-handler-parity"
71
+ static_guideline_select "intent-handler-parity"
72
+ case "$STATIC_STATUS" in
73
+ WARN) warn "2.5.11 intent-handler-parity — $STATIC_REASON" "$STATIC_FILE" ;;
74
+ PASS) pass "2.5.11 intent-handler-parity — $STATIC_REASON" ;;
75
+ *) static_guideline_gap "intent-handler-parity" "2.5.11" "$STATIC_REASON" ;;
76
+ esac
77
+
78
+ # §60 — 2.5.12: call-filter-controls
79
+ set_rule "call-filter-controls"
80
+ static_guideline_select "call-filter-controls"
81
+ case "$STATIC_STATUS" in
82
+ WARN) warn "2.5.12 call-filter-controls — $STATIC_REASON" "$STATIC_FILE" ;;
83
+ PASS) pass "2.5.12 call-filter-controls — $STATIC_REASON" ;;
84
+ *) static_guideline_gap "call-filter-controls" "2.5.12" "$STATIC_REASON" ;;
85
+ esac
86
+
87
+ # §61 — 2.5.13: face-authentication
88
+ set_rule "face-authentication"
89
+ static_guideline_select "face-authentication"
90
+ case "$STATIC_STATUS" in
91
+ WARN) warn "2.5.13 face-authentication — $STATIC_REASON" "$STATIC_FILE" ;;
92
+ PASS) pass "2.5.13 face-authentication — $STATIC_REASON" ;;
93
+ *) static_guideline_gap "face-authentication" "2.5.13" "$STATIC_REASON" ;;
94
+ esac
95
+
96
+ # §62 — 2.5.15: document-browser-access
97
+ set_rule "document-browser-access"
98
+ static_guideline_select "document-browser-access"
99
+ case "$STATIC_STATUS" in
100
+ WARN) warn "2.5.15 document-browser-access — $STATIC_REASON" "$STATIC_FILE" ;;
101
+ PASS) pass "2.5.15 document-browser-access — $STATIC_REASON" ;;
102
+ *) static_guideline_gap "document-browser-access" "2.5.15" "$STATIC_REASON" ;;
103
+ esac
104
+
105
+ # §63 — 2.5.16: extension-bundle-parity
106
+ set_rule "extension-bundle-parity"
107
+ static_guideline_select "extension-bundle-parity"
108
+ case "$STATIC_STATUS" in
109
+ WARN) warn "2.5.16 extension-bundle-parity — $STATIC_REASON" "$STATIC_FILE" ;;
110
+ PASS) pass "2.5.16 extension-bundle-parity — $STATIC_REASON" ;;
111
+ *) static_guideline_gap "extension-bundle-parity" "2.5.16" "$STATIC_REASON" ;;
112
+ esac
113
+
114
+ # §64 — 2.5.17: matter-extension
115
+ set_rule "matter-extension"
116
+ static_guideline_select "matter-extension"
117
+ case "$STATIC_STATUS" in
118
+ WARN) warn "2.5.17 matter-extension — $STATIC_REASON" "$STATIC_FILE" ;;
119
+ PASS) pass "2.5.17 matter-extension — $STATIC_REASON" ;;
120
+ *) static_guideline_gap "matter-extension" "2.5.17" "$STATIC_REASON" ;;
121
+ esac
122
+
123
+ # §65 — 2.5.18: extension-advertising
124
+ set_rule "extension-advertising"
125
+ static_guideline_select "extension-advertising"
126
+ case "$STATIC_STATUS" in
127
+ WARN) warn "2.5.18 extension-advertising — $STATIC_REASON" "$STATIC_FILE" ;;
128
+ PASS) pass "2.5.18 extension-advertising — $STATIC_REASON" ;;
129
+ *) static_guideline_gap "extension-advertising" "2.5.18" "$STATIC_REASON" ;;
130
+ esac
131
+
132
+ # §66 — 4.2.1: ar-integration-depth
133
+ set_rule "ar-integration-depth"
134
+ static_guideline_select "ar-integration-depth"
135
+ case "$STATIC_STATUS" in
136
+ WARN) warn "4.2.1 ar-integration-depth — $STATIC_REASON" "$STATIC_FILE" ;;
137
+ PASS) pass "4.2.1 ar-integration-depth — $STATIC_REASON" ;;
138
+ *) static_guideline_gap "ar-integration-depth" "4.2.1" "$STATIC_REASON" ;;
139
+ esac
140
+
141
+ # §67 — 4.2.3: companion-app-required
142
+ set_rule "companion-app-required"
143
+ static_guideline_select "companion-app-required"
144
+ case "$STATIC_STATUS" in
145
+ WARN) warn "4.2.3 companion-app-required — $STATIC_REASON" "$STATIC_FILE" ;;
146
+ PASS) pass "4.2.3 companion-app-required — $STATIC_REASON" ;;
147
+ *) static_guideline_gap "companion-app-required" "4.2.3" "$STATIC_REASON" ;;
148
+ esac
149
+
150
+ # §68 — 4.5.5: game-center-id-sharing
151
+ set_rule "game-center-id-sharing"
152
+ static_guideline_select "game-center-id-sharing"
153
+ case "$STATIC_STATUS" in
154
+ WARN) warn "4.5.5 game-center-id-sharing — $STATIC_REASON" "$STATIC_FILE" ;;
155
+ PASS) pass "4.5.5 game-center-id-sharing — $STATIC_REASON" ;;
156
+ *) static_guideline_gap "game-center-id-sharing" "4.5.5" "$STATIC_REASON" ;;
157
+ esac
158
+
159
+ # §69 — 4.5.6: metadata-emoji
160
+ set_rule "metadata-emoji"
161
+ static_guideline_select "metadata-emoji"
162
+ case "$STATIC_STATUS" in
163
+ WARN) warn "4.5.6 metadata-emoji — $STATIC_REASON" "$STATIC_FILE" ;;
164
+ PASS) pass "4.5.6 metadata-emoji — $STATIC_REASON" ;;
165
+ *) static_guideline_gap "metadata-emoji" "4.5.6" "$STATIC_REASON" ;;
166
+ esac
167
+
168
+ STATIC_EMOJI_STATUS="$STATIC_STATUS"
169
+
170
+ # §70 — 4.7.2: miniapp-native-bridge
171
+ set_rule "miniapp-native-bridge"
172
+ static_guideline_select "miniapp-native-bridge"
173
+ case "$STATIC_STATUS" in
174
+ WARN) warn "4.7.2 miniapp-native-bridge — $STATIC_REASON" "$STATIC_FILE" ;;
175
+ PASS) pass "4.7.2 miniapp-native-bridge — $STATIC_REASON" ;;
176
+ *) static_guideline_gap "miniapp-native-bridge" "4.7.2" "$STATIC_REASON" ;;
177
+ esac
178
+
179
+ # §71 — 5.2.4: apple-endorsement-claims
180
+ set_rule "apple-endorsement-claims"
181
+ static_guideline_select "apple-endorsement-claims"
182
+ case "$STATIC_STATUS" in
183
+ WARN) warn "5.2.4 apple-endorsement-claims — $STATIC_REASON" "$STATIC_FILE" ;;
184
+ PASS) pass "5.2.4 apple-endorsement-claims — $STATIC_REASON" ;;
185
+ *) static_guideline_gap "apple-endorsement-claims" "5.2.4" "$STATIC_REASON" ;;
186
+ esac
187
+
188
+ if [[ "$STATIC_EMOJI_STATUS" != SKIP ]]; then
189
+ static_guideline_gap "metadata-emoji-icon-not-audited" "4.5.6" "Apple emoji artwork in icon pixels requires visual review."
190
+ fi
191
+ if command -v jq >/dev/null 2>&1; then
192
+ _input_gap="$(printf '%s' "$STATIC_GUIDELINES_JSON" | jq -r '._input_gaps // empty | "\(.count) files skipped: \(.paths | join(", "))"')"
193
+ if [[ -n "$_input_gap" ]]; then static_guideline_gap "source-inputs-not-audited" "source" "$_input_gap"; fi
194
+ STATIC_GAP_REASON="$(printf '%s' "$COVERAGE_GAPS_JSON" | jq -jr '[.[].reason] | unique | join("; ")' | tr '\n\r\t' ' ')"
195
+ fi
196
+ if [[ "$STATIC_GAP_COUNT" -gt 0 ]]; then
197
+ set_rule "modular-checks-not-audited"
198
+ skip "modular-checks-not-audited — $STATIC_GAP_COUNT check(s) did not run: $STATIC_GAP_SLUGS ($STATIC_GAP_REASON)"
199
+ fi
@@ -0,0 +1,341 @@
1
+ #!/usr/bin/env python3
2
+ """Narrow, advisory source/manifest/metadata checks; never shipping proof."""
3
+ import argparse
4
+ import fnmatch
5
+ import json
6
+ import os
7
+ import pathlib
8
+ import plistlib
9
+ import re
10
+ from xml.parsers.expat import ExpatError
11
+
12
+ PRUNE = {'.git', 'Pods', 'Carthage', '.build', 'build', 'DerivedData',
13
+ 'SourcePackages', 'checkouts', '.swiftpm', '.claude', 'worktrees',
14
+ 'node_modules', 'vendor', '.planning', '.symlinks', '*.app', '*.xcarchive', '*.dSYM', '*.xcframework'}
15
+ SOURCE = {'.swift', '.m', '.mm', '.h', '.js', '.jsx', '.ts', '.tsx'}
16
+ RESOURCE = {'.strings', '.xcstrings'}
17
+ ADS = (r'GoogleMobileAds|GADMobileAds|AppLovinSDK|ALSdk|AppsFlyerLib|\bAdjust\b|'
18
+ r'FBAudienceNetwork|BranchSDK|IronSource|UnityAds|VungleAds|Chartboost|'
19
+ r'InMobi|IMSdk|MTGSDK|PAGAdSDK|BUAdSDK|\bSingular\b|KochavaTracker|TenjinSDK')
20
+ TOKEN = re.compile(r'"(?:\\.|[^"\\])*"|\'(?:\\.|[^\'\\])*\'|//[^\n]*|/\*.*?\*/', re.S)
21
+
22
+
23
+ def uncomment(text):
24
+ return TOKEN.sub(lambda m: '\n' * m[0].count('\n') if m[0].startswith(('/', '/*')) else m[0], text)
25
+
26
+
27
+ def checked_text(path):
28
+ if path.is_symlink():
29
+ raise ValueError('symlink input not followed')
30
+ limit = 8 if path.suffix in RESOURCE else 2
31
+ if path.stat().st_size > limit * 1024 * 1024:
32
+ raise ValueError('input exceeds %d MiB read limit' % limit)
33
+ with path.open('rb') as stream:
34
+ bom = stream.read(2)
35
+ encoding = 'utf-16' if path.suffix == '.strings' and bom in (b'\xff\xfe', b'\xfe\xff') else 'utf-8'
36
+ return path.read_text(encoding=encoding)
37
+
38
+
39
+ def input_error(path, exc, root=None):
40
+ path = pathlib.Path(path)
41
+ try:
42
+ name = str(path.relative_to(root)) if root else path.name
43
+ except ValueError:
44
+ name = path.name
45
+ return name
46
+
47
+
48
+ def read_candidate(path):
49
+ if path.suffix in {'.plist', '.entitlements'}:
50
+ if path.is_symlink() or path.stat().st_size > 2 * 1024 * 1024:
51
+ raise ValueError('manifest is a symlink or exceeds 2 MiB read limit')
52
+ with path.open('rb') as stream:
53
+ value = plistlib.load(stream)
54
+ if not isinstance(value, dict):
55
+ raise ValueError('manifest root is not a dictionary')
56
+ return plistlib.dumps(value).decode('utf-8')
57
+ return checked_text(path)
58
+
59
+
60
+ def read_files(root, excludes):
61
+ result, gaps = {}, []
62
+ onerror = lambda exc: gaps.append(input_error(exc.filename, exc, root))
63
+ for folder, dirs, files in os.walk(root, followlinks=False, onerror=onerror):
64
+ keep = [d for d in dirs if not any(fnmatch.fnmatch(d, pattern) for pattern in PRUNE | set(excludes))]
65
+ for d in keep:
66
+ if (pathlib.Path(folder) / d).is_symlink():
67
+ gaps.append(input_error(pathlib.Path(folder) / d, ValueError('symlink'), root))
68
+ dirs[:] = [d for d in keep if not (pathlib.Path(folder) / d).is_symlink()]
69
+ for name in files:
70
+ path = pathlib.Path(folder) / name
71
+ if path.suffix not in SOURCE | RESOURCE | {'.plist', '.entitlements', '.pbxproj'} and name not in {'Podfile', 'Package.swift', 'Package.resolved'}:
72
+ continue
73
+ try:
74
+ result[path] = read_candidate(path)
75
+ except (OSError, UnicodeError, ValueError, plistlib.InvalidFileException, ExpatError) as exc:
76
+ gaps.append(input_error(path, exc, root))
77
+ return result, gaps
78
+
79
+
80
+ def context(root, metadata, main, excludes):
81
+ files, gaps = read_files(root, excludes)
82
+ src = {p: uncomment(t) for p, t in files.items() if p.suffix in SOURCE}
83
+ resources = {p: t for p, t in files.items() if p.suffix in RESOURCE}
84
+ plists = {p: plistlib.loads(t.encode('utf-8')) for p, t in files.items()
85
+ if p.suffix in {'.plist', '.entitlements'}}
86
+ main_data = plists.get(main, {})
87
+ if main not in plists and main.exists():
88
+ try:
89
+ main_data = plistlib.loads(read_candidate(main).encode('utf-8'))
90
+ except (OSError, UnicodeError, ValueError, plistlib.InvalidFileException, ExpatError) as exc:
91
+ gaps.append(input_error(main, exc, root))
92
+ extensions = {p: v for p, v in plists.items() if 'NSExtension' in v or 'NSAppClip' in v}
93
+ return dict(root=root, metadata=metadata, main=main_data, files=files, gaps=gaps,
94
+ src=src, resources=resources, plists=plists, extensions=extensions)
95
+
96
+
97
+ def outcome(hit=False, reason='', path=None, skip=False):
98
+ return dict(status='SKIP' if skip else 'WARN' if hit else 'PASS',
99
+ reason=reason or 'No matching risk signal in scanned inputs.',
100
+ file=str(path) if path else '')
101
+
102
+
103
+ def hit_file(files, pattern):
104
+ return next((p for p, text in files.items() if re.search(pattern, text, re.I)), None)
105
+
106
+
107
+ def metadata_files(c, names):
108
+ base = c['metadata']
109
+ if not base.is_dir() or base.is_symlink():
110
+ return []
111
+ files = [p for locale in sorted(base.iterdir()) if locale.is_dir() and not locale.is_symlink()
112
+ and locale.name not in {'default', 'review_information', 'trade_representative_contact_information'}
113
+ for name in names for p in [locale / (name + '.txt')] if p.is_file() or p.is_symlink()]
114
+ for p in files:
115
+ try:
116
+ checked_text(p)
117
+ except (OSError, UnicodeError, ValueError) as exc:
118
+ raise ValueError(input_error(p, exc)) from exc
119
+ return files
120
+
121
+
122
+ def release_notes(c):
123
+ files = metadata_files(c, ['release_notes'])
124
+ if not files:
125
+ return outcome(skip=True, reason='Release notes metadata unavailable.')
126
+ for p in files:
127
+ value = checked_text(p).strip()
128
+ desc = p.with_name('description.txt')
129
+ same = desc.is_file() and not desc.is_symlink() and value == checked_text(desc).strip()
130
+ version_file = c['metadata'] / 'version.txt'
131
+ version = checked_text(version_file).strip() if version_file.is_file() else ''
132
+ if not value and version == '1.0':
133
+ continue
134
+ if not value and not version:
135
+ return outcome(True, 'Empty release notes with unknown version; low-confidence update review.', p)
136
+ if not value or re.fullmatch(r'lorem(?: ipsum)?[.!]?|TODO|N[/-]A', value, re.I) or same:
137
+ return outcome(True, 'Release notes are empty, a placeholder, or repeat the description.', p)
138
+ return outcome(reason='Release notes contain specific non-placeholder text.')
139
+
140
+
141
+ def restart(c):
142
+ source = {p: t for p, t in c['src'].items()
143
+ if not re.search(r'(?m)^\s*(?:@testable\s+)?import\s+(?:Testing|XCTest)\b', t)}
144
+ p = hit_file(source, r'"[^"\n]*(?:restart your device|reboot|change your settings in Settings\s*>\s*General)[^"\n]*"')
145
+ p = p or hit_file(c['resources'], r'restart your device|\breboot\b|change your settings in Settings\s*>\s*General')
146
+ return outcome(bool(p), 'Device restart/settings instruction string; inspect the user-facing context.' if p else '', p)
147
+
148
+
149
+ def browser(c):
150
+ deps = {p: uncomment(t) for p, t in c['files'].items() if p.name in {'Podfile', 'Package.swift', 'Package.resolved'} or p.suffix == '.pbxproj'}
151
+ p = next((p for p, text in deps.items()
152
+ if re.search(r"[\"'][^\"'\n]*\b(?:Chromium|CEF|Gecko|Blink)\b(?![^\"'\n]*\.(?:swift|m|mm|h|storyboard|xib)[\"'])|\b(?:Chromium|CEF|Gecko|Blink)\.framework", text)), None)
153
+ legacy = hit_file(c['src'], r'\bUIWebView\s*(?:\(|[*>])|:\s*UIWebView\b')
154
+ if legacy:
155
+ return outcome(True, 'Deprecated UIWebView reference; verify the shipping target and Xcode SDK before removal.', legacy)
156
+ return outcome(bool(p), 'Non-WebKit engine dependency signal; verify entitlement and regional eligibility.' if p else '', p)
157
+
158
+
159
+ def intents(c):
160
+ declared = any(v.get('INIntentsSupported') or
161
+ re.search(r'intent', json.dumps(v.get('NSExtension', {})), re.I) for v in c['plists'].values())
162
+ handler = hit_file(c['src'], r'\b(?:INExtension|INIntentHandlerProviding|\w+IntentHandling)\b|func\s+handler\s*\(\s*for\s+intent')
163
+ modern = hit_file(c['src'], r':\s*(?:\w+\s*,\s*)?(?:AppIntent|AppShortcutsProvider)\b')
164
+ bad = (declared and not (handler or modern)) or (handler and not declared)
165
+ return outcome(bool(bad), 'Intent declaration/legacy handler mismatch; inspect target membership. AppIntent discovery needs no legacy plist.' if bad else 'No intent parity mismatch (or intents not used).', handler)
166
+
167
+
168
+ def call_filter(c):
169
+ p = hit_file(c['src'], r'\b(?:ILMessageFilterExtension|CXCallDirectoryProvider|CXCallDirectoryManager)\b')
170
+ ui = hit_file(c['src'], r'"[^"\n]*(?:blocked (?:numbers|callers)|call blocking|spam filter|blocking settings)[^"\n]*"') or hit_file(c['resources'], r'blocked numbers|call blocking|spam filter')
171
+ return outcome(bool(p and not ui), 'Call/filter API signal without a visible blocking-control label; inspect reachable settings.' if p and not ui else 'No missing filter-control signal (or APIs not used).', p)
172
+
173
+
174
+ def face_auth(c):
175
+ native = hit_file(c['src'], r'\b(?:LocalAuthentication|LAContext)\b')
176
+ for p, text in c['src'].items():
177
+ face = re.search(r'\b(?:VNFaceObservation|VNDetectFace\w*|FaceTecSDK|FacePhi)\b', text)
178
+ auth = re.search(r'login|authenticate|authentication|identity verification', text, re.I)
179
+ if face and auth and not native:
180
+ return outcome(True, 'Face recognition and authentication context coexist without LocalAuthentication; inspect authentication design.', p)
181
+ return outcome(reason='No custom face-authentication signal (or native authentication present).')
182
+
183
+
184
+ def documents(c):
185
+ picker = hit_file(c['src'], r'\bUIDocumentPicker\w*\b|\.fileImporter\s*\(|\bUIDocumentBrowserViewController\b')
186
+ if picker:
187
+ return outcome(reason='System document access is used; inspect custom browser reachability separately.')
188
+ custom = next((p for p, t in c['src'].items()
189
+ if re.search(r'FileManager\.default\.contentsOfDirectory', t)
190
+ and re.search(r'\b(?:List|Table|UICollectionView|UITableView)\b', t)), None)
191
+ custom = custom or hit_file(c['src'], r'(?:navigationTitle|Text|title\s*=)\s*\(?\s*"(?:My Files|Files|Documents)"')
192
+ custom = custom or hit_file(c['resources'], r'"(?:My Files|Files|Documents)"')
193
+ return outcome(bool(custom), 'Custom file-browser signal without system document access; inspect Files/iCloud availability.' if custom else 'No custom file-browser signal.', custom)
194
+
195
+
196
+ def extension_parity(c):
197
+ if not c['extensions']:
198
+ return outcome(reason='No discoverable extension target.')
199
+ main_id = c['main'].get('CFBundleIdentifier', '')
200
+ if not main_id or '$(' in main_id or '${' in main_id:
201
+ return outcome(skip=True, reason='Main bundle identifier is absent or build-setting-derived; archive verification required.')
202
+ for p, value in c['extensions'].items():
203
+ bid = value.get('CFBundleIdentifier', '')
204
+ if not bid or '$(' in bid or '${' in bid:
205
+ return outcome(skip=True, reason='Extension bundle id resolved by build settings; archive verification required.', path=p)
206
+ if not bid or not bid.startswith(main_id + '.'):
207
+ return outcome(True, 'Extension bundle identifier is missing or lacks the main-app prefix; verify target configuration.', p)
208
+ return outcome(reason='Literal extension bundle identifiers share the main-app prefix.')
209
+
210
+
211
+ def matter(c):
212
+ p = hit_file(c['src'], r'\bimport\s+(?:MatterSupport|Matter)\b')
213
+ entitlement = any('com.apple.developer.matter.allow-setup-payload' in v for v in c['plists'].values())
214
+ supported = any(re.search('matter', json.dumps(v.get('NSExtension', {})), re.I) for v in c['extensions'].values())
215
+ return outcome(bool((p or entitlement) and not supported), 'Matter setup signal without a discoverable MatterSupport extension; verify target configuration.' if (p or entitlement) and not supported else 'No missing Matter extension signal (or Matter not used).', p)
216
+
217
+
218
+ def extension_ads(c):
219
+ if not c['extensions']:
220
+ return outcome(skip=True, reason='No discoverable extension target; not applicable.')
221
+ for plist in c['extensions']:
222
+ if plist.parent == c['root'] or plist.parent.name in {'ios', 'Sources', 'src'}:
223
+ return outcome(skip=True, reason='Extension source dir unresolved; inspect target membership.', path=plist)
224
+ files = {p: t for p, t in c['src'].items() if plist.parent in p.parents}
225
+ p = hit_file(files, r'(?:import\s+|@import\s+|#import\s*[<"])(?:' + ADS + r')\b')
226
+ if p:
227
+ return outcome(True, 'Advertising/attribution SDK imported by extension-directory source; verify extension target membership.', p)
228
+ return outcome(reason='No advertising import in discovered extension directories; resolved link phases are not audited.')
229
+
230
+
231
+ def ar_depth(c):
232
+ p = hit_file(c['src'], r'\bimport\s+ARKit\b') or hit_file(c['files'], r'ARKit\.framework')
233
+ if not p:
234
+ return outcome(reason='ARKit not used.')
235
+ sessions = [f for f, t in c['src'].items() if re.search(r'\b(?:ARSession|ARView|RealityKit)\b', t)]
236
+ screens = sum(len(re.findall(r'struct\s+\w+\s*:\s*View\b|class\s+\w+\s*:\s*UIViewController\b', t)) for t in c['src'].values())
237
+ bad = len(sessions) == 1 and screens < 2
238
+ return outcome(bad, 'AR use is confined to one source file with fewer than two view declarations; low-confidence depth review, not proof of inadequate AR.' if bad else 'No narrow AR-depth signal.', p)
239
+
240
+
241
+ def companion(c):
242
+ p = hit_file(c['src'], r'"[^"\n]*(?:download|install)\s+[^"\n]{1,60}\s+to (?:continue|proceed|use)[^"\n]*"') or hit_file(c['resources'], r'(?:download|install)\s+[^"\n]{1,60}\s+to (?:continue|proceed|use)')
243
+ bad = bool(c['main'].get('LSApplicationQueriesSchemes') and p)
244
+ return outcome(bad, 'App-query schemes coexist with an install-to-continue instruction; inspect whether core functionality requires another app.' if bad else '', p if bad else None)
245
+
246
+
247
+ def game_ids(c):
248
+ for p, text in c['src'].items():
249
+ if re.search(r'\bGameKit\b', text) and re.search(r'\b(?:playerID|gamePlayerID|teamPlayerID)\b', text) and re.search(r'\b(?:URLRequest|URLSession|Analytics\.logEvent|Mixpanel|Amplitude)\b', text):
250
+ return outcome(True, 'Game Center identifier and network/analytics code coexist in one file; trace actual data flow before concluding sharing.', p)
251
+ return outcome(reason='No co-located Game Center identifier/network signal (or GameKit not used).')
252
+
253
+
254
+ def emoji(c):
255
+ if not c['root'].is_dir():
256
+ return outcome(skip=True, reason='Asset root is unavailable.')
257
+ seen = 0
258
+ for folder, dirs, files in os.walk(c['root'], followlinks=False):
259
+ seen += len(files)
260
+ dirs[:] = [d for d in dirs if not any(fnmatch.fnmatch(d, pattern) for pattern in PRUNE)
261
+ and not (pathlib.Path(folder) / d).is_symlink()]
262
+ for name in dirs + files:
263
+ p = pathlib.Path(folder) / name
264
+ suspect = (name.lower().endswith('.imageset') and 'emoji' in name.lower())
265
+ suspect = suspect or name.lower() == 'applecoloremoji.ttc'
266
+ suspect = suspect or bool(re.search(r'(?:^|[_ -])(?:applecoloremoji|emoji)(?:[_ -]|\.)', name, re.I) and p.suffix.lower() == '.png')
267
+ if suspect:
268
+ return outcome(True, 'Possible embedded Apple emoji artwork by asset name; low-confidence visual/license review required.', p)
269
+ if seen == 0:
270
+ return outcome(skip=True, reason='No project files were read; emoji artwork assets not audited.')
271
+ return outcome(reason='Apple emoji artwork asset signal not used.')
272
+
273
+
274
+ def miniapp(c):
275
+ for p, text in c['src'].items():
276
+ terms = [r'\bWKScriptMessageHandler\b', r'https?://[^"\s]{1,2048}(?:\.js\b|/scripts?/)', r'\bevaluateJavaScript\b', r'\b(?:CLLocationManager|AVCaptureSession|CNContactStore|requestWhenInUseAuthorization)\b']
277
+ if all(re.search(term, text) for term in terms):
278
+ return outcome(True, 'Remote JavaScript, message handler, evaluation and native-sensitive API coexist; inspect mini-app bridge exposure.', p)
279
+ return outcome(reason='No combined remote-script/native-sensitive bridge signal (or webview not used).')
280
+
281
+
282
+ def endorsements(c):
283
+ files = metadata_files(c, ['name', 'subtitle', 'description', 'keywords', 'promotional_text', 'release_notes'])
284
+ if not files:
285
+ return outcome(skip=True, reason='Store metadata unavailable.')
286
+ for p in files:
287
+ if re.search(r'Apple recommends|featured by Apple|Apple.s choice|Apple Design Award|#1 on the App Store|(?:official|endorsed by|approved by)\s+(?:Apple|App Store)', checked_text(p), re.I):
288
+ return outcome(True, 'Apple endorsement/official-product marketing claim; verify authorization and accuracy.', p)
289
+ return outcome(reason='No matched Apple endorsement claim in metadata.')
290
+
291
+
292
+ CHECKS = {'release-notes-specificity': release_notes, 'device-restart-instructions': restart,
293
+ 'browser-engine': browser, 'intent-handler-parity': intents,
294
+ 'call-filter-controls': call_filter, 'face-authentication': face_auth,
295
+ 'document-browser-access': documents, 'extension-bundle-parity': extension_parity,
296
+ 'matter-extension': matter, 'extension-advertising': extension_ads,
297
+ 'ar-integration-depth': ar_depth, 'companion-app-required': companion,
298
+ 'game-center-id-sharing': game_ids, 'metadata-emoji': emoji,
299
+ 'miniapp-native-bridge': miniapp, 'apple-endorsement-claims': endorsements}
300
+
301
+
302
+ def evaluate(root, metadata, main, excludes):
303
+ c = context(root, metadata, main, excludes)
304
+ result = {}
305
+ independent = {'release-notes-specificity', 'metadata-emoji', 'apple-endorsement-claims'}
306
+ if c['gaps']:
307
+ result['_input_gaps'] = {'count': len(set(c['gaps'])), 'paths': sorted(set(c['gaps']))[:3]}
308
+ for key, check in CHECKS.items():
309
+ if key not in independent and not c['src']:
310
+ result[key] = outcome(skip=True, reason='Source directory unavailable or no source files were read.')
311
+ continue
312
+ if key in {'intent-handler-parity', 'companion-app-required'} and not c['main']:
313
+ result[key] = outcome(skip=True, reason='Main Info.plist unavailable for manifest comparison.')
314
+ continue
315
+ try:
316
+ result[key] = check(c)
317
+ except (OSError, UnicodeError, ValueError) as exc:
318
+ result[key] = outcome(skip=True, reason='Input could not be completely read: ' + str(exc)[:500])
319
+ for key, row in result.items():
320
+ if key.startswith('_'):
321
+ continue
322
+ if row['file']:
323
+ try:
324
+ row['file'] = str(pathlib.Path(row['file']).relative_to(root))
325
+ except ValueError:
326
+ pass
327
+ return result
328
+
329
+
330
+ def main():
331
+ parser = argparse.ArgumentParser()
332
+ parser.add_argument('--root', type=pathlib.Path, required=True)
333
+ parser.add_argument('--metadata', type=pathlib.Path, required=True)
334
+ parser.add_argument('--plist', type=pathlib.Path, required=True)
335
+ parser.add_argument('--exclude-dir', action='append', default=[])
336
+ args = parser.parse_args()
337
+ print(json.dumps(evaluate(args.root.resolve(), args.metadata.resolve(), args.plist.resolve(), args.exclude_dir)))
338
+
339
+
340
+ if __name__ == '__main__':
341
+ main()
@@ -0,0 +1,39 @@
1
+ """Bound the optional source reader and preserve reasons when it cannot run."""
2
+ import argparse
3
+ import json
4
+ from pathlib import Path
5
+ import subprocess
6
+ import sys
7
+
8
+
9
+ def read(arguments, timeout=60):
10
+ command = [sys.executable, '-B', str(Path(__file__).with_name('static-guidelines.py'))] + arguments
11
+ try:
12
+ result = subprocess.run(command, capture_output=True, text=True, timeout=timeout)
13
+ if result.stderr:
14
+ print(result.stderr, file=sys.stderr, end='')
15
+ if result.returncode:
16
+ return {'_reader_error': 'reader failed (exit %d); see stderr' % result.returncode}
17
+ value = json.loads(result.stdout)
18
+ if not isinstance(value, dict):
19
+ raise ValueError('reader result is not an object')
20
+ return value
21
+ except subprocess.TimeoutExpired:
22
+ reason = 'reader timeout after %g seconds' % timeout
23
+ except (OSError, ValueError) as exc:
24
+ reason = 'reader failed: ' + type(exc).__name__
25
+ print(reason, file=sys.stderr)
26
+ return {'_reader_error': reason}
27
+
28
+
29
+ def main():
30
+ parser = argparse.ArgumentParser()
31
+ parser.add_argument('--timeout', type=float, default=60)
32
+ args, arguments = parser.parse_known_args()
33
+ if not 0 < args.timeout <= 60:
34
+ parser.error('timeout must be positive and at most 60 seconds')
35
+ print(json.dumps(read(arguments, args.timeout)))
36
+
37
+
38
+ if __name__ == '__main__':
39
+ main()
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env bash
2
+ HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
3
+ command -v python3 >/dev/null 2>&1 || { echo 'SKIP: metadata-review — Python 3 required'; exit 3; }
4
+ exec python3 -B "$HERE/lib/metadata-review.py" "$@"