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,160 @@
1
+ """Coordinate explicitly requested tiers; default scan never invokes this runner."""
2
+ import argparse
3
+ import importlib.util
4
+ import json
5
+ import os
6
+ from pathlib import Path
7
+ import re
8
+ import stat
9
+ import subprocess
10
+ import sys
11
+ import tempfile
12
+
13
+ HERE = Path(__file__).resolve().parent
14
+ OWN_OUTPUTS = ('summary.json', 'run-results.json', 'artifact-review.json', 'metadata-review.json')
15
+
16
+
17
+ def module(name):
18
+ spec = importlib.util.spec_from_file_location(name.replace('-', '_'), HERE / 'lib' / (name + '.py'))
19
+ value = importlib.util.module_from_spec(spec); spec.loader.exec_module(value)
20
+ return value
21
+
22
+
23
+ PROCESS, SAFE, RECORDS = module('dyn-process'), module('safe_write'), module('optional-records')
24
+ merge_status = RECORDS.merge_status
25
+
26
+
27
+ def remove_stale_outputs(out):
28
+ paths = [out / name for name in OWN_OUTPUTS]
29
+ if not (out / 'runtime').is_symlink():
30
+ paths.append(out / 'runtime/screen-inventory.json')
31
+ if not (out / 'runtime/explore').is_symlink():
32
+ paths.append(out / 'runtime/explore/screen-inventory.json')
33
+ for path in paths:
34
+ try:
35
+ mode = path.lstat().st_mode
36
+ except (FileNotFoundError, NotADirectoryError):
37
+ continue
38
+ if not stat.S_ISDIR(mode):
39
+ path.unlink()
40
+
41
+
42
+ def run(command, timeout):
43
+ try:
44
+ return PROCESS.run(command, timeout, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
45
+ except (OSError, subprocess.TimeoutExpired):
46
+ return None
47
+
48
+
49
+ def arguments():
50
+ parser = argparse.ArgumentParser(description=__doc__)
51
+ parser.add_argument('--repo', type=Path, required=True)
52
+ parser.add_argument('--out-dir', type=Path)
53
+ parser.add_argument('--app', type=Path)
54
+ for name in ('build', 'metadata', 'no-runtime', 'demo-login', 'dynamic-blocking', 'dry-run', 'check-urls'):
55
+ parser.add_argument('--' + name, action='store_true')
56
+ for name in ('asc-version-id', 'asc-info-id', 'asc-app-id'):
57
+ parser.add_argument('--' + name)
58
+ args = parser.parse_args(); repo = args.repo.resolve()
59
+ if not repo.is_dir() or (args.build and args.app):
60
+ parser.error('existing --repo and at most one of --build/--app required')
61
+ if (args.dynamic_blocking or args.demo_login) and not (args.build or args.app):
62
+ parser.error('runtime flags require --app or --build')
63
+ if args.no_runtime and (args.demo_login or args.dynamic_blocking):
64
+ parser.error('--no-runtime conflicts with runtime flags')
65
+ if (args.check_urls or args.asc_app_id or args.asc_info_id or args.asc_version_id) and not args.metadata:
66
+ parser.error('metadata options require --metadata')
67
+ if args.out_dir:
68
+ out = args.out_dir.resolve()
69
+ if out == repo or repo in out.parents:
70
+ parser.error('--out-dir must be outside the user project')
71
+ out.mkdir(parents=True, exist_ok=True)
72
+ else:
73
+ out = Path(tempfile.mkdtemp(prefix='precheck-review-'))
74
+ args.repo, args.out_dir = repo, out
75
+ return args
76
+
77
+
78
+ def json_tier(command, tier, args, checks, tiers, errors):
79
+ result = run(command, 120)
80
+ if result is None or result.returncode:
81
+ tiers[tier] = 'SKIP: tool, input or deadline unavailable'; return
82
+ try:
83
+ payload = json.loads(result.stdout)
84
+ path = args.out_dir / (tier + '-review.json')
85
+ SAFE.write_text(path, json.dumps(payload, indent=2) + '\n')
86
+ errors.extend(RECORDS.import_records(checks, payload.get('checks', payload.get('results', [])), str(path)))
87
+ tiers[tier] = 'RAN'
88
+ except (ValueError, TypeError, AttributeError):
89
+ tiers[tier] = 'SKIP: unreadable tier results'
90
+
91
+
92
+ def build_tier(args, tiers):
93
+ app = args.app.resolve() if args.app else None
94
+ if args.build:
95
+ command = ['bash', str(HERE / 'build-run.sh'), '--repo', str(args.repo), '--out', str(args.out_dir / 'artifact')]
96
+ if args.dry_run:
97
+ command.append('--dry-run')
98
+ result = run(command, 2700)
99
+ tiers['build'] = ('PLAN' if args.dry_run else 'RAN') if result and result.returncode == 0 else 'SKIP: build unavailable'
100
+ if result and result.returncode == 0 and not args.dry_run:
101
+ for line in result.stdout.splitlines():
102
+ if line.startswith('app_path='):
103
+ app = Path(line.split('=', 1)[1])
104
+ return app
105
+
106
+
107
+ def runtime_tier(args, app, checks, tiers):
108
+ if not app or args.no_runtime or args.dry_run:
109
+ return []
110
+ command = ['bash', str(HERE / 'runtime-review.sh'), '--app', str(app), '--repo', str(args.repo), '--out', str(args.out_dir / 'runtime')]
111
+ if args.demo_login:
112
+ command.append('--demo-login')
113
+ result = run(command, 1380)
114
+ if not result or result.returncode:
115
+ tiers['runtime'] = 'SKIP: simulator driver or deadline unavailable'; return []
116
+ tiers['runtime'] = 'RAN'
117
+ for line in result.stdout.splitlines():
118
+ match = re.match(r'^DYNAMIC-(PASS|FINDING|SKIP): \S+ \[([^]]+)\] — (.*)$', line)
119
+ if match:
120
+ status, check_id, detail = match.groups()
121
+ if status == 'FINDING' and not re.search(r'quorum 3/3(?:\D|$)', detail):
122
+ status = 'SKIP'
123
+ RECORDS.merge_result(checks, check_id.split(':')[0], status, detail, 'runtime/transcript.txt#' + check_id)
124
+ # Only the structured allowlisted blocking validator can authorize escalation.
125
+ validator = module('runtime-blocking')
126
+ return validator.blocking(args.out_dir / 'runtime') if args.dynamic_blocking else []
127
+
128
+
129
+ def main():
130
+ args = arguments(); remove_stale_outputs(args.out_dir)
131
+ checks, errors = {}, []
132
+ tiers = dict.fromkeys(('build', 'artifact', 'runtime', 'metadata'), 'NOT_RUN')
133
+ app = build_tier(args, tiers)
134
+ if app and not args.dry_run:
135
+ json_tier(['bash', str(HERE / 'artifact-review.sh'), '--app', str(app), '--format', 'json'], 'artifact', args, checks, tiers, errors)
136
+ blocking = runtime_tier(args, app, checks, tiers)
137
+ if args.metadata:
138
+ command = ['bash', str(HERE / 'metadata-review.sh'), '--repo', str(args.repo)]
139
+ for name in ('asc_app_id', 'asc_info_id', 'asc_version_id'):
140
+ if getattr(args, name):
141
+ command += ['--' + name.replace('_', '-'), getattr(args, name)]
142
+ if args.check_urls:
143
+ command.append('--check-urls')
144
+ json_tier(command, 'metadata', args, checks, tiers, errors)
145
+ result_path = args.out_dir / 'run-results.json'
146
+ SAFE.write_text(result_path, json.dumps({'checks': checks}, indent=2) + '\n')
147
+ summary = {'schema_version': 1, 'tiers': tiers, 'blocking': blocking, 'input_errors': errors,
148
+ 'run_results': str(result_path), 'output_dir': str(args.out_dir)}
149
+ SAFE.write_text(args.out_dir / 'summary.json', json.dumps(summary, indent=2) + '\n')
150
+ print(json.dumps(summary)); return 0
151
+
152
+
153
+ if __name__ == '__main__':
154
+ try:
155
+ raise SystemExit(main())
156
+ except InterruptedError:
157
+ raise SystemExit(143)
158
+ except OSError as exc:
159
+ print('opt-in-review: cannot write reports safely: ' + str(exc), file=sys.stderr)
160
+ raise SystemExit(2)
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env bash
2
+ # Explicit runtime tier. The caller supplies an existing simulator app; no builds.
3
+ set -eu
4
+ HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
+ exec bash "$HERE/dynamic-run.sh" "$@"
@@ -15,6 +15,8 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
15
15
 
16
16
  FORMAT="text"
17
17
  SCAN_DIR=""
18
+ OPT_NO_RUNTIME=0 OPT_DEMO=0 OPT_ASC_VERSION="" OPT_ASC_INFO=""
19
+ OPT_BUILD=0 OPT_APP="" OPT_METADATA=0 OPT_ASC="" OPT_URLS=0 OPT_DYN_BLOCK=0 OPT_DRY=0 OPT_OUT="" OPT_TEMP="" OPT_RAN_OK=0
18
20
  while [[ $# -gt 0 ]]; do
19
21
  case "$1" in
20
22
  --format)
@@ -25,6 +27,26 @@ while [[ $# -gt 0 ]]; do
25
27
  if [[ $# -lt 2 ]]; then echo "scan.sh: --dir needs a path" >&2; exit 64; fi
26
28
  SCAN_DIR="$2"; shift 2 ;;
27
29
  --dir=*) SCAN_DIR="${1#*=}"; shift ;;
30
+ --build) OPT_BUILD=1; shift ;;
31
+ --app)
32
+ if [[ $# -lt 2 ]]; then echo "scan.sh: --app needs a path" >&2; exit 64; fi
33
+ OPT_APP="$2"; shift 2 ;;
34
+ --metadata) OPT_METADATA=1; shift ;;
35
+ --no-runtime) OPT_NO_RUNTIME=1; shift ;;
36
+ --demo-login) OPT_DEMO=1; shift ;;
37
+ --asc-version-id|--asc-info-id)
38
+ if [[ $# -lt 2 ]]; then echo "scan.sh: $1 needs an ID" >&2; exit 64; fi
39
+ if [[ "$1" == --asc-version-id ]]; then OPT_ASC_VERSION="$2"; else OPT_ASC_INFO="$2"; fi
40
+ shift 2 ;;
41
+ --asc-app-id)
42
+ if [[ $# -lt 2 ]]; then echo "scan.sh: --asc-app-id needs an ID" >&2; exit 64; fi
43
+ OPT_ASC="$2"; OPT_METADATA=1; shift 2 ;;
44
+ --check-urls) OPT_URLS=1; OPT_METADATA=1; shift ;;
45
+ --dynamic-blocking) OPT_DYN_BLOCK=1; shift ;;
46
+ --dry-run) OPT_DRY=1; shift ;;
47
+ --out)
48
+ if [[ $# -lt 2 ]]; then echo "scan.sh: --out needs a path" >&2; exit 64; fi
49
+ OPT_OUT="$2"; shift 2 ;;
28
50
  *) shift ;;
29
51
  esac
30
52
  done
@@ -46,8 +68,12 @@ source "$SCRIPT_DIR/project-model.sh"
46
68
  source "$SCRIPT_DIR/image-dims.sh"
47
69
  source "$SCRIPT_DIR/sarif.sh"
48
70
  source "$SCRIPT_DIR/framework-detect.sh"
71
+ # shellcheck source=skills/appstore-precheck/scripts/lib/coverage-run.sh
72
+ source "$SCRIPT_DIR/lib/coverage-run.sh"
49
73
  FINDINGS_TMP="$(mktemp)"; export FINDINGS_TMP
50
- trap 'rm -f "$FINDINGS_TMP"' EXIT
74
+ # shellcheck source=skills/appstore-precheck/scripts/lib/optin-scan.sh
75
+ source "$SCRIPT_DIR/lib/optin-scan.sh"
76
+ trap optin_cleanup EXIT
51
77
  # The envelope `version` is the appstore-precheck TOOL's own version (from this
52
78
  # skill's SKILL.md), never the scanned repo's — $ROOT above is the SCANNED app's
53
79
  # git root, so reading its package.json here would leak the wrong version.
@@ -74,6 +100,9 @@ cfg_bool() { # cfg_bool <json-path> — echoes "true"/"false"
74
100
  echo "false"
75
101
  }
76
102
 
103
+ optin_trust
104
+ optin_validate || exit $?
105
+
77
106
  _LAST_SUPPRESSED=0
78
107
 
79
108
  # _tag — print the evidence/confidence line under the finding just emitted, at the
@@ -254,7 +283,7 @@ echo "PASS: layout — ios='${IOS_DIR:-?}' metadata='${META_DIR:-?}' xcstrings='
254
283
  # The store listing is a real rejection surface. Without a fastlane metadata dir the
255
284
  # listing checks simply never run, and reporting only the ones that DID run would let
256
285
  # a repo look clean on ground nobody examined. Name the cost, derived from the
257
- # evidence catalogue so the number cannot rot as rules are added.
286
+ # evidence catalogue. New modular gaps are reported in coverage_sections instead.
258
287
  if [[ -z "$META_DIR" || ! -d "$META_DIR" ]]; then
259
288
  # A gap record, not a check (see evidence.sh is_gap_record): the id exists so the
260
289
  # gap can be acknowledged by name in .precheck-ignore. Acknowledging it removes the
@@ -274,11 +303,11 @@ fi
274
303
  # rule under-detects there rather than false-firing — and a clean-looking result
275
304
  # would rest on ground nobody read. Detection is file presence only
276
305
  # (framework-detect.sh); the count is derived from the evidence catalogue, like the
277
- # store-listing gap above, so it cannot rot as rules are added.
306
+ # original §1–§55 store-listing gap above; modular checks report separate gaps.
278
307
  FRAMEWORK="$(detect_framework .)"
279
308
  if [[ "$FRAMEWORK" != native ]]; then
280
309
  set_rule "framework-not-audited"
281
- _src_list="$(rules_with_evidence source)"
310
+ _src_list="$(rules_with_evidence source 55)"
282
311
  _src_rules="$(printf '%s\n' "$_src_list" | grep -c .)"
283
312
  skip "framework — ${_src_rules} code-level checks under-detect on ${FRAMEWORK} (source greps read Swift/ObjC only): the metadata, manifest, resource and build-setting checks apply in full, but a ${FRAMEWORK} app's logic lives outside the files those checks read, so a clean result from them is partial. Review the listed guidelines against the ${FRAMEWORK} code by hand, or run the Phase 6 dynamic tier on a built simulator app."
284
313
  detail "$(printf '%s\n' "$_src_list" | tr '\n' ' ' | sed 's/ $//')"
@@ -431,7 +460,7 @@ check_len() {
431
460
  len=$(wc -m < "$file" | tr -d ' ')
432
461
  fi
433
462
  [[ -z "$len" ]] && return
434
- (( len > limit )) && fail "2.3.1 $label — $file ${len} chars (limit ${limit})" "$file"
463
+ (( len > limit )) && fail "2.3.7 $label — $file ${len} chars (limit ${limit})" "$file"
435
464
  }
436
465
  for loc in "${LOCALES[@]+"${LOCALES[@]}"}"; do
437
466
  d="$META_DIR/$loc"; [[ -d "$d" ]] || continue
@@ -443,7 +472,7 @@ for loc in "${LOCALES[@]+"${LOCALES[@]}"}"; do
443
472
  done
444
473
 
445
474
  # ===================================================================
446
- # §6 — 2.3.7 Localized metadata parity across all detected locales
475
+ # §6 — 2.3 Localized metadata parity across all detected locales
447
476
  # ===================================================================
448
477
  set_rule "locale-metadata-parity"
449
478
  if (( ${#LOCALES[@]} > 0 )); then
@@ -456,9 +485,9 @@ if (( ${#LOCALES[@]} > 0 )); then
456
485
  # submitted. Warn (don't block) so an approved set isn't falsely RED.
457
486
  # Auto-detected locales always exist, so this only fires in config mode.
458
487
  if [[ -n "$LOCALES_FROM_CONFIG" ]]; then
459
- warn "2.3.7 Locale '$loc' is in .appstore-precheck.json but has no metadata folder ($d) — add it or remove '$loc' from the config 'locales' list"
488
+ warn "2.3 Locale '$loc' is in .appstore-precheck.json but has no metadata folder ($d) — add it or remove '$loc' from the config 'locales' list"
460
489
  else
461
- fail "2.3.7 Locale missing — $d does not exist"
490
+ fail "2.3 Locale missing — $d does not exist"
462
491
  fi
463
492
  continue
464
493
  fi
@@ -467,18 +496,18 @@ if (( ${#LOCALES[@]} > 0 )); then
467
496
  case "$f" in
468
497
  name.txt|description.txt)
469
498
  # App Store Connect will not accept a localization without these.
470
- fail "2.3.7 Metadata missing — $d/$f is empty or absent" ;;
499
+ fail "2.3 Metadata missing — $d/$f is empty or absent" ;;
471
500
  *)
472
501
  # Subtitle and keywords are OPTIONAL in App Store Connect (verified
473
502
  # 2026-09-01). An empty one is a discovery/parity gap, not a blocker —
474
503
  # reporting it as a validator FAIL was an overstatement.
475
504
  set_confidence "judgment-call"
476
- warn "2.3.7 Metadata gap — $d/$f is empty or absent (optional in App Store Connect, but every other locale should not be the only place it exists)"
505
+ warn "2.3 Metadata gap — $d/$f is empty or absent (optional in App Store Connect, but every other locale should not be the only place it exists)"
477
506
  set_confidence "" ;;
478
507
  esac
479
508
  done
480
509
  done
481
- pass "2.3.7 Localized metadata — checked ${#LOCALES[@]} locales"
510
+ pass "2.3 Localized metadata — checked ${#LOCALES[@]} locales"
482
511
  fi
483
512
 
484
513
  # ===================================================================
@@ -684,14 +713,14 @@ else
684
713
  fi
685
714
 
686
715
  # ===================================================================
687
- # §13 — 5.1.5 Screen Time / sensitive-API justification (optional, opt-in)
716
+ # §13 — review-preparation Screen Time / sensitive-API justification (optional, opt-in)
688
717
  # ===================================================================
689
718
  set_rule "screentime-justification"
690
719
  if [[ "$CHECK_FAMILY" == "true" ]] && grep -q "NSFamilyControlsUsageDescription" "$INFO_PLIST" 2>/dev/null; then
691
720
  if [[ -n "$REVIEW_PREP" && -f "$REVIEW_PREP" ]] && grep -qiE 'family|screen[[:space:]]?time' "$REVIEW_PREP" 2>/dev/null; then
692
- pass "5.1.5 Screen Time API — reviewer-prep justification note present"
721
+ pass "review-preparation Screen Time API — reviewer-prep justification note present"
693
722
  else
694
- warn "5.1.5 Screen Time API in use — add a justification in your ASC App Review notes (point .reviewPrepNotes at the file). Otherwise 5.1.1 rejection risk is high."
723
+ warn "review-preparation Screen Time API in use — add a justification in your ASC App Review notes (point .reviewPrepNotes at the file). This is preparation advice; it is not a Location Services requirement."
695
724
  fi
696
725
  fi
697
726
 
@@ -718,7 +747,7 @@ ext_purchase=""
718
747
  grep -rqE 'ExternalPurchase|ExternalPurchaseLink|ExternalPurchaseCustomLink' "${IOS_DIR:-.}" "${GREP_PRUNE[@]}" "${SRC_INC[@]}" 2>/dev/null && ext_purchase=1
719
748
  grep -rqE 'external-purchase' "${IOS_DIR:-.}" "${GREP_PRUNE[@]}" --include='*.entitlements' 2>/dev/null && ext_purchase=1
720
749
  if [[ -n "$ext_purchase" ]]; then
721
- warn "3.1.1(a) External purchase link detected — ensure the External Purchase entitlement, eligible storefronts, the required disclosure sheet, and App Store Connect reporting are in place (3.1.1(a))."
750
+ warn "3.1.1(a) External purchase link detected — review the offering, storefront, distribution and applicable agreement before checking entitlement, disclosure and reporting duties. United States storefront links do not require these entitlements under 3.1.1(a); SDK presence alone is not a violation."
722
751
  fi
723
752
 
724
753
  # ===================================================================
@@ -835,7 +864,7 @@ set_rule "thirdparty-payment-sdk"
835
864
  if [[ -n "$IOS_DIR" ]]; then
836
865
  payment_sdk=$(grep -rlE 'import Stripe|StripePaymentSheet|StripeApplePay|import Braintree|BTPaymentFlow|import PayPal|PayPalCheckout|PayPalNativeCheckout|import Square|SquareInAppPayments|import Adyen|AdyenComponents|RazorpaySDK|import Paddle' "$IOS_DIR" "${GREP_PRUNE[@]}" "${SRC_INC[@]}" 2>/dev/null | head -1)
837
866
  if [[ -n "$payment_sdk" ]]; then
838
- warn "3.1.1 Third-party payment SDK — '$(basename "$payment_sdk")' detected; selling digital content/functionality must use in-app purchase, not an external processor (3.1.1). Allowed only for physical goods/services — verify your offering."
867
+ warn "3.1.1 Third-party payment SDK — '$(basename "$payment_sdk")' detected; verify the actual digital/physical offering, storefront, distribution and 3.1.1/3.1.3 exception before deciding which payment methods are allowed. SDK presence alone establishes no violation."
839
868
  fi
840
869
  fi
841
870
 
@@ -1053,18 +1082,18 @@ if [[ -f "$INFO_PLIST" && -n "$IOS_DIR" ]]; then
1053
1082
  fi
1054
1083
 
1055
1084
  # ===================================================================
1056
- # §34 — 3.1.5(a) Cryptocurrency wallet / exchange / mining
1085
+ # §34 — 3.1.5 Cryptocurrency wallet / exchange / mining
1057
1086
  # ===================================================================
1058
1087
  set_rule "crypto-wallet-mining"
1059
1088
  if [[ -n "$IOS_DIR" ]]; then
1060
1089
  crypto_sdk=$(grep -rlE 'import Web3|web3swift|Web3Swift|WalletConnect|TrustWalletCore|CoinbaseWalletSDK|SolanaSwift|CryptoMining|coinhive|MoneroMiner' "$IOS_DIR" "${GREP_PRUNE[@]}" "${SRC_INC[@]}" 2>/dev/null | head -1)
1061
1090
  if [[ -n "$crypto_sdk" ]]; then
1062
- warn "3.1.5(a) Cryptocurrency — a crypto wallet/exchange/mining signal was detected (e.g. $(basename "$crypto_sdk")); wallets & exchanges have entity and licensing requirements, and on-device mining is not permitted (3.1.5(a)). Verify eligibility."
1091
+ warn "3.1.5 Cryptocurrency — a crypto wallet/exchange/mining signal was detected (e.g. $(basename "$crypto_sdk")); wallets & exchanges have entity and licensing requirements, and on-device mining is not permitted (3.1.5). Verify eligibility."
1063
1092
  fi
1064
1093
  fi
1065
1094
 
1066
1095
  # ===================================================================
1067
- # §35 — 4.2.3 Web-wrapper / thin app
1096
+ # §35 — 4.2 Web-wrapper / thin app
1068
1097
  # ===================================================================
1069
1098
  # A thin WKWebView wrapper around a website is rejected under minimum
1070
1099
  # functionality. Heuristic: WKWebView present in a project with very few Swift
@@ -1074,7 +1103,7 @@ if [[ -n "$IOS_DIR" ]]; then
1074
1103
  if grep -rqE 'WKWebView' "$IOS_DIR" "${GREP_PRUNE[@]}" "${SRC_INC[@]}" 2>/dev/null; then
1075
1104
  swift_n=$(find "$IOS_DIR" "${PRUNE[@]}" -name '*.swift' 2>/dev/null | wc -l | tr -d ' ')
1076
1105
  if (( swift_n > 0 && swift_n <= 4 )); then
1077
- warn "4.2.3 Minimum functionality — the app appears to be a WKWebView wrapper with only $swift_n Swift file(s); a thin wrapper around a website is rejected under 4.2.3. Add native value, or verify this is a real app rather than a repackaged site."
1106
+ warn "4.2 Minimum functionality — the app appears to be a WKWebView wrapper with only $swift_n Swift file(s); a thin wrapper around a website is reviewed under 4.2. Add native value, or verify this is a real app rather than a repackaged site."
1078
1107
  fi
1079
1108
  fi
1080
1109
  fi
@@ -1310,10 +1339,10 @@ if [[ -d "$META_DIR" ]]; then
1310
1339
  price_hits="$(printf '%s' "$price_hits" | grep -v '^$' | head -10)"
1311
1340
  if [[ -n "$price_hits" ]]; then
1312
1341
  price_first="$(printf '%s\n' "$price_hits" | head -1)"
1313
- warn "2.3.1 Pricing language in app name/subtitle — price or promo wording (\"Free\", \"% off\", a currency amount) in the name or subtitle is a common metadata rejection (2.3.1/2.3.7); prices belong in the price field, not the title:" "${price_first%%:*}"
1342
+ warn "2.3.7 Pricing language in app name/subtitle — price or promo wording (\"Free\", \"% off\", a currency amount) in the name or subtitle is a common metadata rejection (2.3.7); prices belong in the price field, not the title:" "${price_first%%:*}"
1314
1343
  detail "$price_hits"
1315
1344
  else
1316
- pass "2.3.1 App name/subtitle — no pricing/promo language detected"
1345
+ pass "2.3.7 App name/subtitle — no pricing/promo language detected"
1317
1346
  fi
1318
1347
  fi
1319
1348
 
@@ -1632,9 +1661,13 @@ if [[ -n "$IOS_DIR" ]]; then
1632
1661
  fi
1633
1662
  fi
1634
1663
 
1664
+ # shellcheck source=skills/appstore-precheck/scripts/lib/scan-guidelines.sh
1665
+ source "$SCRIPT_DIR/lib/scan-guidelines.sh"
1666
+
1667
+ optin_run || exit $?
1635
1668
  echo "---END-OF-SCAN---"
1636
1669
  if [[ "$FORMAT" == text && "${_SUPPRESSED_COUNT:-0}" -gt 0 ]]; then
1637
1670
  printf '(%s finding(s) suppressed via .precheck-ignore)\n' "$_SUPPRESSED_COUNT"
1638
1671
  fi
1639
- if [[ "$FORMAT" == json ]]; then exec 1>&4 4>&-; render_json;
1672
+ if [[ "$FORMAT" == json ]]; then exec 1>&4 4>&-; render_json | coverage_run_json | optin_render_json;
1640
1673
  elif [[ "$FORMAT" == sarif ]]; then exec 1>&4 4>&-; render_sarif; fi
@@ -63,7 +63,7 @@ class NoRedirect(urllib.request.HTTPRedirectHandler):
63
63
  return None # Never forward the bearer credential to another endpoint.
64
64
 
65
65
 
66
- def evaluate(request, timeout=15, retries=2, opener=None, sleep=time.sleep):
66
+ def evaluate(request, timeout=15, retries=2, opener=None, sleep=time.sleep, telemetry=None):
67
67
  key = os.environ.get('TYPESAFE_API_KEY')
68
68
  if not key:
69
69
  raise ServiceError('TYPESAFE_API_KEY is not set')
@@ -71,6 +71,8 @@ def evaluate(request, timeout=15, retries=2, opener=None, sleep=time.sleep):
71
71
  req = urllib.request.Request(ENDPOINT, data=json.dumps(request, ensure_ascii=False).encode(),
72
72
  headers={'Authorization': 'Bearer ' + key, 'Content-Type': 'application/json'})
73
73
  for attempt in range(retries + 1):
74
+ if telemetry is not None:
75
+ telemetry['attempts'] = attempt + 1
74
76
  try:
75
77
  with opener(req, timeout=timeout) as response:
76
78
  raw = response.read(2_000_001)
@@ -4,13 +4,16 @@ import os
4
4
  import plistlib
5
5
  import re
6
6
  from pathlib import Path
7
+ from .review_v4 import evidence_gaps
7
8
 
8
9
  REFERENCES = Path(__file__).resolve().parents[2] / 'references'
9
10
  SKIP = {'.git', '.codex', '.agents', '.claude', 'node_modules', 'Pods', 'Carthage',
10
- 'build', 'DerivedData', '.build', 'eval', 'tests', 'Tests', '.typesafe-cache'}
11
- SUFFIXES = {'.swift', '.m', '.mm', '.h', '.plist', '.entitlements', '.xcprivacy', '.xcstrings'}
11
+ 'build', 'DerivedData', '.build', 'eval', 'tests', 'Tests', '.typesafe-cache',
12
+ 'review_information', 'trade_representative_contact_information'}
13
+ SUFFIXES = {'.swift', '.m', '.mm', '.h', '.plist', '.entitlements', '.xcprivacy', '.xcstrings', '.strings'}
12
14
  METADATA = {'name.txt', 'subtitle.txt', 'description.txt', 'keywords.txt', 'release_notes.txt',
13
15
  'promotional_text.txt', 'privacy_url.txt', 'support_url.txt', 'notes.txt'}
16
+ SDK_FILES = {'Package.resolved', 'Podfile.lock', 'Cartfile.resolved'}
14
17
 
15
18
 
16
19
  def redact(text):
@@ -24,10 +27,42 @@ def redact(text):
24
27
  r'\1[REDACTED]\2', text)
25
28
 
26
29
 
27
- def collect(repo):
28
- repo = Path(repo).resolve()
29
- if not repo.is_dir():
30
- raise ValueError('repository path is not a directory')
30
+ def input_kinds(path, text):
31
+ if path.suffix == '.xcprivacy':
32
+ return ['privacy-manifest']
33
+ if path.name in SDK_FILES:
34
+ return ['SDK']
35
+ if path.name in METADATA:
36
+ return ['metadata'] + (['name'] if path.name == 'name.txt' else [])
37
+ if path.suffix in ('.strings', '.xcstrings'):
38
+ return ['source-strings']
39
+ if path.suffix in ('.plist', '.entitlements'):
40
+ return ['manifest']
41
+ # Source code alone is not classified as observed UI or paywall copy.
42
+ return ['source']
43
+
44
+
45
+ def read_evidence(path, rel, identifier, plists, catalogs):
46
+ raw = path.read_bytes()
47
+ if path.suffix in ('.plist', '.entitlements', '.xcprivacy'):
48
+ parsed = plistlib.loads(raw)
49
+ if path.suffix == '.plist' and isinstance(parsed, dict):
50
+ plists.append((rel, parsed))
51
+ text = raw.decode('utf-8') if not raw.startswith(b'bplist') else plistlib.dumps(parsed).decode()
52
+ else:
53
+ text = raw.decode('utf-8')
54
+ if path.suffix == '.xcstrings':
55
+ catalogs.append((rel, json.loads(text)))
56
+ if not text.strip():
57
+ return None, False
58
+ kinds = input_kinds(path, text)
59
+ shown = redact(text[:5_000])
60
+ return {'id': identifier, 'path': rel, 'line': 1, 'text': shown,
61
+ 'kind': kinds[0], 'evidence_inputs': kinds,
62
+ 'representation': 'decoded plist' if raw.startswith(b'bplist') else 'source'}, len(text) > 5_000
63
+
64
+
65
+ def gather(repo):
31
66
  evidence, missing, plists, catalogs = [], [], [], []
32
67
  total = 0
33
68
  for directory, dirs, files in os.walk(repo, followlinks=False):
@@ -35,39 +70,26 @@ def collect(repo):
35
70
  and not Path(directory, d).is_symlink())
36
71
  for name in sorted(files):
37
72
  path = Path(directory, name)
38
- if path.is_symlink() or path.suffix not in SUFFIXES and name not in METADATA:
39
- continue
40
- if path.stat().st_size > 64_000 or len(evidence) >= 48 or total >= 70_000:
41
- missing.append('collection limit: ' + path.relative_to(repo).as_posix())
73
+ if path.is_symlink() or path.suffix not in SUFFIXES and name not in METADATA | SDK_FILES:
42
74
  continue
43
75
  rel = path.relative_to(repo).as_posix()
44
76
  try:
45
- raw = path.read_bytes()
46
- if path.suffix in ('.plist', '.entitlements', '.xcprivacy'):
47
- parsed = plistlib.loads(raw)
48
- if path.suffix == '.plist' and isinstance(parsed, dict):
49
- plists.append((rel, parsed))
50
- text = raw.decode('utf-8') if not raw.startswith(b'bplist') else plistlib.dumps(parsed).decode()
51
- else:
52
- text = raw.decode('utf-8')
53
- if path.suffix == '.xcstrings':
54
- catalogs.append((rel, json.loads(text)))
77
+ if path.stat().st_size > 64_000 or len(evidence) >= 48 or total >= 70_000:
78
+ missing.append('collection limit: ' + rel)
79
+ continue
80
+ item, truncated = read_evidence(path, rel, 'e%d' % len(evidence), plists, catalogs)
55
81
  except (OSError, ValueError, UnicodeError, plistlib.InvalidFileException):
56
82
  missing.append('unreadable: ' + rel)
57
83
  continue
58
- # Skip empty files; no claims can cite them as evidence spans.
59
- if not text.strip():
60
- continue
61
- if len(text) > 5_000:
84
+ if item:
85
+ evidence.append(item)
86
+ total += len(item['text'])
87
+ if truncated:
62
88
  missing.append('truncated: ' + rel)
63
- shown = redact(text[:5_000])
64
- evidence.append({'id': 'e%d' % len(evidence), 'path': rel, 'line': 1, 'text': shown,
65
- 'kind': 'manifest' if path.suffix in ('.plist', '.entitlements', '.xcprivacy') else
66
- ('metadata' if name in METADATA else 'source'),
67
- 'representation': 'decoded plist' if raw.startswith(b'bplist') else 'source'})
68
- total += len(shown)
69
- catalog = json.loads((REFERENCES / 'review-catalog.json').read_text())
70
- prose = (REFERENCES / 'pierre-deep-review.md').read_text()
89
+ return evidence, missing, plists, catalogs
90
+
91
+
92
+ def review_jobs(catalog, prose, evidence, missing):
71
93
  jobs = []
72
94
  for check in catalog['checks']:
73
95
  gaps = list(missing)
@@ -78,11 +100,18 @@ def collect(repo):
78
100
  if check['key'] in ('privacy-consistency', 'tracking-consistency', 'developer-identity'):
79
101
  gaps.append('live privacy/support contents must be supplied by the host')
80
102
  procedure = re.search(r'^### %d — .*?(?=^### |^---$)' % check['number'], prose, re.M | re.S)
81
- jobs.append({'id': check['key'], 'workflow': 'review', 'check_key': check['key'],
82
- 'context': {'check_definition': {**check, 'procedure': procedure[0] if procedure else check['question']},
83
- 'scope': 'repository source review only; not proof of a shipping binary'},
84
- 'coverage': {'complete': not gaps, 'missing': gaps[:64]}, 'evidence': evidence})
85
- # Purpose quality is bounded to the actual string, separately from broad project review.
103
+ job = {'id': check['key'], 'workflow': 'review', 'check_key': check['key'],
104
+ 'catalog_version': catalog['version'], 'review_catalog_version': catalog['version'],
105
+ 'context': {'check_definition': {**check, 'procedure': procedure[0] if procedure else check['question']},
106
+ 'scope': 'repository source review only; not proof of a shipping binary'},
107
+ 'coverage': {'complete': not gaps, 'missing': gaps[:64]}, 'evidence': evidence}
108
+ gaps.extend(evidence_gaps(job))
109
+ job['coverage'] = {'complete': not gaps, 'missing': sorted(set(gaps))[:64]}
110
+ jobs.append(job)
111
+ return jobs
112
+
113
+
114
+ def add_purpose_jobs(jobs, plists):
86
115
  for rel, parsed in plists:
87
116
  for key, value in sorted(parsed.items()):
88
117
  if re.fullmatch(r'NS[A-Za-z]+UsageDescription', key) and isinstance(value, str) and value.strip():
@@ -92,7 +121,9 @@ def collect(repo):
92
121
  'coverage': {'complete': False, 'missing': ['feature implementation not verified']},
93
122
  'evidence': [{'id': 'purpose', 'path': rel, 'line': 1, 'text': key + ': ' + redact(value),
94
123
  'representation': 'parsed plist value; line 1 identifies file, not value location'}]})
95
- # Source-language values are candidates regardless of regex matches. Batch size stays bounded.
124
+
125
+
126
+ def add_copy_jobs(jobs, catalogs):
96
127
  for rel, catalog_data in catalogs:
97
128
  if not isinstance(catalog_data, dict):
98
129
  continue
@@ -114,8 +145,21 @@ def collect(repo):
114
145
  'coverage': {'complete': False, 'missing': ['UI role and handler require host inspection']},
115
146
  'evidence': [{'id': 'copy', 'path': rel, 'line': 1, 'text': key + ': ' + redact(value),
116
147
  'representation': 'parsed String Catalog value'}]})
148
+
149
+
150
+ def collect(repo):
151
+ repo = Path(repo).resolve()
152
+ if not repo.is_dir():
153
+ raise ValueError('repository path is not a directory')
154
+ evidence, missing, plists, catalogs = gather(repo)
155
+ catalog = json.loads((REFERENCES / 'review-catalog.json').read_text())
156
+ prose = (REFERENCES / 'pierre-deep-review.md').read_text()
157
+ jobs = review_jobs(catalog, prose, evidence, missing)
158
+ add_purpose_jobs(jobs, plists)
159
+ add_copy_jobs(jobs, catalogs)
117
160
  return {'version': 1, 'catalog_version': catalog['version'], 'jobs': jobs[:128],
118
161
  'collection_notes': ['Bounded source collection. Inspect before sending. Redaction is best-effort.',
119
162
  'Line 1 on parsed plist/String Catalog values identifies the file, not an exact value line.',
120
163
  'Complete means coverage of the stated source scope, never runtime verification.',
164
+ 'New v4 checks require typed evidence and explicit applicability context; source alone is insufficient.',
121
165
  'Enrich missing context and coverage through the host; no credentials are required.']}