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.
- package/CHANGELOG.md +56 -0
- package/README.md +81 -39
- package/package.json +2 -2
- package/skills/appstore-precheck/SKILL.md +41 -146
- package/skills/appstore-precheck/guidelines-baseline.json +284 -35
- package/skills/appstore-precheck/guidelines-fingerprints.json +307 -93
- package/skills/appstore-precheck/references/finding-commentary.md +93 -0
- package/skills/appstore-precheck/references/methodology.md +56 -19
- package/skills/appstore-precheck/references/optional-review.md +56 -0
- package/skills/appstore-precheck/references/pierre-deep-review.md +292 -47
- package/skills/appstore-precheck/references/review-catalog.json +500 -13
- package/skills/appstore-precheck/references/screenshot-vision-review.md +8 -8
- package/skills/appstore-precheck/references/simulator-dynamic-review.md +73 -12
- package/skills/appstore-precheck/references/typesafe.md +15 -0
- package/skills/appstore-precheck/scripts/artifact-review.sh +10 -0
- package/skills/appstore-precheck/scripts/augment-json.py +29 -0
- package/skills/appstore-precheck/scripts/build-run.sh +5 -0
- package/skills/appstore-precheck/scripts/coverage-sections.sh +6 -0
- package/skills/appstore-precheck/scripts/dynamic-run.sh +94 -9
- package/skills/appstore-precheck/scripts/dynamic.sh +25 -1
- package/skills/appstore-precheck/scripts/evidence.sh +8 -3
- package/skills/appstore-precheck/scripts/findings.sh +8 -0
- package/skills/appstore-precheck/scripts/lib/artifact-review.py +518 -0
- package/skills/appstore-precheck/scripts/lib/asc-client.py +293 -0
- package/skills/appstore-precheck/scripts/lib/build-evidence.py +50 -0
- package/skills/appstore-precheck/scripts/lib/build-exec.py +50 -0
- package/skills/appstore-precheck/scripts/lib/build-plan.py +106 -0
- package/skills/appstore-precheck/scripts/lib/build-plan.sh +15 -0
- package/skills/appstore-precheck/scripts/lib/build-run.py +177 -0
- package/skills/appstore-precheck/scripts/lib/coverage-run.sh +23 -0
- package/skills/appstore-precheck/scripts/lib/coverage-sections.py +250 -0
- package/skills/appstore-precheck/scripts/lib/dyn-demo-login.py +111 -0
- package/skills/appstore-precheck/scripts/lib/dyn-device.sh +32 -4
- package/skills/appstore-precheck/scripts/lib/dyn-explore.py +316 -0
- package/skills/appstore-precheck/scripts/lib/dyn-guideline-capture.py +301 -0
- package/skills/appstore-precheck/scripts/lib/dyn-guidelines.py +112 -0
- package/skills/appstore-precheck/scripts/lib/dyn-guidelines.sh +23 -0
- package/skills/appstore-precheck/scripts/lib/dyn-process.py +75 -0
- package/skills/appstore-precheck/scripts/lib/dyn-quorum.sh +28 -30
- package/skills/appstore-precheck/scripts/lib/dyn-scrub.py +77 -0
- package/skills/appstore-precheck/scripts/lib/dyn-signals.sh +2 -2
- package/skills/appstore-precheck/scripts/lib/metadata-review.py +369 -0
- package/skills/appstore-precheck/scripts/lib/optin-scan.sh +79 -0
- package/skills/appstore-precheck/scripts/lib/optional-records.py +60 -0
- package/skills/appstore-precheck/scripts/lib/runtime-blocking.py +26 -0
- package/skills/appstore-precheck/scripts/lib/safe_write.py +70 -0
- package/skills/appstore-precheck/scripts/lib/scan-guidelines.sh +109 -0
- package/skills/appstore-precheck/scripts/lib/static-guidelines.py +370 -0
- package/skills/appstore-precheck/scripts/lib/static-reader.py +39 -0
- package/skills/appstore-precheck/scripts/metadata-review.sh +4 -0
- package/skills/appstore-precheck/scripts/opt-in-review.py +160 -0
- package/skills/appstore-precheck/scripts/runtime-review.sh +5 -0
- package/skills/appstore-precheck/scripts/scan.sh +58 -24
- package/skills/appstore-precheck/scripts/semantic/client.py +3 -1
- package/skills/appstore-precheck/scripts/semantic/collect.py +82 -38
- package/skills/appstore-precheck/scripts/semantic/engine.py +165 -127
- package/skills/appstore-precheck/scripts/semantic/questions.py +5 -1
- 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)
|
|
@@ -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
|
-
|
|
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
|
|
@@ -117,7 +146,8 @@ PRUNE=( -not -path '*/.git/*' -not -path '*/Pods/*' -not -path '*/Carthage/*'
|
|
|
117
146
|
|
|
118
147
|
# Same prune set expressed as grep --exclude-dir globs, for repo-wide grep -r passes
|
|
119
148
|
# (the find-style PRUNE above is not valid grep syntax).
|
|
120
|
-
|
|
149
|
+
# -D skip: never block on FIFOs/sockets/devices that happen to match a source glob.
|
|
150
|
+
GREP_PRUNE=( -D skip --exclude-dir=.git --exclude-dir=Pods --exclude-dir=Carthage
|
|
121
151
|
--exclude-dir=.build --exclude-dir=build --exclude-dir=DerivedData
|
|
122
152
|
--exclude-dir=SourcePackages --exclude-dir=checkouts --exclude-dir=.swiftpm
|
|
123
153
|
--exclude-dir=.claude --exclude-dir=worktrees
|
|
@@ -254,7 +284,7 @@ echo "PASS: layout — ios='${IOS_DIR:-?}' metadata='${META_DIR:-?}' xcstrings='
|
|
|
254
284
|
# The store listing is a real rejection surface. Without a fastlane metadata dir the
|
|
255
285
|
# listing checks simply never run, and reporting only the ones that DID run would let
|
|
256
286
|
# a repo look clean on ground nobody examined. Name the cost, derived from the
|
|
257
|
-
# evidence catalogue
|
|
287
|
+
# evidence catalogue. New modular gaps are reported in coverage_sections instead.
|
|
258
288
|
if [[ -z "$META_DIR" || ! -d "$META_DIR" ]]; then
|
|
259
289
|
# A gap record, not a check (see evidence.sh is_gap_record): the id exists so the
|
|
260
290
|
# gap can be acknowledged by name in .precheck-ignore. Acknowledging it removes the
|
|
@@ -274,11 +304,11 @@ fi
|
|
|
274
304
|
# rule under-detects there rather than false-firing — and a clean-looking result
|
|
275
305
|
# would rest on ground nobody read. Detection is file presence only
|
|
276
306
|
# (framework-detect.sh); the count is derived from the evidence catalogue, like the
|
|
277
|
-
# store-listing gap above
|
|
307
|
+
# original §1–§55 store-listing gap above; modular checks report separate gaps.
|
|
278
308
|
FRAMEWORK="$(detect_framework .)"
|
|
279
309
|
if [[ "$FRAMEWORK" != native ]]; then
|
|
280
310
|
set_rule "framework-not-audited"
|
|
281
|
-
_src_list="$(rules_with_evidence source)"
|
|
311
|
+
_src_list="$(rules_with_evidence source 55)"
|
|
282
312
|
_src_rules="$(printf '%s\n' "$_src_list" | grep -c .)"
|
|
283
313
|
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
314
|
detail "$(printf '%s\n' "$_src_list" | tr '\n' ' ' | sed 's/ $//')"
|
|
@@ -431,7 +461,7 @@ check_len() {
|
|
|
431
461
|
len=$(wc -m < "$file" | tr -d ' ')
|
|
432
462
|
fi
|
|
433
463
|
[[ -z "$len" ]] && return
|
|
434
|
-
(( len > limit )) && fail "2.3.
|
|
464
|
+
(( len > limit )) && fail "2.3.7 $label — $file ${len} chars (limit ${limit})" "$file"
|
|
435
465
|
}
|
|
436
466
|
for loc in "${LOCALES[@]+"${LOCALES[@]}"}"; do
|
|
437
467
|
d="$META_DIR/$loc"; [[ -d "$d" ]] || continue
|
|
@@ -443,7 +473,7 @@ for loc in "${LOCALES[@]+"${LOCALES[@]}"}"; do
|
|
|
443
473
|
done
|
|
444
474
|
|
|
445
475
|
# ===================================================================
|
|
446
|
-
# §6 — 2.3
|
|
476
|
+
# §6 — 2.3 Localized metadata parity across all detected locales
|
|
447
477
|
# ===================================================================
|
|
448
478
|
set_rule "locale-metadata-parity"
|
|
449
479
|
if (( ${#LOCALES[@]} > 0 )); then
|
|
@@ -456,9 +486,9 @@ if (( ${#LOCALES[@]} > 0 )); then
|
|
|
456
486
|
# submitted. Warn (don't block) so an approved set isn't falsely RED.
|
|
457
487
|
# Auto-detected locales always exist, so this only fires in config mode.
|
|
458
488
|
if [[ -n "$LOCALES_FROM_CONFIG" ]]; then
|
|
459
|
-
warn "2.3
|
|
489
|
+
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
490
|
else
|
|
461
|
-
fail "2.3
|
|
491
|
+
fail "2.3 Locale missing — $d does not exist"
|
|
462
492
|
fi
|
|
463
493
|
continue
|
|
464
494
|
fi
|
|
@@ -467,18 +497,18 @@ if (( ${#LOCALES[@]} > 0 )); then
|
|
|
467
497
|
case "$f" in
|
|
468
498
|
name.txt|description.txt)
|
|
469
499
|
# App Store Connect will not accept a localization without these.
|
|
470
|
-
fail "2.3
|
|
500
|
+
fail "2.3 Metadata missing — $d/$f is empty or absent" ;;
|
|
471
501
|
*)
|
|
472
502
|
# Subtitle and keywords are OPTIONAL in App Store Connect (verified
|
|
473
503
|
# 2026-09-01). An empty one is a discovery/parity gap, not a blocker —
|
|
474
504
|
# reporting it as a validator FAIL was an overstatement.
|
|
475
505
|
set_confidence "judgment-call"
|
|
476
|
-
warn "2.3
|
|
506
|
+
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
507
|
set_confidence "" ;;
|
|
478
508
|
esac
|
|
479
509
|
done
|
|
480
510
|
done
|
|
481
|
-
pass "2.3
|
|
511
|
+
pass "2.3 Localized metadata — checked ${#LOCALES[@]} locales"
|
|
482
512
|
fi
|
|
483
513
|
|
|
484
514
|
# ===================================================================
|
|
@@ -684,14 +714,14 @@ else
|
|
|
684
714
|
fi
|
|
685
715
|
|
|
686
716
|
# ===================================================================
|
|
687
|
-
# §13 —
|
|
717
|
+
# §13 — review-preparation Screen Time / sensitive-API justification (optional, opt-in)
|
|
688
718
|
# ===================================================================
|
|
689
719
|
set_rule "screentime-justification"
|
|
690
720
|
if [[ "$CHECK_FAMILY" == "true" ]] && grep -q "NSFamilyControlsUsageDescription" "$INFO_PLIST" 2>/dev/null; then
|
|
691
721
|
if [[ -n "$REVIEW_PREP" && -f "$REVIEW_PREP" ]] && grep -qiE 'family|screen[[:space:]]?time' "$REVIEW_PREP" 2>/dev/null; then
|
|
692
|
-
pass "
|
|
722
|
+
pass "review-preparation Screen Time API — reviewer-prep justification note present"
|
|
693
723
|
else
|
|
694
|
-
warn "
|
|
724
|
+
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
725
|
fi
|
|
696
726
|
fi
|
|
697
727
|
|
|
@@ -718,7 +748,7 @@ ext_purchase=""
|
|
|
718
748
|
grep -rqE 'ExternalPurchase|ExternalPurchaseLink|ExternalPurchaseCustomLink' "${IOS_DIR:-.}" "${GREP_PRUNE[@]}" "${SRC_INC[@]}" 2>/dev/null && ext_purchase=1
|
|
719
749
|
grep -rqE 'external-purchase' "${IOS_DIR:-.}" "${GREP_PRUNE[@]}" --include='*.entitlements' 2>/dev/null && ext_purchase=1
|
|
720
750
|
if [[ -n "$ext_purchase" ]]; then
|
|
721
|
-
warn "3.1.1(a) External purchase link detected —
|
|
751
|
+
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
752
|
fi
|
|
723
753
|
|
|
724
754
|
# ===================================================================
|
|
@@ -835,7 +865,7 @@ set_rule "thirdparty-payment-sdk"
|
|
|
835
865
|
if [[ -n "$IOS_DIR" ]]; then
|
|
836
866
|
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
867
|
if [[ -n "$payment_sdk" ]]; then
|
|
838
|
-
warn "3.1.1 Third-party payment SDK — '$(basename "$payment_sdk")' detected;
|
|
868
|
+
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
869
|
fi
|
|
840
870
|
fi
|
|
841
871
|
|
|
@@ -1053,18 +1083,18 @@ if [[ -f "$INFO_PLIST" && -n "$IOS_DIR" ]]; then
|
|
|
1053
1083
|
fi
|
|
1054
1084
|
|
|
1055
1085
|
# ===================================================================
|
|
1056
|
-
# §34 — 3.1.5
|
|
1086
|
+
# §34 — 3.1.5 Cryptocurrency wallet / exchange / mining
|
|
1057
1087
|
# ===================================================================
|
|
1058
1088
|
set_rule "crypto-wallet-mining"
|
|
1059
1089
|
if [[ -n "$IOS_DIR" ]]; then
|
|
1060
1090
|
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
1091
|
if [[ -n "$crypto_sdk" ]]; then
|
|
1062
|
-
warn "3.1.5
|
|
1092
|
+
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
1093
|
fi
|
|
1064
1094
|
fi
|
|
1065
1095
|
|
|
1066
1096
|
# ===================================================================
|
|
1067
|
-
# §35 — 4.2
|
|
1097
|
+
# §35 — 4.2 Web-wrapper / thin app
|
|
1068
1098
|
# ===================================================================
|
|
1069
1099
|
# A thin WKWebView wrapper around a website is rejected under minimum
|
|
1070
1100
|
# functionality. Heuristic: WKWebView present in a project with very few Swift
|
|
@@ -1074,7 +1104,7 @@ if [[ -n "$IOS_DIR" ]]; then
|
|
|
1074
1104
|
if grep -rqE 'WKWebView' "$IOS_DIR" "${GREP_PRUNE[@]}" "${SRC_INC[@]}" 2>/dev/null; then
|
|
1075
1105
|
swift_n=$(find "$IOS_DIR" "${PRUNE[@]}" -name '*.swift' 2>/dev/null | wc -l | tr -d ' ')
|
|
1076
1106
|
if (( swift_n > 0 && swift_n <= 4 )); then
|
|
1077
|
-
warn "4.2
|
|
1107
|
+
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
1108
|
fi
|
|
1079
1109
|
fi
|
|
1080
1110
|
fi
|
|
@@ -1310,10 +1340,10 @@ if [[ -d "$META_DIR" ]]; then
|
|
|
1310
1340
|
price_hits="$(printf '%s' "$price_hits" | grep -v '^$' | head -10)"
|
|
1311
1341
|
if [[ -n "$price_hits" ]]; then
|
|
1312
1342
|
price_first="$(printf '%s\n' "$price_hits" | head -1)"
|
|
1313
|
-
warn "2.3.
|
|
1343
|
+
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
1344
|
detail "$price_hits"
|
|
1315
1345
|
else
|
|
1316
|
-
pass "2.3.
|
|
1346
|
+
pass "2.3.7 App name/subtitle — no pricing/promo language detected"
|
|
1317
1347
|
fi
|
|
1318
1348
|
fi
|
|
1319
1349
|
|
|
@@ -1632,9 +1662,13 @@ if [[ -n "$IOS_DIR" ]]; then
|
|
|
1632
1662
|
fi
|
|
1633
1663
|
fi
|
|
1634
1664
|
|
|
1665
|
+
# shellcheck source=skills/appstore-precheck/scripts/lib/scan-guidelines.sh
|
|
1666
|
+
source "$SCRIPT_DIR/lib/scan-guidelines.sh"
|
|
1667
|
+
|
|
1668
|
+
optin_run || exit $?
|
|
1635
1669
|
echo "---END-OF-SCAN---"
|
|
1636
1670
|
if [[ "$FORMAT" == text && "${_SUPPRESSED_COUNT:-0}" -gt 0 ]]; then
|
|
1637
1671
|
printf '(%s finding(s) suppressed via .precheck-ignore)\n' "$_SUPPRESSED_COUNT"
|
|
1638
1672
|
fi
|
|
1639
|
-
if [[ "$FORMAT" == json ]]; then exec 1>&4 4>&-; render_json;
|
|
1673
|
+
if [[ "$FORMAT" == json ]]; then exec 1>&4 4>&-; render_json | coverage_run_json | optin_render_json;
|
|
1640
1674
|
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
|
-
|
|
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
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if
|
|
84
|
+
if item:
|
|
85
|
+
evidence.append(item)
|
|
86
|
+
total += len(item['text'])
|
|
87
|
+
if truncated:
|
|
62
88
|
missing.append('truncated: ' + rel)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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
|
-
|
|
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.']}
|