appstore-precheck 1.19.0 → 1.20.1

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 +56 -0
  2. package/README.md +81 -39
  3. package/package.json +2 -2
  4. package/skills/appstore-precheck/SKILL.md +41 -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 +73 -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 +250 -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 +316 -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 +77 -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 +79 -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 +70 -0
  47. package/skills/appstore-precheck/scripts/lib/scan-guidelines.sh +109 -0
  48. package/skills/appstore-precheck/scripts/lib/static-guidelines.py +370 -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 +58 -24
  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,109 @@
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_TOTAL=0 STATIC_GAP_SLUGS="" STATIC_GAP_REASON="" STATIC_EMOJI_STATUS=SKIP
6
+ STATIC_GUIDELINES_JSON='{}'
7
+ # The reader understands only --exclude-dir=... entries; grep-only flags such as `-D skip` stay out.
8
+ STATIC_READER_EXCLUDES=()
9
+ for _prune in "${GREP_PRUNE[@]+"${GREP_PRUNE[@]}"}"; do
10
+ case "$_prune" in --exclude-dir=*) STATIC_READER_EXCLUDES+=("$_prune") ;; esac
11
+ done
12
+ if command -v python3 >/dev/null 2>&1 && command -v jq >/dev/null 2>&1; then
13
+ STATIC_GUIDELINES_JSON="$(python3 -B "$SCRIPT_DIR/lib/static-reader.py" \
14
+ --root "$ROOT" --metadata "${META_DIR:-/nonexistent}" --plist "${INFO_PLIST:-/nonexistent}" \
15
+ "${STATIC_READER_EXCLUDES[@]+"${STATIC_READER_EXCLUDES[@]}"}" )" || STATIC_GUIDELINES_JSON='{"_reader_error":"reader invocation failed; see stderr"}'
16
+ fi
17
+
18
+ static_guideline_select() {
19
+ local row
20
+ STATIC_STATUS=SKIP STATIC_REASON="Python 3 or jq unavailable, or source reader failed." STATIC_FILE=""
21
+ if command -v jq >/dev/null 2>&1; then
22
+ STATIC_REASON="$(printf '%s' "$STATIC_GUIDELINES_JSON" | jq -r '._reader_error // "Python 3 or jq unavailable, or source reader failed."')"
23
+ row="$(printf '%s' "$STATIC_GUIDELINES_JSON" | jq -cer --arg id "$1" '.[$id] // empty' 2>/dev/null)" || return 0
24
+ STATIC_STATUS="$(printf '%s' "$row" | jq -r '.status')"
25
+ STATIC_REASON="$(printf '%s' "$row" | jq -jr '.reason' | tr '\n\r\t' ' ')"
26
+ STATIC_FILE="$(printf '%s' "$row" | jq -jr '.file' | tr '\n\r\t' ' ')"
27
+ fi
28
+ }
29
+
30
+ static_guideline_gap() {
31
+ local id="$1" guideline="$2" reason="$3"
32
+ STATIC_GAP_TOTAL=$((STATIC_GAP_TOTAL + 1))
33
+ case "$id" in
34
+ *-not-audited) ;;
35
+ *) STATIC_GAP_COUNT=$((STATIC_GAP_COUNT + 1))
36
+ STATIC_GAP_SLUGS="${STATIC_GAP_SLUGS}${STATIC_GAP_SLUGS:+, }$id" ;;
37
+ esac
38
+ STATIC_GAP_REASON="$reason"
39
+ if command -v jq >/dev/null 2>&1; then
40
+ COVERAGE_GAPS_JSON="$(printf '%s' "$COVERAGE_GAPS_JSON" | jq -c \
41
+ --arg id "$id" --arg guideline "$guideline" --arg reason "$reason" \
42
+ '. + [{rule_id:$id,guideline:$guideline,status:"SKIP",reason:$reason}]')"
43
+ else
44
+ # These two values come only from the literal call sites below, never input files.
45
+ COVERAGE_GAPS_JSON="${COVERAGE_GAPS_JSON%]}"
46
+ [[ "$COVERAGE_GAPS_JSON" == '[' ]] || COVERAGE_GAPS_JSON+=','
47
+ COVERAGE_GAPS_JSON+="{\"rule_id\":\"$id\",\"guideline\":\"$guideline\",\"status\":\"SKIP\",\"reason\":\"Optional Python 3/jq reader unavailable.\"}]"
48
+ fi
49
+ }
50
+
51
+ # §56–§71: slug | guideline | evidence class. Keep coverage-sections.py in sync.
52
+ while IFS='|' read -r _static_slug _static_guideline _static_evidence; do
53
+ set_rule "$_static_slug"
54
+ set_evidence "$_static_evidence"
55
+ static_guideline_select "$_static_slug"
56
+ case "$STATIC_STATUS" in
57
+ WARN) warn "$_static_guideline $_static_slug — $STATIC_REASON" "$STATIC_FILE" ;;
58
+ PASS) pass "$_static_guideline $_static_slug — $STATIC_REASON" ;;
59
+ *) static_guideline_gap "$_static_slug" "$_static_guideline" "$STATIC_REASON" ;;
60
+ esac
61
+ if [[ "$_static_slug" == metadata-emoji ]]; then STATIC_EMOJI_STATUS="$STATIC_STATUS"; fi
62
+ done <<'STATIC_GUIDELINE_TABLE'
63
+ release-notes-specificity|2.3.12|metadata
64
+ device-restart-instructions|2.4.4|source
65
+ browser-engine|2.5.6|source
66
+ intent-handler-parity|2.5.11|source
67
+ call-filter-controls|2.5.12|source
68
+ face-authentication|2.5.13|source
69
+ document-browser-access|2.5.15|source
70
+ extension-bundle-parity|2.5.16|source
71
+ matter-extension|2.5.17|source
72
+ extension-advertising|2.5.18|source
73
+ ar-integration-depth|4.2.1|source
74
+ companion-app-required|4.2.3|source
75
+ game-center-id-sharing|4.5.5|source
76
+ metadata-emoji|4.5.6|resource
77
+ miniapp-native-bridge|4.7.2|source
78
+ apple-endorsement-claims|5.2.4|metadata
79
+ STATIC_GUIDELINE_TABLE
80
+
81
+ if [[ "$STATIC_EMOJI_STATUS" != SKIP ]]; then
82
+ static_guideline_gap "metadata-emoji-icon-not-audited" "4.5.6" "Apple emoji artwork in icon pixels requires visual review."
83
+ fi
84
+ STATIC_GAP_FALLBACK_SLUGS="$STATIC_GAP_SLUGS" STATIC_GAP_REASON_FALLBACK="$STATIC_GAP_REASON"
85
+ if command -v jq >/dev/null 2>&1; then
86
+ _input_gap="$(printf '%s' "$STATIC_GUIDELINES_JSON" | jq -r '._input_gaps // empty | "\(.count) files skipped: \(.paths | join(", "))"')"
87
+ if [[ -n "$_input_gap" ]]; then static_guideline_gap "source-inputs-not-audited" "source" "$_input_gap"; fi
88
+ STATIC_GAP_SLUGS="$(printf '%s' "$COVERAGE_GAPS_JSON" | jq -jr '
89
+ def grouped: group_by(.reason) | map((map(.rule_id) | join(", ")) + " (" + .[0].reason + ")") | join("; ");
90
+ [.[] | select(.rule_id | endswith("-not-audited") | not)] | grouped' | tr '\n\r\t' ' ')"
91
+ STATIC_GAP_REASON="$(printf '%s' "$COVERAGE_GAPS_JSON" | jq -jr '
92
+ [.[] | select(.rule_id | endswith("-not-audited"))] |
93
+ map(.rule_id + " (" + .reason + ")") | join("; ")' | tr '\n\r\t' ' ')"
94
+ if [[ -z "$STATIC_GAP_SLUGS" && -n "$STATIC_GAP_FALLBACK_SLUGS" ]]; then
95
+ # jq is present but failed: fall back to the bash accumulator so the list is never empty.
96
+ STATIC_GAP_SLUGS="$STATIC_GAP_FALLBACK_SLUGS ($STATIC_GAP_REASON_FALLBACK)"
97
+ fi
98
+ STATIC_GAP_SLUGS="${STATIC_GAP_SLUGS}${STATIC_GAP_REASON:+; additional coverage gaps: $STATIC_GAP_REASON}"
99
+ else
100
+ STATIC_GAP_SLUGS="$STATIC_GAP_SLUGS ($STATIC_GAP_REASON)"
101
+ fi
102
+ if [[ "$STATIC_GAP_TOTAL" -gt 0 ]]; then
103
+ set_rule "modular-checks-not-audited"
104
+ if [[ "$STATIC_GAP_COUNT" -eq 0 ]]; then
105
+ skip "modular-checks-not-audited — additional coverage gaps: $STATIC_GAP_REASON"
106
+ else
107
+ skip "modular-checks-not-audited — $STATIC_GAP_COUNT check(s) did not run: $STATIC_GAP_SLUGS"
108
+ fi
109
+ fi
@@ -0,0 +1,370 @@
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
+ import stat
11
+ from xml.parsers.expat import ExpatError
12
+
13
+ PRUNE = {'.git', 'Pods', 'Carthage', '.build', 'build', 'DerivedData',
14
+ 'SourcePackages', 'checkouts', '.swiftpm', '.claude', 'worktrees',
15
+ 'node_modules', 'vendor', '.planning', '.symlinks', '*.app', '*.xcarchive', '*.dSYM', '*.xcframework'}
16
+ SOURCE = {'.swift', '.m', '.mm', '.h', '.js', '.jsx', '.ts', '.tsx'}
17
+ RESOURCE = {'.strings', '.xcstrings'}
18
+ ADS = (r'GoogleMobileAds|GADMobileAds|AppLovinSDK|ALSdk|AppsFlyerLib|\bAdjust\b|'
19
+ r'FBAudienceNetwork|BranchSDK|IronSource|UnityAds|VungleAds|Chartboost|'
20
+ r'InMobi|IMSdk|MTGSDK|PAGAdSDK|BUAdSDK|\bSingular\b|KochavaTracker|TenjinSDK')
21
+ TOKEN = re.compile(r'"(?:\\.|[^"\\])*"|\'(?:\\.|[^\'\\])*\'|//[^\n]*|/\*.*?\*/', re.S)
22
+
23
+
24
+ def uncomment(text):
25
+ return TOKEN.sub(lambda m: '\n' * m[0].count('\n') if m[0].startswith(('/', '/*')) else m[0], text)
26
+
27
+
28
+ def checked_bytes(path):
29
+ limit = (8 if path.suffix in RESOURCE else 2) * 1024 * 1024
30
+ fd = os.open(str(path), os.O_RDONLY | os.O_NONBLOCK | os.O_NOFOLLOW)
31
+ with os.fdopen(fd, 'rb') as stream:
32
+ info = os.fstat(stream.fileno())
33
+ if not stat.S_ISREG(info.st_mode):
34
+ raise ValueError('special file skipped')
35
+ if info.st_size > limit:
36
+ raise ValueError('input exceeds read limit')
37
+ data = stream.read(limit + 1)
38
+ if len(data) > limit:
39
+ raise ValueError('input exceeds read limit')
40
+ return data
41
+
42
+
43
+ def checked_text(path):
44
+ data = checked_bytes(path)
45
+ encoding = 'utf-16' if path.suffix == '.strings' and data[:2] in (b'\xff\xfe', b'\xfe\xff') else 'utf-8'
46
+ return data.decode(encoding)
47
+
48
+
49
+ def input_error(path, exc, root=None):
50
+ path = pathlib.Path(path)
51
+ try:
52
+ name = str(path.relative_to(root)) if root else path.name
53
+ except ValueError:
54
+ name = path.name
55
+ return name + (' (special file skipped)' if isinstance(exc, ValueError) and str(exc) == 'special file skipped' else '')
56
+
57
+
58
+ def read_candidate(path):
59
+ if path.suffix in {'.plist', '.entitlements'}:
60
+ value = plistlib.loads(checked_bytes(path))
61
+ if not isinstance(value, dict):
62
+ raise ValueError('manifest root is not a dictionary')
63
+ return plistlib.dumps(value).decode('utf-8')
64
+ return checked_text(path)
65
+
66
+
67
+ def read_files(root, excludes):
68
+ result, gaps = {}, []
69
+ onerror = lambda exc: gaps.append(input_error(exc.filename, exc, root))
70
+ for folder, dirs, files in os.walk(root, followlinks=False, onerror=onerror):
71
+ keep = [d for d in dirs if not any(fnmatch.fnmatch(d, pattern) for pattern in PRUNE | set(excludes))]
72
+ for d in keep:
73
+ if (pathlib.Path(folder) / d).is_symlink():
74
+ gaps.append(input_error(pathlib.Path(folder) / d, ValueError('symlink'), root))
75
+ dirs[:] = [d for d in keep if not (pathlib.Path(folder) / d).is_symlink()]
76
+ for name in files:
77
+ path = pathlib.Path(folder) / name
78
+ if path.suffix not in SOURCE | RESOURCE | {'.plist', '.entitlements', '.pbxproj'} and name not in {'Podfile', 'Package.swift', 'Package.resolved'}:
79
+ continue
80
+ try:
81
+ result[path] = read_candidate(path)
82
+ except (OSError, UnicodeError, ValueError, plistlib.InvalidFileException, ExpatError) as exc:
83
+ gaps.append(input_error(path, exc, root))
84
+ return result, gaps
85
+
86
+
87
+ def context(root, metadata, main, excludes):
88
+ files, gaps = read_files(root, excludes)
89
+ src = {p: uncomment(t) for p, t in files.items() if p.suffix in SOURCE}
90
+ resources = {p: t for p, t in files.items() if p.suffix in RESOURCE}
91
+ plists = {p: plistlib.loads(t.encode('utf-8')) for p, t in files.items()
92
+ if p.suffix in {'.plist', '.entitlements'}}
93
+ main_data = plists.get(main, {})
94
+ if main not in plists and main.exists():
95
+ try:
96
+ main_data = plistlib.loads(read_candidate(main).encode('utf-8'))
97
+ except (OSError, UnicodeError, ValueError, plistlib.InvalidFileException, ExpatError) as exc:
98
+ gaps.append(input_error(main, exc, root))
99
+ extensions = {p: v for p, v in plists.items() if 'NSExtension' in v or 'NSAppClip' in v}
100
+ return dict(root=root, metadata=metadata, main=main_data, files=files, gaps=gaps,
101
+ src=src, resources=resources, plists=plists, extensions=extensions)
102
+
103
+
104
+ def outcome(hit=False, reason='', path=None, skip=False):
105
+ return dict(status='SKIP' if skip else 'WARN' if hit else 'PASS',
106
+ reason=reason or 'No matching risk signal in scanned inputs.',
107
+ file=str(path) if path else '')
108
+
109
+
110
+ def hit_file(files, pattern):
111
+ return next((p for p, text in files.items() if re.search(pattern, text, re.I)), None)
112
+
113
+
114
+ def metadata_files(c, names):
115
+ base = c['metadata']
116
+ if not base.is_dir() or base.is_symlink():
117
+ return []
118
+ files = [p for locale in sorted(base.iterdir()) if locale.is_dir() and not locale.is_symlink()
119
+ and locale.name not in {'default', 'review_information', 'trade_representative_contact_information'}
120
+ for name in names for p in [locale / (name + '.txt')] if p.is_file() or p.is_symlink()]
121
+ for p in files:
122
+ try:
123
+ checked_text(p)
124
+ except (OSError, UnicodeError, ValueError) as exc:
125
+ detail = str(exc) if isinstance(exc, ValueError) else type(exc).__name__
126
+ err = ValueError(input_error(p, exc, c.get('root')) + ': ' + detail)
127
+ err.filename = None
128
+ err.sanitized = True
129
+ raise err from exc
130
+ return files
131
+
132
+
133
+ def app_version(c):
134
+ version = str(c['main'].get('CFBundleShortVersionString', ''))
135
+ if re.fullmatch(r'\d+(?:\.\d+){1,2}', version):
136
+ return version
137
+ versions = {v for p, text in c['files'].items() if p.suffix == '.pbxproj'
138
+ for v in re.findall(r'\bMARKETING_VERSION\s*=\s*"?(\d+(?:\.\d+){1,2})"?\s*;', uncomment(text))}
139
+ if versions:
140
+ return next(iter(versions)) if len(versions) == 1 else ''
141
+ version_file = c['metadata'] / 'version.txt'
142
+ return checked_text(version_file).strip() if version_file.is_file() else ''
143
+
144
+
145
+ def release_notes(c):
146
+ files = metadata_files(c, ['release_notes'])
147
+ if not files:
148
+ return outcome(skip=True, reason='Release notes metadata unavailable.')
149
+ version, initial_empty = app_version(c), False
150
+ for p in files:
151
+ value = checked_text(p).strip()
152
+ desc = p.with_name('description.txt')
153
+ same = desc.is_file() and not desc.is_symlink() and value == checked_text(desc).strip()
154
+ if not value and version in ('1.0', '1.0.0'):
155
+ initial_empty = True
156
+ continue
157
+ if not value and not version:
158
+ return outcome(True, 'Empty release notes with unknown version; low-confidence update review.', p)
159
+ if not value or re.fullmatch(r'lorem(?: ipsum)?[.!]?|TODO|N[/-]A', value, re.I) or same:
160
+ return outcome(True, 'Release notes are empty, a placeholder, or repeat the description.', p)
161
+ if initial_empty:
162
+ return outcome(reason='empty release notes accepted for the initial version')
163
+ return outcome(reason='Release notes contain specific non-placeholder text.')
164
+
165
+
166
+ def restart(c):
167
+ source = {p: t for p, t in c['src'].items()
168
+ if not re.search(r'(?m)^\s*(?:@testable\s+)?import\s+(?:Testing|XCTest)\b', t)}
169
+ p = hit_file(source, r'"[^"\n]{0,512}(?:restart your device|reboot|change your settings in Settings\s*>\s*General)[^"\n]{0,512}"')
170
+ p = p or hit_file(c['resources'], r'restart your device|\breboot\b|change your settings in Settings\s*>\s*General')
171
+ return outcome(bool(p), 'Device restart/settings instruction string; inspect the user-facing context.' if p else '', p)
172
+
173
+
174
+ def browser(c):
175
+ deps = {p: uncomment(t) for p, t in c['files'].items() if p.name in {'Podfile', 'Package.swift', 'Package.resolved'} or p.suffix == '.pbxproj'}
176
+ p = next((p for p, text in deps.items()
177
+ if re.search(r"[\"'][^\"'\n]{0,512}\b(?:Chromium|CEF|Gecko|Blink)\b(?![^\"'\n]{0,512}\.(?:swift|m|mm|h|storyboard|xib)[\"'])|\b(?:Chromium|CEF|Gecko|Blink)\.framework", text)), None)
178
+ legacy = hit_file(c['src'], r'\bUIWebView\s*(?:\(|[*>])|:\s*UIWebView\b')
179
+ if legacy:
180
+ return outcome(True, 'Deprecated UIWebView reference; verify the shipping target and Xcode SDK before removal.', legacy)
181
+ return outcome(bool(p), 'Non-WebKit engine dependency signal; verify entitlement and regional eligibility.' if p else '', p)
182
+
183
+
184
+ def intents(c):
185
+ declared = any(v.get('INIntentsSupported') or
186
+ re.search(r'intent', json.dumps(v.get('NSExtension', {})), re.I) for v in c['plists'].values())
187
+ handler = hit_file(c['src'], r'\b(?:INExtension|INIntentHandlerProviding|\w+IntentHandling)\b|func\s+handler\s*\(\s*for\s+intent')
188
+ modern = hit_file(c['src'], r':\s*(?:\w+\s*,\s*)?(?:AppIntent|AppShortcutsProvider)\b')
189
+ bad = (declared and not (handler or modern)) or (handler and not declared)
190
+ 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)
191
+
192
+
193
+ def call_filter(c):
194
+ p = hit_file(c['src'], r'\b(?:ILMessageFilterExtension|CXCallDirectoryProvider|CXCallDirectoryManager)\b')
195
+ ui = hit_file(c['src'], r'"[^"\n]{0,512}(?:blocked (?:numbers|callers)|call blocking|spam filter|blocking settings)[^"\n]{0,512}"') or hit_file(c['resources'], r'blocked numbers|call blocking|spam filter')
196
+ 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)
197
+
198
+
199
+ def face_auth(c):
200
+ native = hit_file(c['src'], r'\b(?:LocalAuthentication|LAContext)\b')
201
+ for p, text in c['src'].items():
202
+ face = re.search(r'\b(?:VNFaceObservation|VNDetectFace\w*|FaceTecSDK|FacePhi)\b', text)
203
+ auth = re.search(r'login|authenticate|authentication|identity verification', text, re.I)
204
+ if face and auth and not native:
205
+ return outcome(True, 'Face recognition and authentication context coexist without LocalAuthentication; inspect authentication design.', p)
206
+ return outcome(reason='No custom face-authentication signal (or native authentication present).')
207
+
208
+
209
+ def documents(c):
210
+ picker = hit_file(c['src'], r'\bUIDocumentPicker\w*\b|\.fileImporter\s*\(|\bUIDocumentBrowserViewController\b')
211
+ if picker:
212
+ return outcome(reason='System document access is used; inspect custom browser reachability separately.')
213
+ title = hit_file(c['src'], r'(?:navigationTitle|Text|title\s*=)\s*\(?\s*"(?:My Files|Files|Documents)"')
214
+ title = title or hit_file(c['resources'], r'"(?:My Files|Files|Documents)"')
215
+ custom = next((p for p, t in c['src'].items()
216
+ if title and re.search(r'FileManager\.default\.contentsOfDirectory|\benumerator\s*\(\s*at\s*:', t)
217
+ and re.search(r'\b(?:List|Table|UICollectionView|UITableView)\b', t)), None)
218
+ 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)
219
+
220
+
221
+ def extension_parity(c):
222
+ if not c['extensions']:
223
+ return outcome(reason='No discoverable extension target.')
224
+ main_id = c['main'].get('CFBundleIdentifier', '')
225
+ if not main_id or '$(' in main_id or '${' in main_id:
226
+ return outcome(skip=True, reason='Main bundle identifier is absent or build-setting-derived; archive verification required.')
227
+ for p, value in c['extensions'].items():
228
+ bid = value.get('CFBundleIdentifier', '')
229
+ if not bid or '$(' in bid or '${' in bid:
230
+ return outcome(skip=True, reason='Extension bundle id resolved by build settings; archive verification required.', path=p)
231
+ if not bid or not bid.startswith(main_id + '.'):
232
+ return outcome(True, 'Extension bundle identifier is missing or lacks the main-app prefix; verify target configuration.', p)
233
+ return outcome(reason='Literal extension bundle identifiers share the main-app prefix.')
234
+
235
+
236
+ def matter(c):
237
+ p = hit_file(c['src'], r'\bimport\s+(?:MatterSupport|Matter)\b')
238
+ entitlement = any('com.apple.developer.matter.allow-setup-payload' in v for v in c['plists'].values())
239
+ supported = any(re.search('matter', json.dumps(v.get('NSExtension', {})), re.I) for v in c['extensions'].values())
240
+ 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)
241
+
242
+
243
+ def extension_ads(c):
244
+ if not c['extensions']:
245
+ return outcome(skip=True, reason='No discoverable extension target; not applicable.')
246
+ for plist in c['extensions']:
247
+ if plist.parent == c['root'] or plist.parent.name in {'ios', 'Sources', 'src'}:
248
+ return outcome(skip=True, reason='Extension source dir unresolved; inspect target membership.', path=plist)
249
+ files = {p: t for p, t in c['src'].items() if plist.parent in p.parents}
250
+ p = hit_file(files, r'(?:import\s+|@import\s+|#import\s*[<"])(?:' + ADS + r')\b')
251
+ if p:
252
+ return outcome(True, 'Advertising/attribution SDK imported by extension-directory source; verify extension target membership.', p)
253
+ return outcome(reason='No advertising import in discovered extension directories; resolved link phases are not audited.')
254
+
255
+
256
+ def ar_depth(c):
257
+ p = hit_file(c['src'], r'\bimport\s+ARKit\b') or hit_file(c['files'], r'ARKit\.framework')
258
+ if not p:
259
+ return outcome(reason='ARKit not used.')
260
+ sessions = [f for f, t in c['src'].items() if re.search(r'\b(?:ARSession|ARView|RealityKit)\b', t)]
261
+ 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())
262
+ bad = len(sessions) == 1 and screens < 2
263
+ 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)
264
+
265
+
266
+ def companion(c):
267
+ p = hit_file(c['src'], r'"[^"\n]{0,512}(?:download|install)[ \t]{1,60}[^"\n]{1,60}[ \t]{1,60}to (?:continue|proceed|use)[^"\n]{0,512}"') or hit_file(c['resources'], r'(?:download|install)[ \t]{1,60}[^"\n]{1,60}[ \t]{1,60}to (?:continue|proceed|use)')
268
+ bad = bool(c['main'].get('LSApplicationQueriesSchemes') and p)
269
+ 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)
270
+
271
+
272
+ def game_ids(c):
273
+ for p, text in c['src'].items():
274
+ 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):
275
+ return outcome(True, 'Game Center identifier and network/analytics code coexist in one file; trace actual data flow before concluding sharing.', p)
276
+ return outcome(reason='No co-located Game Center identifier/network signal (or GameKit not used).')
277
+
278
+
279
+ def emoji(c):
280
+ if not c['root'].is_dir():
281
+ return outcome(skip=True, reason='Asset root is unavailable.')
282
+ seen = 0
283
+ for folder, dirs, files in os.walk(c['root'], followlinks=False):
284
+ seen += len(files)
285
+ dirs[:] = [d for d in dirs if not any(fnmatch.fnmatch(d, pattern) for pattern in PRUNE)
286
+ and not (pathlib.Path(folder) / d).is_symlink()]
287
+ for name in dirs + files:
288
+ p = pathlib.Path(folder) / name
289
+ suspect = (name.lower().endswith('.imageset') and 'emoji' in name.lower())
290
+ suspect = suspect or name.lower() == 'applecoloremoji.ttc'
291
+ suspect = suspect or bool(re.search(r'(?:^|[_ -])(?:applecoloremoji|emoji)(?:[_ -]|\.)', name, re.I) and p.suffix.lower() == '.png')
292
+ if suspect:
293
+ return outcome(True, 'Possible embedded Apple emoji artwork by asset name; low-confidence visual/license review required.', p)
294
+ if seen == 0:
295
+ return outcome(skip=True, reason='No project files were read; emoji artwork assets not audited.')
296
+ return outcome(reason='Apple emoji artwork asset signal not used.')
297
+
298
+
299
+ def miniapp(c):
300
+ for p, text in c['src'].items():
301
+ terms = [r'\bWKScriptMessageHandler\b', r'https?://[^"\s]{1,2048}(?:\.js\b|/scripts?/)', r'\bevaluateJavaScript\b', r'\b(?:CLLocationManager|AVCaptureSession|CNContactStore|requestWhenInUseAuthorization)\b']
302
+ if all(re.search(term, text) for term in terms):
303
+ return outcome(True, 'Remote JavaScript, message handler, evaluation and native-sensitive API coexist; inspect mini-app bridge exposure.', p)
304
+ return outcome(reason='No combined remote-script/native-sensitive bridge signal (or webview not used).')
305
+
306
+
307
+ def endorsements(c):
308
+ files = metadata_files(c, ['name', 'subtitle', 'description', 'keywords', 'promotional_text', 'release_notes'])
309
+ if not files:
310
+ return outcome(skip=True, reason='Store metadata unavailable.')
311
+ for p in files:
312
+ 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):
313
+ return outcome(True, 'Apple endorsement/official-product marketing claim; verify authorization and accuracy.', p)
314
+ return outcome(reason='No matched Apple endorsement claim in metadata.')
315
+
316
+
317
+ CHECKS = {'release-notes-specificity': release_notes, 'device-restart-instructions': restart,
318
+ 'browser-engine': browser, 'intent-handler-parity': intents,
319
+ 'call-filter-controls': call_filter, 'face-authentication': face_auth,
320
+ 'document-browser-access': documents, 'extension-bundle-parity': extension_parity,
321
+ 'matter-extension': matter, 'extension-advertising': extension_ads,
322
+ 'ar-integration-depth': ar_depth, 'companion-app-required': companion,
323
+ 'game-center-id-sharing': game_ids, 'metadata-emoji': emoji,
324
+ 'miniapp-native-bridge': miniapp, 'apple-endorsement-claims': endorsements}
325
+
326
+
327
+ def evaluate(root, metadata, main, excludes):
328
+ c = context(root, metadata, main, excludes)
329
+ result = {}
330
+ independent = {'release-notes-specificity', 'metadata-emoji', 'apple-endorsement-claims'}
331
+ if c['gaps']:
332
+ result['_input_gaps'] = {'count': len(set(c['gaps'])), 'paths': sorted(set(c['gaps']))[:3]}
333
+ for key, check in CHECKS.items():
334
+ if key not in independent and not c['src']:
335
+ result[key] = outcome(skip=True, reason='Source directory unavailable or no source files were read.')
336
+ continue
337
+ if key in {'intent-handler-parity', 'companion-app-required'} and not c['main']:
338
+ result[key] = outcome(skip=True, reason='Main Info.plist unavailable for manifest comparison.')
339
+ continue
340
+ try:
341
+ result[key] = check(c)
342
+ except (OSError, UnicodeError, ValueError) as exc:
343
+ if getattr(exc, 'sanitized', False):
344
+ detail = str(exc)
345
+ else:
346
+ detail = input_error(getattr(exc, 'filename', None) or 'input', exc, root) + ' (' + type(exc).__name__ + ')'
347
+ result[key] = outcome(skip=True, reason='Input could not be completely read: ' + detail)
348
+ for key, row in result.items():
349
+ if key.startswith('_'):
350
+ continue
351
+ if row['file']:
352
+ try:
353
+ row['file'] = str(pathlib.Path(row['file']).relative_to(root))
354
+ except ValueError:
355
+ row['file'] = pathlib.Path(row['file']).name
356
+ return result
357
+
358
+
359
+ def main():
360
+ parser = argparse.ArgumentParser()
361
+ parser.add_argument('--root', type=pathlib.Path, required=True)
362
+ parser.add_argument('--metadata', type=pathlib.Path, required=True)
363
+ parser.add_argument('--plist', type=pathlib.Path, required=True)
364
+ parser.add_argument('--exclude-dir', action='append', default=[])
365
+ args = parser.parse_args()
366
+ print(json.dumps(evaluate(args.root.resolve(), args.metadata.resolve(), args.plist.resolve(), args.exclude_dir)))
367
+
368
+
369
+ if __name__ == '__main__':
370
+ 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" "$@"