appstore-precheck 1.20.0 → 1.20.2

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 CHANGED
@@ -5,6 +5,25 @@ All notable changes to this project are documented here. Versioning follows
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [1.20.2] — 2026-10-02
9
+
10
+ ### Fixed
11
+ - Idle CPU observations resolve the installed simulator container for each fresh repeat and verify the executable and device path before sampling; unavailable containers remain SKIP.
12
+ - Maestro gets a discarded warm-up read after setup and each reinstall (120-second default, configurable or disabled). Unread geometry and guideline hierarchy reads retry once; warm-up emits only a note.
13
+ - The local dynamic runner forwards exploration, authorized navigation, demo login, timing, iPad and packet-capture options, with portable offline argument plans.
14
+ - Builds prefer the project-named scheme, then the sole verified application target's scheme; ambiguous choices list candidates and retain discovery diagnostics. Agent configuration and worktree directories are excluded from discovery and build copies.
15
+ - First-screen checks report SKIP with a not-reached reason when no launch stayed up.
16
+
17
+ ## [1.20.1] — 2026-10-02
18
+
19
+ ### Fixed
20
+ - Static readers skip special files without blocking, bound quoted-string matching, and omit absolute paths from input-error reasons. Repository-wide `grep` passes skip FIFOs and devices (`-D skip`), so a stray named pipe no longer hangs the default scan.
21
+ - Empty release notes recognize initial versions from Info.plist or MARKETING_VERSION; document-browser warnings require file access, list UI, and a browser title together.
22
+ - Exploration artifacts refuse symlink targets. Demo credentials are redacted by value; secure-field detection is not relied on.
23
+ - Modular SKIP summaries count checks separately from supplemental gaps and group their reasons. A shared execution table remains cross-validated against section coverage.
24
+ - Explicit `--dynamic-blocking` requires jq and exits 64 when it is unavailable.
25
+ - Legacy shell assertions use shared helpers with synthetic failure probes on Bash 3.2.
26
+
8
27
  ## [1.20.0] — 2026-10-02
9
28
 
10
29
  ### Guideline section coverage 45 → 93 of 102 leaf rules (91%)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appstore-precheck",
3
- "version": "1.20.0",
3
+ "version": "1.20.2",
4
4
  "description": "Read-only iOS App Store pre-submission check, packaged as a portable Agent Skill with native Claude Code, Cursor, Codex, and Grok Build plugins, plus an npx CLI.",
5
5
  "license": "MIT",
6
6
  "author": "Berkay Turk (https://github.com/berkayturk)",
@@ -4,7 +4,7 @@ description: Read-only pre-submission check for an iOS app before App Store revi
4
4
  license: MIT
5
5
  metadata:
6
6
  author: Berkay Turk
7
- version: 1.20.0
7
+ version: 1.20.2
8
8
  allowed-tools: Bash Read Grep Glob WebFetch mcp__maestro__list_devices mcp__maestro__run mcp__maestro__inspect_screen mcp__maestro__take_screenshot mcp__maestro__cheat_sheet
9
9
  ---
10
10
 
@@ -408,6 +408,8 @@ device and never touches an existing one or the repo, but the launched app reach
408
408
  and receives the demo credentials you supplied — tell the user so before the first launch. It
409
409
  requires macOS + Xcode + a simulator runtime and is permanently local-only (it cannot run in CI).
410
410
  It is a pre-submit local smoke signal, not a TestFlight / crash-reporter / QA replacement.
411
+ The separate `scan.sh --dynamic-blocking` opt-in requires jq; without it the scanner exits 64
412
+ with `--dynamic-blocking needs jq` before optional work.
411
413
 
412
414
  **Getting a build without building.** Never run `xcodebuild` / `flutter build` / `gradle`. Run
413
415
  `bash <skill-dir>/scripts/app-discover.sh --repo <repo> --json`: it lists the simulator `.app`
@@ -69,7 +69,8 @@ reporter, or real-device QA.
69
69
  - **Determinism before findings.** The launch checks run **N=3 times**, each on a freshly erased
70
70
  device; a `DYNAMIC-FINDING` for a crash needs **3/3**. Mixed evidence is not unanimous and stays SKIP with its counts; fewer than three repeats
71
71
  or any unreadable repeat also stays SKIP. Blocking is off by default; explicit `--dynamic-blocking`
72
- uses only the documented fresh unanimous launch/login allowlist.
72
+ uses only the documented fresh unanimous launch/login allowlist. `scan.sh --dynamic-blocking`
73
+ requires jq; if unavailable it exits 64 with `--dynamic-blocking needs jq` before optional work.
73
74
  - **One flow per Maestro invocation.** The iOS 26 driver misbehaves in batch mode (Maestro issues
74
75
  #3254 / #3318): every `mcp__maestro__run` call carries exactly one flow; the runner reads the
75
76
  hierarchy with one `maestro hierarchy` call at a time.
@@ -170,7 +171,13 @@ hand with `xcrun simctl` when it drives the selector-based checks.
170
171
  is optional and off by default.)
171
172
  7. Between repeats: `xcrun simctl shutdown <udid>`, `xcrun simctl erase <udid>`, boot, step 2,
172
173
  install again — a fresh erase every time, only on the device this run created.
173
- 8. Teardown, always, at the end of the run: `xcrun simctl shutdown <udid>` then
174
+ 8. Warm the Maestro driver once after D0 and after each erase + boot + install, including
175
+ iPad setup and demo repeats: a discarded `maestro --device <udid> hierarchy` read,
176
+ bounded by `DYN_MAESTRO_WARMUP_TIMEOUT` (default 120 seconds; `0` disables it).
177
+ The transcript records `# NOTE: [dyn-maestro-warmup]`; this is never PASS/FINDING
178
+ evidence. Dry-run lists the warm-up without invoking Maestro. When driving MCP
179
+ checks by hand, do this after installation before the first `inspect_screen`.
180
+ 9. Teardown, always, at the end of the run: `xcrun simctl shutdown <udid>` then
174
181
  `xcrun simctl delete <udid>` — only for the device this tier created.
175
182
 
176
183
  ### D1 — Launch without crash (`dyn-launch`)
@@ -199,7 +206,9 @@ observations are SKIP with their counts. Signals that could not be read are name
199
206
 
200
207
  ### D2 — Core screen reachable (`dyn-first-screen`)
201
208
  Derived from the same repeats: a non-uniform screenshot with the process alive at the end of the
202
- window is a real first screen; a flat frame or a dead process is not. Same quorum. The
209
+ window is a real first screen; a flat frame or a dead process is not. Same quorum.
210
+ If no launch stayed up, D2 is SKIP with `not reached: app did not stay up on any launch`.
211
+ The
203
212
  degenerate-tree caveat applies: judge Flutter/Compose screens by the screenshot, not the tree.
204
213
 
205
214
  ### D3 — Paywall renders (`dyn-paywall-visible`)
@@ -264,7 +273,8 @@ resolve it (see the reconciliation table in `dynamic.sh`).
264
273
 
265
274
  After the last healthy repeat, `dynamic-run.sh` switches `xcrun simctl ui <udid> appearance dark`
266
275
  (D7), then `content_size accessibility-extra-extra-extra-large` (D8), takes a screenshot and one
267
- hierarchy read each, and applies three heuristics
276
+ hierarchy read each (one retry only when the read is `unread`, never for a readable
277
+ but degenerate tree), and applies three heuristics
268
278
  ([`lib/dyn-geometry.sh`](../scripts/lib/dyn-geometry.sh)) over the labelled nodes:
269
279
 
270
280
  - **clipped** — a labelled frame that leaves the screen rectangle;
@@ -348,7 +358,11 @@ bash skills/appstore-precheck/scripts/dynamic-run.sh --app <path>.app --repo /pa
348
358
  ```
349
359
 
350
360
  `tests/local/run-dynamic.sh` chains discovery → confirmation → runner → `dynamic.sh` on macOS; it is
351
- not part of `tests/all.sh`.
361
+ not part of `tests/all.sh`. It forwards `--explore`, `--authorized-navigation FILE`,
362
+ `--demo-login`, `--window`, `--repeats`, `--ipad` and `--pktap` unchanged.
363
+ With explicit `--app` and `--dry-run`, it prints the runner arguments and plan without
364
+ requiring macOS/Xcode or performing discovery, scanning or reconciliation; its argument
365
+ and shim regression tests run in the offline suite.
352
366
 
353
367
  ## Feeding the transcript to dynamic.sh
354
368
 
@@ -390,13 +404,19 @@ partial, a keyless D10 line aims at nothing); `att-usage ↔ dyn-shipped-bundle:
390
404
  `lib/dyn-guidelines.sh` invokes `dyn-guideline-capture.py` once per healthy launch,
391
405
  before demo login, only on a device created and freshly erased by this runner. The
392
406
  collector has a 240-second deadline; individual commands have 10–20-second deadlines.
407
+ Unread hierarchy commands retry once; driver failures remain SKIP if the retry fails.
393
408
  `dyn-guidelines.py` requires at least three distinct fresh observations with identical
394
409
  non-SKIP results. Missing repeats, mixed results, driver errors and degenerate UI
395
410
  semantics remain SKIP. Existing `--udid` and `--dry-run` sessions cannot establish this
396
411
  freshness. `run.json` links the private `guideline_observations` artifact directory.
397
412
 
398
- The CPU check verifies the PID's executable path against the installed bundle before
399
- sleeping or sampling. Host `ps` may report averaged process CPU; this is a performance
413
+ The CPU check resolves `xcrun simctl get_app_container <udid> <bundle-id> app` on
414
+ **every fresh repeat**, then compares `ps -p <pid> -o comm=` with that container's
415
+ executable. The basename must equal `CFBundleExecutable`, and the resolved path must
416
+ stay inside `~/Library/Developer/CoreSimulator/Devices/<udid>/data/`. It never compares
417
+ the running process with the original source `.app` path. An unavailable container
418
+ produces SKIP with `container path unavailable`; identity is checked again before each
419
+ sample. Only a verified process is allowed to reach the idle wait or sampling. Host `ps` may report averaged process CPU; this is a performance
400
420
  review hint, not a battery-use measurement. Missing tools, PID mismatch or incomplete
401
421
  samples remain SKIP. It does not need an accessibility tree.
402
422
 
@@ -94,7 +94,7 @@ if [[ -n "$APP" ]]; then
94
94
  [[ -f "$APP/Info.plist" ]] || { echo "dynamic-run.sh: $APP has no Info.plist (not an installable bundle)" >&2; exit 66; }
95
95
  fi
96
96
  [[ -n "$REPO" && ! -d "$REPO" ]] && { echo "dynamic-run.sh: --repo is not a directory: $REPO" >&2; exit 66; }
97
- command -v xcrun >/dev/null 2>&1 || { echo "dynamic-run.sh: xcrun not found — this tier needs macOS with Xcode (it is permanently local-only)" >&2; exit 69; }
97
+ [[ "$DYN_DRY_RUN" == 1 ]] || command -v xcrun >/dev/null 2>&1 || { echo "dynamic-run.sh: xcrun not found — this tier needs macOS with Xcode (it is permanently local-only)" >&2; exit 69; }
98
98
  [[ -z "$FRAMEWORK" ]] && { if [[ -n "$REPO" ]]; then FRAMEWORK="$(detect_framework "$REPO")"; else FRAMEWORK=native; fi; }
99
99
  [[ -n "$OUT" ]] || OUT="$(mktemp -d "${TMPDIR:-/tmp}/precheck-dynamic.XXXXXX")"
100
100
  if [[ -n "$REPO" ]]; then
@@ -116,6 +116,10 @@ DYN_OWNED_LEDGER="$OUT/owned-simulators.txt"; : > "$DYN_OWNED_LEDGER"; export DY
116
116
  DYN_EXT_DIR="$(mktemp -d "$OUT/guideline-observations.XXXXXX")" || { echo "dynamic-run.sh: cannot create private observations directory" >&2; exit 66; }
117
117
  TRANSCRIPT="$OUT/transcript.txt"; : > "$TRANSCRIPT"
118
118
  DYN_PLAN_FILE="$OUT/plan.txt"; : > "$DYN_PLAN_FILE"; export DYN_PLAN_FILE
119
+ if [[ "$DYN_DRY_RUN" == 1 ]]; then
120
+ dyn_plan "options: --repeats $REPEATS --window $WINDOW; --explore=$EXPLORE --demo-login=$DEMO --ipad=$IPAD --pktap=$PKTAP"
121
+ [[ -z "$AUTH_NAV" ]] || dyn_plan "--authorized-navigation $(printf '%q' "$AUTH_NAV")"
122
+ fi
119
123
 
120
124
  # --- Transcript helpers -------------------------------------------------------------
121
125
  emit() { printf '%s\n' "$1" | tee -a "$TRANSCRIPT"; }
@@ -190,6 +194,7 @@ if [[ -n "$APP" ]]; then
190
194
  else
191
195
  emit "$(dyn_line PASS setup dyn-install "using user-supplied device $UDID for $BID (not created by this run: never erased, reset or deleted; repeats relaunch without a fresh erase, so they are less deterministic; build config unknown)")"
192
196
  fi
197
+ dyn_maestro_warmup "$UDID"
193
198
  INSTALLED="$(dyn_device_container "$UDID" "$BID")"
194
199
  [[ -n "$INSTALLED" && -d "$INSTALLED" ]] || INSTALLED="$APP"
195
200
 
@@ -231,6 +236,7 @@ else
231
236
  L_SKIP=$((L_SKIP+1)); S_SKIP=$((S_SKIP+1)); i=$((i+1)); continue
232
237
  fi
233
238
  dyn_device_prepare "$UDID"
239
+ dyn_maestro_warmup "$UDID"
234
240
  [[ "$DYN_DRY_RUN" == 1 ]] || FRESH_ERASES=$((FRESH_ERASES+1))
235
241
  fi
236
242
  r="$(dyn_repeat "$UDID" "$BID" "$EXE" "$WINDOW" "$OUT" "$i")"
@@ -251,6 +257,9 @@ else
251
257
  (( FRESH_ERASES == REPEATS && REPEATS >= 3 )) && FRESH_NOTE="fresh erase verified"
252
258
  emit "$(dyn_line "$LAUNCH_KIND" 2.1 dyn-launch "$(cut -f2 <<<"$q"); last repeat: $LAST_DETAIL; window ${WINDOW}s; screenshots $OUT/launch-*.png; $FRESH_NOTE")"
253
259
  q="$(dyn_quorum "$S_PASS" "$S_FIND" "$S_SKIP")"
260
+ if (( L_PASS == 0 )); then
261
+ q="$(printf 'SKIP\tnot reached: app did not stay up on any launch')"
262
+ fi
254
263
  emit "$(dyn_line "$(cut -f1 <<<"$q")" 2.1 dyn-first-screen "$(cut -f2 <<<"$q") (a non-blank screenshot with the process alive after ${WINDOW}s; a splash stuck as a flat frame counts as failed)")"
255
264
  fi
256
265
 
@@ -262,7 +271,7 @@ geometry_pass() { # geometry_pass <rule-id> <guideline> <label> <tag>
262
271
  png="$OUT/$tag.png"; hier="$OUT/$tag.json"
263
272
  [[ "$DYN_DRY_RUN" == 1 ]] || sleep 2
264
273
  dyn_signal_screenshot "$UDID" "$png" >/dev/null
265
- tree="$(dyn_signal_tree "$UDID" "$hier")"
274
+ tree="$(dyn_signal_tree_retry "$UDID" "$hier")"
266
275
  if [[ "$DYN_DRY_RUN" == 1 ]]; then emit "$(dyn_line SKIP "$g" "$id" "dry run: $label not observed")"; return 0; fi
267
276
  [[ "$tree" == unread ]] && { emit "$(dyn_line SKIP "$g" "$id" "$label: accessibility tree could not be read (Maestro missing or timed out); screenshot $png for a human eye")"; return 0; }
268
277
  emit "$(dyn_geometry_line "$(dyn_geometry_report "$hier" 0 0)" "$g" "$id" "$label" "$png")"
@@ -293,6 +302,7 @@ if (( IPAD )); then
293
302
  else
294
303
  dyn_device_boot "$CREATED_IPAD"; dyn_device_prepare "$CREATED_IPAD"
295
304
  if dyn_device_install "$CREATED_IPAD" "${APP:-}" >/dev/null 2>&1; then
305
+ dyn_maestro_warmup "$CREATED_IPAD"
296
306
  saved="$UDID"; UDID="$CREATED_IPAD"
297
307
  r="$(dyn_repeat "$UDID" "$BID" "$EXE" "$WINDOW" "$OUT" ipad)"
298
308
  if [[ "$DYN_DRY_RUN" == 1 ]]; then emit "$(dyn_line SKIP 2.4.1 dyn-ipad-layout "dry run: iPad layout not observed")"
@@ -318,6 +328,7 @@ run_demo_phase() {
318
328
  DEMO_SKIP=$((DEMO_SKIP+1)); i=$((i+1)); continue
319
329
  fi
320
330
  dyn_device_prepare "$UDID"
331
+ dyn_maestro_warmup "$UDID"
321
332
  fresh=$((fresh+1))
322
333
  r="$(dyn_repeat "$UDID" "$BID" "$EXE" "$WINDOW" "$OUT" "demo-$i")"
323
334
  kind="$(cut -f1 <<<"$r")"
@@ -6,7 +6,8 @@ import shutil
6
6
  import subprocess
7
7
 
8
8
  EXCLUDED = {'.git', 'node_modules', 'Pods', 'build', 'DerivedData', '.build', '.dart_tool',
9
- '__pycache__', '.gradle', '.kotlin', '.idea'}
9
+ '__pycache__', '.gradle', '.kotlin', '.idea', '.claude', '.cursor', '.agents',
10
+ '.grok', '.codex', '.planning'}
10
11
  SECRETS = ('.env*', '.npmrc', '.netrc', '*.pem', '*.key', '*.jks', '*.keystore',
11
12
  'key.properties', '.sentryclirc', '*Secrets*.xcconfig', '*asc-key*.json',
12
13
  '*.p8', '*.p12', '*.mobileprovision', '.appstore-precheck.json',
@@ -18,6 +18,7 @@ def module(name):
18
18
 
19
19
 
20
20
  PLAN, EXEC, EVIDENCE = module('build-plan'), module('build-exec'), module('build-evidence')
21
+ SCHEMES = module('build-schemes')
21
22
 
22
23
 
23
24
  def arguments():
@@ -32,23 +33,6 @@ def arguments():
32
33
  return parser.parse_args()
33
34
 
34
35
 
35
- def scheme_list(output):
36
- schemes = set()
37
- decoder = json.JSONDecoder()
38
- for index, char in enumerate(output):
39
- if char != '{':
40
- continue
41
- try:
42
- data, _ = decoder.raw_decode(output[index:])
43
- except ValueError:
44
- continue
45
- if isinstance(data, dict):
46
- for value in data.values():
47
- if isinstance(value, dict) and isinstance(value.get('schemes'), list):
48
- schemes.update(s for s in value['schemes'] if isinstance(s, str))
49
- return sorted(schemes)
50
-
51
-
52
36
  def prepare_framework(args, copy, step):
53
37
  if args.framework != 'rn':
54
38
  return
@@ -87,15 +71,13 @@ def run_steps(args, copy, work, out, project):
87
71
  return 'debug', list((copy / 'build/ios/iphonesimulator').glob('*.app'))
88
72
  code, output = step(['xcodebuild', '-list', '-json'] + flags)
89
73
  if code:
90
- raise ValueError('scheme discovery failed; inspect build.log')
91
- schemes = scheme_list(output)
92
- if len(schemes) != 1:
93
- raise ValueError('select one shared scheme; candidates: ' + ', '.join(schemes))
74
+ raise ValueError('scheme discovery failed; candidates: ' + ', '.join(SCHEMES.scheme_list(output)) + '; inspect build.log')
75
+ scheme = SCHEMES.select(output, project, copy, PLAN.excluded)
94
76
  for config in ('Release', 'Debug'):
95
77
  if config == 'Debug' and args.framework == 'kmp' and (copy / 'gradlew').is_file():
96
78
  if step(['./gradlew', '--project-cache-dir', str(work / 'gradle-cache'), ':shared:linkDebugFrameworkIosSimulatorArm64'])[0]:
97
79
  raise ValueError('KMP framework preparation failed; inspect build.log')
98
- command = ['xcodebuild'] + flags + ['-scheme', schemes[0], '-sdk', 'iphonesimulator', '-configuration', config,
80
+ command = ['xcodebuild'] + flags + ['-scheme', scheme, '-sdk', 'iphonesimulator', '-configuration', config,
99
81
  '-derivedDataPath', str(work / 'dd'), 'CODE_SIGNING_ALLOWED=NO', 'build']
100
82
  if step(command)[0] == 0:
101
83
  return config.lower(), list((work / 'dd/Build/Products' / (config + '-iphonesimulator')).glob('*.app'))
@@ -0,0 +1,56 @@
1
+ """Choose a shared scheme using project identity, then verified application targets."""
2
+ import json
3
+ import os
4
+ from pathlib import Path
5
+ import subprocess
6
+
7
+
8
+ def listings(output):
9
+ decoder = json.JSONDecoder()
10
+ for index, char in enumerate(output):
11
+ if char != '{':
12
+ continue
13
+ try:
14
+ data, _ = decoder.raw_decode(output[index:])
15
+ except ValueError:
16
+ continue
17
+ if isinstance(data, dict):
18
+ for key in ('project', 'workspace'):
19
+ value = data.get(key)
20
+ if isinstance(value, dict) and isinstance(value.get('schemes'), list):
21
+ yield value
22
+
23
+
24
+ def scheme_list(output):
25
+ return sorted({s for value in listings(output) for s in value['schemes'] if isinstance(s, str)})
26
+
27
+
28
+ def application_targets(copy, excluded):
29
+ targets = set()
30
+ model = Path(__file__).resolve().parents[1] / 'project-model.sh'
31
+ for base, dirs, files in os.walk(copy):
32
+ dirs[:] = [d for d in dirs if not excluded(Path(base) / d) and not (Path(base) / d).is_symlink()]
33
+ if Path(base).suffix != '.xcodeproj' or 'project.pbxproj' not in files:
34
+ continue
35
+ result = subprocess.run(['bash', '-c', 'source "$1"; pm_app_targets "$2"',
36
+ 'build-schemes', str(model), str(Path(base) / 'project.pbxproj')],
37
+ capture_output=True, text=True, timeout=10)
38
+ if result.returncode == 0:
39
+ targets.update(result.stdout.splitlines())
40
+ return targets
41
+
42
+
43
+ def select(output, project, copy, excluded):
44
+ schemes = scheme_list(output)
45
+ if len(schemes) == 1:
46
+ return schemes[0]
47
+ name = Path(project).stem
48
+ if name in schemes:
49
+ return name
50
+ listed_targets = {t for value in listings(output) for t in value.get('targets', []) if isinstance(t, str)}
51
+ targets = application_targets(copy, excluded)
52
+ if listed_targets:
53
+ targets &= listed_targets
54
+ if len(targets) == 1 and targets.issubset(schemes):
55
+ return targets.pop()
56
+ raise ValueError('select one shared application scheme; candidates: ' + (', '.join(schemes) or '(none)'))
@@ -31,6 +31,12 @@ def scan_sources(skill):
31
31
  result = {}
32
32
  for text in [entry] + [(scripts / name).read_text() for name in modules]:
33
33
  text = '\n'.join(line for line in text.splitlines() if not line.lstrip().startswith('#'))
34
+ table = re.search(r"done <<'STATIC_GUIDELINE_TABLE'\n(.*?)\nSTATIC_GUIDELINE_TABLE", text, re.S)
35
+ if table:
36
+ for slug, guideline, evidence in re.findall(
37
+ r'^([\w-]+)\|([1-5](?:\.\d+)+)\|(source|metadata|resource)$', table[1], re.M):
38
+ if slug in slugs:
39
+ add(result, guideline, '§%d' % slugs[slug])
34
40
  chunks = re.split(r'set_rule "([\w-]*)"', text)
35
41
  for index in range(1, len(chunks), 2):
36
42
  slug = chunks[index]
@@ -9,7 +9,6 @@ import collections
9
9
  import hashlib
10
10
  import importlib.util
11
11
  import json
12
- import os
13
12
  import pathlib
14
13
  import re
15
14
  import subprocess
@@ -90,6 +89,7 @@ _scrub_spec = importlib.util.spec_from_file_location('dyn_scrub', pathlib.Path(_
90
89
  _scrub = importlib.util.module_from_spec(_scrub_spec)
91
90
  _scrub_spec.loader.exec_module(_scrub)
92
91
  scrub_tree = _scrub.scrub_tree
92
+ _safe_write = _scrub.sibling('safe_write')
93
93
 
94
94
 
95
95
  def summarize(tree, name, screenshot=None, timestamp=None):
@@ -225,7 +225,7 @@ def navigate(udid, bundle_id, path, out, deadline):
225
225
  flow = private / 'navigation-flow.yaml'
226
226
  content = 'appId: ' + json.dumps(bundle_id) + '\n---\n- launchApp:\n clearState: false\n'
227
227
  content += ''.join('- tapOn:\n text: ' + json.dumps('^' + re.escape(label) + '$') + '\n' for label in path)
228
- flow.write_text(content)
228
+ _safe_write.write_text(flow, content)
229
229
  flow.chmod(0o600)
230
230
  command(['maestro', '--device', udid, 'test', '--debug-output', str(private / 'debug'),
231
231
  '--test-output-dir', str(private / 'output'), str(flow)],
@@ -235,11 +235,15 @@ def navigate(udid, bundle_id, path, out, deadline):
235
235
  def capture_screen(udid, out, name, deadline, authenticated=False, allowed=None):
236
236
  raw = command(['maestro', '--device', udid, 'hierarchy'], min(45, max(.01, deadline-time.monotonic())), cwd=out)
237
237
  tree = scrub_tree(json.loads(raw), authenticated=authenticated, allowed=allowed)
238
- (out / (name + '.json')).write_text(json.dumps(tree, indent=2))
238
+ _safe_write.write_text(out / (name + '.json'), json.dumps(tree, indent=2))
239
239
  png = None if authenticated else name + '.png'
240
240
  try:
241
241
  if png:
242
- command(['xcrun', 'simctl', 'io', udid, 'screenshot', '--type=png', str(out / png)], min(15, max(.01, deadline-time.monotonic())), cwd=out)
242
+ with tempfile.TemporaryDirectory(prefix='.screenshot-', dir=str(out)) as temporary:
243
+ image = pathlib.Path(temporary) / png
244
+ command(['xcrun', 'simctl', 'io', udid, 'screenshot', '--type=png', str(image)],
245
+ min(15, max(.01, deadline-time.monotonic())), cwd=out)
246
+ _safe_write.write_bytes(out / png, image.read_bytes())
243
247
  except (OSError, subprocess.SubprocessError):
244
248
  png = None
245
249
  screen = summarize(tree, name, png, time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime()))
@@ -304,7 +308,7 @@ def main():
304
308
  screens = live_explore(args.udid, args.bundle_id, out, args.max_screens, args.seconds, authorization, args.authenticated)
305
309
  report = {'schema_version': 1, 'screens': screens, 'checks': evaluate(screens, {}),
306
310
  'screen_budget': args.max_screens, 'time_budget_seconds': args.seconds}
307
- (out / 'screen-inventory.json').write_text(json.dumps(report, indent=2) + '\n')
311
+ _safe_write.write_text(out / 'screen-inventory.json', json.dumps(report, indent=2) + '\n')
308
312
  print(json.dumps(report)); return 0
309
313
 
310
314
 
@@ -136,11 +136,15 @@ def safe_action(value):
136
136
 
137
137
 
138
138
  def hierarchy(udid):
139
- raw = command(['maestro', '--device', udid, 'hierarchy'], 15)
140
- try:
141
- return json.loads(raw)
142
- except (ValueError, TypeError):
143
- return {}
139
+ for _ in range(2):
140
+ raw = command(['maestro', '--device', udid, 'hierarchy'], 15)
141
+ try:
142
+ tree = json.loads(raw)
143
+ if isinstance(tree, (dict, list)):
144
+ return tree
145
+ except (ValueError, TypeError):
146
+ pass
147
+ return {}
144
148
 
145
149
 
146
150
  def tap(udid, bundle, text):
@@ -208,13 +212,19 @@ def applicability(app, repo):
208
212
  'miniapp': source_signal(repo)}
209
213
 
210
214
 
211
- def cpu_observation(pid, app, executable):
215
+ def cpu_observation(pid, udid, bundle_id, executable):
212
216
  obs = {'applicable': True, 'usable': False}
213
217
  if not str(pid).isdigit() or not executable or '/' in executable:
214
218
  return obs
215
- expected = str(Path(app).resolve() / executable)
219
+ container = command(['xcrun', 'simctl', 'get_app_container', udid, bundle_id, 'app']).strip()
220
+ if not container or not Path(container).is_absolute():
221
+ obs['reason'] = 'container path unavailable; CPU was not sampled'
222
+ return obs
223
+ expected = str(Path(container).resolve() / executable)
224
+ device_data = (Path.home() / 'Library/Developer/CoreSimulator/Devices' / udid / 'data').resolve()
216
225
  actual = command(['ps', '-p', str(pid), '-o', 'comm=']).strip()
217
- if actual != expected:
226
+ if (actual != expected or Path(actual).name != executable
227
+ or device_data not in Path(actual).resolve().parents):
218
228
  obs['reason'] = 'Process identity did not match the installed executable; CPU was not sampled'
219
229
  return obs
220
230
  time.sleep(20)
@@ -262,7 +272,7 @@ def action_observation(args, mode, initial):
262
272
  def observe(args):
263
273
  signals = applicability(args.app, args.repo)
264
274
  initial = screen_facts(load_tree(args.initial_tree))
265
- result = {'dyn-cpu-idle': cpu_observation(args.pid, args.app, args.executable)}
275
+ result = {'dyn-cpu-idle': cpu_observation(args.pid, args.udid, args.bundle_id, args.executable)}
266
276
  modes = {'capture': 'dyn-capture-indicator', 'music': 'dyn-musickit-auth',
267
277
  'miniapp': 'dyn-miniapp-index', 'location': 'dyn-location-timing'}
268
278
  for mode, rule in modes.items():
@@ -37,9 +37,7 @@ def scrub_tree(value, authenticated=False, allowed=None, key=''):
37
37
  if isinstance(value, list):
38
38
  return [scrub_tree(x, authenticated, allowed, key) for x in value]
39
39
  if isinstance(value, dict):
40
- secure = any('securetextfield' in str(value.get(k, '')).lower() for k in ('type', 'class'))
41
- return {scrub_text(k): ('[redacted]' if secure and k in ('text', 'value', 'accessibilityText', 'label')
42
- else scrub_tree(v, authenticated, allowed, k)) for k, v in value.items()}
40
+ return {scrub_text(k): scrub_tree(v, authenticated, allowed, k) for k, v in value.items()}
43
41
  return value
44
42
 
45
43
 
@@ -19,6 +19,7 @@
19
19
 
20
20
  : "${DYN_DRY_RUN:=0}"
21
21
  : "${DYN_MAESTRO_TIMEOUT:=45}"
22
+ : "${DYN_MAESTRO_WARMUP_TIMEOUT:=120}"
22
23
  DYN_LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
23
24
 
24
25
  # dyn_with_timeout <secs> <argv…> — run with a wall-clock cap (macOS has no
@@ -98,6 +99,34 @@ dyn_signal_tree() {
98
99
  [[ "$n" =~ ^[0-9]+$ ]] && echo "$n" || echo unread
99
100
  }
100
101
 
102
+ # Warm-up is a discarded driver read, never observation evidence. Zero disables it.
103
+ dyn_maestro_warmup() {
104
+ local udid="$1" status=0
105
+ [[ "$DYN_MAESTRO_WARMUP_TIMEOUT" != 0 ]] || return 0
106
+ if [[ "$DYN_DRY_RUN" == 1 ]]; then
107
+ dyn_plan "maestro --device $udid hierarchy # warm-up; timeout ${DYN_MAESTRO_WARMUP_TIMEOUT}s; result discarded"
108
+ note 'NOTE: [dyn-maestro-warmup] planned discarded hierarchy read'
109
+ return 0
110
+ fi
111
+ if ! command -v maestro >/dev/null 2>&1; then
112
+ note 'NOTE: [dyn-maestro-warmup] unavailable: Maestro missing; no observation recorded'
113
+ return 0
114
+ fi
115
+ python3 -B "$DYN_LIB_DIR/dyn-process.py" --timeout "$DYN_MAESTRO_WARMUP_TIMEOUT" --grace 1 -- \
116
+ maestro --device "$udid" hierarchy >/dev/null 2>&1 || status=$?
117
+ note "NOTE: [dyn-maestro-warmup] discarded hierarchy read; exit $status; no observation recorded"
118
+ }
119
+
120
+ # Retry unread geometry once; a readable degenerate tree is still a real SKIP.
121
+ dyn_signal_tree_retry() {
122
+ local tree
123
+ tree="$(dyn_signal_tree "$1" "$2")"
124
+ if [[ "$tree" == unread && "$DYN_DRY_RUN" != 1 ]]; then
125
+ tree="$(dyn_signal_tree "$1" "$2")"
126
+ fi
127
+ printf '%s\n' "$tree"
128
+ }
129
+
101
130
  # dyn_repeat <udid> <bundle-id> <executable> <window-secs> <out-dir> <i>
102
131
  # -> "<verdict><TAB><detail><TAB><proc>,<shot>,<log>,<tree>" for dyn-launch; files in out-dir.
103
132
  dyn_repeat() {
@@ -7,7 +7,15 @@ optin_trust() {
7
7
  fi
8
8
  }
9
9
 
10
+ optin_blocking_tools() {
11
+ if [[ "${OPT_DYN_BLOCK:-0}" == 1 ]] && ! command -v jq >/dev/null 2>&1; then
12
+ echo 'scan.sh: --dynamic-blocking needs jq' >&2
13
+ return 64
14
+ fi
15
+ }
16
+
10
17
  optin_validate() {
18
+ optin_blocking_tools || return $?
11
19
  [[ "$OPT_BUILD" != 1 || -z "$OPT_APP" ]] || { echo 'scan.sh: choose --build or --app' >&2; return 64; }
12
20
  if [[ "$OPT_DEMO" == 1 || "$OPT_DYN_BLOCK" == 1 ]]; then
13
21
  [[ "$OPT_NO_RUNTIME" != 1 && ( "$OPT_BUILD" == 1 || -n "$OPT_APP" ) ]] || { echo 'scan.sh: runtime flags need --build/--app and cannot use --no-runtime' >&2; return 64; }
@@ -24,6 +32,7 @@ PY
24
32
  }
25
33
 
26
34
  optin_run() {
35
+ optin_blocking_tools || return $?
27
36
  [[ "$OPT_BUILD" == 1 || -n "$OPT_APP" || "$OPT_METADATA" == 1 ]] || return 0
28
37
  if ! command -v python3 >/dev/null 2>&1; then
29
38
  set_rule 'opt-in-review'; skip 'opt-in review — Python 3 required'; return 0
@@ -50,9 +59,6 @@ optin_run() {
50
59
  fi
51
60
  OPT_RAN_OK=1
52
61
  [[ "$FORMAT" != text ]] || printf 'OPT-IN: report — %s/summary.json\n' "$OPT_OUT"
53
- if [[ "$OPT_DYN_BLOCK" == 1 ]] && ! command -v jq >/dev/null 2>&1; then
54
- set_rule 'dynamic-blocking'; skip 'dynamic blocking — jq unavailable; no blocking conclusions imported'; return 0
55
- fi
56
62
  if [[ "$OPT_DYN_BLOCK" == 1 ]]; then
57
63
  while IFS= read -r line; do
58
64
  [[ -n "$line" ]] || continue
@@ -33,6 +33,15 @@ def _current_umask():
33
33
 
34
34
  def write_text(path, text, encoding="utf-8"):
35
35
  """Atomically write ``text`` to ``path``; refuse a symlink or non-regular target."""
36
+ _write(path, text, "w", encoding)
37
+
38
+
39
+ def write_bytes(path, data):
40
+ """Atomically write binary output under the same regular-file policy."""
41
+ _write(path, data, "wb", None)
42
+
43
+
44
+ def _write(path, content, stream_mode, encoding):
36
45
  target = os.path.abspath(os.fspath(path))
37
46
  mode = _existing_mode(target)
38
47
  if mode is not None and not stat.S_ISREG(mode):
@@ -43,8 +52,8 @@ def write_text(path, text, encoding="utf-8"):
43
52
  fd, temporary = tempfile.mkstemp(dir=directory, prefix="." + os.path.basename(target) + ".",
44
53
  suffix=".tmp")
45
54
  try:
46
- with os.fdopen(fd, "w", encoding=encoding) as handle:
47
- handle.write(text)
55
+ with os.fdopen(fd, stream_mode, encoding=encoding) as handle:
56
+ handle.write(content)
48
57
  handle.flush()
49
58
  os.fsync(handle.fileno())
50
59
  if hasattr(os, "chmod"):
@@ -2,12 +2,17 @@
2
2
  # Additional source checks are advisory; absent inputs remain additive coverage gaps.
3
3
  # shellcheck disable=SC2034
4
4
  COVERAGE_GAPS_JSON="${COVERAGE_GAPS_JSON:-[]}"
5
- STATIC_GAP_COUNT=0 STATIC_GAP_SLUGS="" STATIC_GAP_REASON="" STATIC_EMOJI_STATUS=SKIP
5
+ STATIC_GAP_COUNT=0 STATIC_GAP_TOTAL=0 STATIC_GAP_SLUGS="" STATIC_GAP_REASON="" STATIC_EMOJI_STATUS=SKIP
6
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
7
12
  if command -v python3 >/dev/null 2>&1 && command -v jq >/dev/null 2>&1; then
8
13
  STATIC_GUIDELINES_JSON="$(python3 -B "$SCRIPT_DIR/lib/static-reader.py" \
9
14
  --root "$ROOT" --metadata "${META_DIR:-/nonexistent}" --plist "${INFO_PLIST:-/nonexistent}" \
10
- "${GREP_PRUNE[@]+"${GREP_PRUNE[@]}"}" )" || STATIC_GUIDELINES_JSON='{"_reader_error":"reader invocation failed; see stderr"}'
15
+ "${STATIC_READER_EXCLUDES[@]+"${STATIC_READER_EXCLUDES[@]}"}" )" || STATIC_GUIDELINES_JSON='{"_reader_error":"reader invocation failed; see stderr"}'
11
16
  fi
12
17
 
13
18
  static_guideline_select() {
@@ -24,8 +29,12 @@ static_guideline_select() {
24
29
 
25
30
  static_guideline_gap() {
26
31
  local id="$1" guideline="$2" reason="$3"
27
- STATIC_GAP_COUNT=$((STATIC_GAP_COUNT + 1))
28
- STATIC_GAP_SLUGS="${STATIC_GAP_SLUGS}${STATIC_GAP_SLUGS:+, }$id"
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
29
38
  STATIC_GAP_REASON="$reason"
30
39
  if command -v jq >/dev/null 2>&1; then
31
40
  COVERAGE_GAPS_JSON="$(printf '%s' "$COVERAGE_GAPS_JSON" | jq -c \
@@ -39,161 +48,62 @@ static_guideline_gap() {
39
48
  fi
40
49
  }
41
50
 
42
- # §56 — 2.3.12: release-notes-specificity
43
- set_rule "release-notes-specificity"
44
- static_guideline_select "release-notes-specificity"
45
- case "$STATIC_STATUS" in
46
- WARN) warn "2.3.12 release-notes-specificity — $STATIC_REASON" "$STATIC_FILE" ;;
47
- PASS) pass "2.3.12 release-notes-specificity — $STATIC_REASON" ;;
48
- *) static_guideline_gap "release-notes-specificity" "2.3.12" "$STATIC_REASON" ;;
49
- esac
50
-
51
- # §57 — 2.4.4: device-restart-instructions
52
- set_rule "device-restart-instructions"
53
- static_guideline_select "device-restart-instructions"
54
- case "$STATIC_STATUS" in
55
- WARN) warn "2.4.4 device-restart-instructions — $STATIC_REASON" "$STATIC_FILE" ;;
56
- PASS) pass "2.4.4 device-restart-instructions — $STATIC_REASON" ;;
57
- *) static_guideline_gap "device-restart-instructions" "2.4.4" "$STATIC_REASON" ;;
58
- esac
59
-
60
- # §58 — 2.5.6: browser-engine
61
- set_rule "browser-engine"
62
- static_guideline_select "browser-engine"
63
- case "$STATIC_STATUS" in
64
- WARN) warn "2.5.6 browser-engine — $STATIC_REASON" "$STATIC_FILE" ;;
65
- PASS) pass "2.5.6 browser-engine — $STATIC_REASON" ;;
66
- *) static_guideline_gap "browser-engine" "2.5.6" "$STATIC_REASON" ;;
67
- esac
68
-
69
- # §59 — 2.5.11: intent-handler-parity
70
- set_rule "intent-handler-parity"
71
- static_guideline_select "intent-handler-parity"
72
- case "$STATIC_STATUS" in
73
- WARN) warn "2.5.11 intent-handler-parity — $STATIC_REASON" "$STATIC_FILE" ;;
74
- PASS) pass "2.5.11 intent-handler-parity — $STATIC_REASON" ;;
75
- *) static_guideline_gap "intent-handler-parity" "2.5.11" "$STATIC_REASON" ;;
76
- esac
77
-
78
- # §60 — 2.5.12: call-filter-controls
79
- set_rule "call-filter-controls"
80
- static_guideline_select "call-filter-controls"
81
- case "$STATIC_STATUS" in
82
- WARN) warn "2.5.12 call-filter-controls — $STATIC_REASON" "$STATIC_FILE" ;;
83
- PASS) pass "2.5.12 call-filter-controls — $STATIC_REASON" ;;
84
- *) static_guideline_gap "call-filter-controls" "2.5.12" "$STATIC_REASON" ;;
85
- esac
86
-
87
- # §61 — 2.5.13: face-authentication
88
- set_rule "face-authentication"
89
- static_guideline_select "face-authentication"
90
- case "$STATIC_STATUS" in
91
- WARN) warn "2.5.13 face-authentication — $STATIC_REASON" "$STATIC_FILE" ;;
92
- PASS) pass "2.5.13 face-authentication — $STATIC_REASON" ;;
93
- *) static_guideline_gap "face-authentication" "2.5.13" "$STATIC_REASON" ;;
94
- esac
95
-
96
- # §62 — 2.5.15: document-browser-access
97
- set_rule "document-browser-access"
98
- static_guideline_select "document-browser-access"
99
- case "$STATIC_STATUS" in
100
- WARN) warn "2.5.15 document-browser-access — $STATIC_REASON" "$STATIC_FILE" ;;
101
- PASS) pass "2.5.15 document-browser-access — $STATIC_REASON" ;;
102
- *) static_guideline_gap "document-browser-access" "2.5.15" "$STATIC_REASON" ;;
103
- esac
104
-
105
- # §63 — 2.5.16: extension-bundle-parity
106
- set_rule "extension-bundle-parity"
107
- static_guideline_select "extension-bundle-parity"
108
- case "$STATIC_STATUS" in
109
- WARN) warn "2.5.16 extension-bundle-parity — $STATIC_REASON" "$STATIC_FILE" ;;
110
- PASS) pass "2.5.16 extension-bundle-parity — $STATIC_REASON" ;;
111
- *) static_guideline_gap "extension-bundle-parity" "2.5.16" "$STATIC_REASON" ;;
112
- esac
113
-
114
- # §64 — 2.5.17: matter-extension
115
- set_rule "matter-extension"
116
- static_guideline_select "matter-extension"
117
- case "$STATIC_STATUS" in
118
- WARN) warn "2.5.17 matter-extension — $STATIC_REASON" "$STATIC_FILE" ;;
119
- PASS) pass "2.5.17 matter-extension — $STATIC_REASON" ;;
120
- *) static_guideline_gap "matter-extension" "2.5.17" "$STATIC_REASON" ;;
121
- esac
122
-
123
- # §65 — 2.5.18: extension-advertising
124
- set_rule "extension-advertising"
125
- static_guideline_select "extension-advertising"
126
- case "$STATIC_STATUS" in
127
- WARN) warn "2.5.18 extension-advertising — $STATIC_REASON" "$STATIC_FILE" ;;
128
- PASS) pass "2.5.18 extension-advertising — $STATIC_REASON" ;;
129
- *) static_guideline_gap "extension-advertising" "2.5.18" "$STATIC_REASON" ;;
130
- esac
131
-
132
- # §66 — 4.2.1: ar-integration-depth
133
- set_rule "ar-integration-depth"
134
- static_guideline_select "ar-integration-depth"
135
- case "$STATIC_STATUS" in
136
- WARN) warn "4.2.1 ar-integration-depth — $STATIC_REASON" "$STATIC_FILE" ;;
137
- PASS) pass "4.2.1 ar-integration-depth — $STATIC_REASON" ;;
138
- *) static_guideline_gap "ar-integration-depth" "4.2.1" "$STATIC_REASON" ;;
139
- esac
140
-
141
- # §67 — 4.2.3: companion-app-required
142
- set_rule "companion-app-required"
143
- static_guideline_select "companion-app-required"
144
- case "$STATIC_STATUS" in
145
- WARN) warn "4.2.3 companion-app-required — $STATIC_REASON" "$STATIC_FILE" ;;
146
- PASS) pass "4.2.3 companion-app-required — $STATIC_REASON" ;;
147
- *) static_guideline_gap "companion-app-required" "4.2.3" "$STATIC_REASON" ;;
148
- esac
149
-
150
- # §68 — 4.5.5: game-center-id-sharing
151
- set_rule "game-center-id-sharing"
152
- static_guideline_select "game-center-id-sharing"
153
- case "$STATIC_STATUS" in
154
- WARN) warn "4.5.5 game-center-id-sharing — $STATIC_REASON" "$STATIC_FILE" ;;
155
- PASS) pass "4.5.5 game-center-id-sharing — $STATIC_REASON" ;;
156
- *) static_guideline_gap "game-center-id-sharing" "4.5.5" "$STATIC_REASON" ;;
157
- esac
158
-
159
- # §69 — 4.5.6: metadata-emoji
160
- set_rule "metadata-emoji"
161
- static_guideline_select "metadata-emoji"
162
- case "$STATIC_STATUS" in
163
- WARN) warn "4.5.6 metadata-emoji — $STATIC_REASON" "$STATIC_FILE" ;;
164
- PASS) pass "4.5.6 metadata-emoji — $STATIC_REASON" ;;
165
- *) static_guideline_gap "metadata-emoji" "4.5.6" "$STATIC_REASON" ;;
166
- esac
167
-
168
- STATIC_EMOJI_STATUS="$STATIC_STATUS"
169
-
170
- # §70 — 4.7.2: miniapp-native-bridge
171
- set_rule "miniapp-native-bridge"
172
- static_guideline_select "miniapp-native-bridge"
173
- case "$STATIC_STATUS" in
174
- WARN) warn "4.7.2 miniapp-native-bridge — $STATIC_REASON" "$STATIC_FILE" ;;
175
- PASS) pass "4.7.2 miniapp-native-bridge — $STATIC_REASON" ;;
176
- *) static_guideline_gap "miniapp-native-bridge" "4.7.2" "$STATIC_REASON" ;;
177
- esac
178
-
179
- # §71 — 5.2.4: apple-endorsement-claims
180
- set_rule "apple-endorsement-claims"
181
- static_guideline_select "apple-endorsement-claims"
182
- case "$STATIC_STATUS" in
183
- WARN) warn "5.2.4 apple-endorsement-claims — $STATIC_REASON" "$STATIC_FILE" ;;
184
- PASS) pass "5.2.4 apple-endorsement-claims — $STATIC_REASON" ;;
185
- *) static_guideline_gap "apple-endorsement-claims" "5.2.4" "$STATIC_REASON" ;;
186
- esac
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
187
80
 
188
81
  if [[ "$STATIC_EMOJI_STATUS" != SKIP ]]; then
189
82
  static_guideline_gap "metadata-emoji-icon-not-audited" "4.5.6" "Apple emoji artwork in icon pixels requires visual review."
190
83
  fi
84
+ STATIC_GAP_FALLBACK_SLUGS="$STATIC_GAP_SLUGS" STATIC_GAP_REASON_FALLBACK="$STATIC_GAP_REASON"
191
85
  if command -v jq >/dev/null 2>&1; then
192
86
  _input_gap="$(printf '%s' "$STATIC_GUIDELINES_JSON" | jq -r '._input_gaps // empty | "\(.count) files skipped: \(.paths | join(", "))"')"
193
87
  if [[ -n "$_input_gap" ]]; then static_guideline_gap "source-inputs-not-audited" "source" "$_input_gap"; fi
194
- STATIC_GAP_REASON="$(printf '%s' "$COVERAGE_GAPS_JSON" | jq -jr '[.[].reason] | unique | join("; ")' | tr '\n\r\t' ' ')"
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)"
195
101
  fi
196
- if [[ "$STATIC_GAP_COUNT" -gt 0 ]]; then
102
+ if [[ "$STATIC_GAP_TOTAL" -gt 0 ]]; then
197
103
  set_rule "modular-checks-not-audited"
198
- skip "modular-checks-not-audited — $STATIC_GAP_COUNT check(s) did not run: $STATIC_GAP_SLUGS ($STATIC_GAP_REASON)"
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
199
109
  fi
@@ -7,6 +7,7 @@ import os
7
7
  import pathlib
8
8
  import plistlib
9
9
  import re
10
+ import stat
10
11
  from xml.parsers.expat import ExpatError
11
12
 
12
13
  PRUNE = {'.git', 'Pods', 'Carthage', '.build', 'build', 'DerivedData',
@@ -24,16 +25,25 @@ def uncomment(text):
24
25
  return TOKEN.sub(lambda m: '\n' * m[0].count('\n') if m[0].startswith(('/', '/*')) else m[0], text)
25
26
 
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
+
27
43
  def checked_text(path):
28
- if path.is_symlink():
29
- raise ValueError('symlink input not followed')
30
- limit = 8 if path.suffix in RESOURCE else 2
31
- if path.stat().st_size > limit * 1024 * 1024:
32
- raise ValueError('input exceeds %d MiB read limit' % limit)
33
- with path.open('rb') as stream:
34
- bom = stream.read(2)
35
- encoding = 'utf-16' if path.suffix == '.strings' and bom in (b'\xff\xfe', b'\xfe\xff') else 'utf-8'
36
- return path.read_text(encoding=encoding)
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)
37
47
 
38
48
 
39
49
  def input_error(path, exc, root=None):
@@ -42,15 +52,12 @@ def input_error(path, exc, root=None):
42
52
  name = str(path.relative_to(root)) if root else path.name
43
53
  except ValueError:
44
54
  name = path.name
45
- return name
55
+ return name + (' (special file skipped)' if isinstance(exc, ValueError) and str(exc) == 'special file skipped' else '')
46
56
 
47
57
 
48
58
  def read_candidate(path):
49
59
  if path.suffix in {'.plist', '.entitlements'}:
50
- if path.is_symlink() or path.stat().st_size > 2 * 1024 * 1024:
51
- raise ValueError('manifest is a symlink or exceeds 2 MiB read limit')
52
- with path.open('rb') as stream:
53
- value = plistlib.load(stream)
60
+ value = plistlib.loads(checked_bytes(path))
54
61
  if not isinstance(value, dict):
55
62
  raise ValueError('manifest root is not a dictionary')
56
63
  return plistlib.dumps(value).decode('utf-8')
@@ -115,33 +122,51 @@ def metadata_files(c, names):
115
122
  try:
116
123
  checked_text(p)
117
124
  except (OSError, UnicodeError, ValueError) as exc:
118
- raise ValueError(input_error(p, exc)) from 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
119
130
  return files
120
131
 
121
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
+
122
145
  def release_notes(c):
123
146
  files = metadata_files(c, ['release_notes'])
124
147
  if not files:
125
148
  return outcome(skip=True, reason='Release notes metadata unavailable.')
149
+ version, initial_empty = app_version(c), False
126
150
  for p in files:
127
151
  value = checked_text(p).strip()
128
152
  desc = p.with_name('description.txt')
129
153
  same = desc.is_file() and not desc.is_symlink() and value == checked_text(desc).strip()
130
- version_file = c['metadata'] / 'version.txt'
131
- version = checked_text(version_file).strip() if version_file.is_file() else ''
132
- if not value and version == '1.0':
154
+ if not value and version in ('1.0', '1.0.0'):
155
+ initial_empty = True
133
156
  continue
134
157
  if not value and not version:
135
158
  return outcome(True, 'Empty release notes with unknown version; low-confidence update review.', p)
136
159
  if not value or re.fullmatch(r'lorem(?: ipsum)?[.!]?|TODO|N[/-]A', value, re.I) or same:
137
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')
138
163
  return outcome(reason='Release notes contain specific non-placeholder text.')
139
164
 
140
165
 
141
166
  def restart(c):
142
167
  source = {p: t for p, t in c['src'].items()
143
168
  if not re.search(r'(?m)^\s*(?:@testable\s+)?import\s+(?:Testing|XCTest)\b', t)}
144
- p = hit_file(source, r'"[^"\n]*(?:restart your device|reboot|change your settings in Settings\s*>\s*General)[^"\n]*"')
169
+ p = hit_file(source, r'"[^"\n]{0,512}(?:restart your device|reboot|change your settings in Settings\s*>\s*General)[^"\n]{0,512}"')
145
170
  p = p or hit_file(c['resources'], r'restart your device|\breboot\b|change your settings in Settings\s*>\s*General')
146
171
  return outcome(bool(p), 'Device restart/settings instruction string; inspect the user-facing context.' if p else '', p)
147
172
 
@@ -149,7 +174,7 @@ def restart(c):
149
174
  def browser(c):
150
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'}
151
176
  p = next((p for p, text in deps.items()
152
- if re.search(r"[\"'][^\"'\n]*\b(?:Chromium|CEF|Gecko|Blink)\b(?![^\"'\n]*\.(?:swift|m|mm|h|storyboard|xib)[\"'])|\b(?:Chromium|CEF|Gecko|Blink)\.framework", text)), None)
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)
153
178
  legacy = hit_file(c['src'], r'\bUIWebView\s*(?:\(|[*>])|:\s*UIWebView\b')
154
179
  if legacy:
155
180
  return outcome(True, 'Deprecated UIWebView reference; verify the shipping target and Xcode SDK before removal.', legacy)
@@ -167,7 +192,7 @@ def intents(c):
167
192
 
168
193
  def call_filter(c):
169
194
  p = hit_file(c['src'], r'\b(?:ILMessageFilterExtension|CXCallDirectoryProvider|CXCallDirectoryManager)\b')
170
- ui = hit_file(c['src'], r'"[^"\n]*(?:blocked (?:numbers|callers)|call blocking|spam filter|blocking settings)[^"\n]*"') or hit_file(c['resources'], r'blocked numbers|call blocking|spam filter')
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')
171
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)
172
197
 
173
198
 
@@ -185,11 +210,11 @@ def documents(c):
185
210
  picker = hit_file(c['src'], r'\bUIDocumentPicker\w*\b|\.fileImporter\s*\(|\bUIDocumentBrowserViewController\b')
186
211
  if picker:
187
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)"')
188
215
  custom = next((p for p, t in c['src'].items()
189
- if re.search(r'FileManager\.default\.contentsOfDirectory', t)
216
+ if title and re.search(r'FileManager\.default\.contentsOfDirectory|\benumerator\s*\(\s*at\s*:', t)
190
217
  and re.search(r'\b(?:List|Table|UICollectionView|UITableView)\b', t)), None)
191
- custom = custom or hit_file(c['src'], r'(?:navigationTitle|Text|title\s*=)\s*\(?\s*"(?:My Files|Files|Documents)"')
192
- custom = custom or hit_file(c['resources'], r'"(?:My Files|Files|Documents)"')
193
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)
194
219
 
195
220
 
@@ -239,7 +264,7 @@ def ar_depth(c):
239
264
 
240
265
 
241
266
  def companion(c):
242
- p = hit_file(c['src'], r'"[^"\n]*(?:download|install)\s+[^"\n]{1,60}\s+to (?:continue|proceed|use)[^"\n]*"') or hit_file(c['resources'], r'(?:download|install)\s+[^"\n]{1,60}\s+to (?:continue|proceed|use)')
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)')
243
268
  bad = bool(c['main'].get('LSApplicationQueriesSchemes') and p)
244
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)
245
270
 
@@ -315,7 +340,11 @@ def evaluate(root, metadata, main, excludes):
315
340
  try:
316
341
  result[key] = check(c)
317
342
  except (OSError, UnicodeError, ValueError) as exc:
318
- result[key] = outcome(skip=True, reason='Input could not be completely read: ' + str(exc)[:500])
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)
319
348
  for key, row in result.items():
320
349
  if key.startswith('_'):
321
350
  continue
@@ -323,7 +352,7 @@ def evaluate(root, metadata, main, excludes):
323
352
  try:
324
353
  row['file'] = str(pathlib.Path(row['file']).relative_to(root))
325
354
  except ValueError:
326
- pass
355
+ row['file'] = pathlib.Path(row['file']).name
327
356
  return result
328
357
 
329
358
 
@@ -146,7 +146,8 @@ PRUNE=( -not -path '*/.git/*' -not -path '*/Pods/*' -not -path '*/Carthage/*'
146
146
 
147
147
  # Same prune set expressed as grep --exclude-dir globs, for repo-wide grep -r passes
148
148
  # (the find-style PRUNE above is not valid grep syntax).
149
- GREP_PRUNE=( --exclude-dir=.git --exclude-dir=Pods --exclude-dir=Carthage
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
150
151
  --exclude-dir=.build --exclude-dir=build --exclude-dir=DerivedData
151
152
  --exclude-dir=SourcePackages --exclude-dir=checkouts --exclude-dir=.swiftpm
152
153
  --exclude-dir=.claude --exclude-dir=worktrees