appstore-precheck 1.18.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.
- package/CHANGELOG.md +256 -0
- package/README.md +108 -39
- package/bin/cli.js +8 -0
- package/package.json +2 -2
- package/skills/appstore-precheck/SKILL.md +99 -157
- package/skills/appstore-precheck/guidelines-baseline.json +285 -36
- package/skills/appstore-precheck/guidelines-fingerprints.json +319 -93
- package/skills/appstore-precheck/references/finding-commentary.md +93 -0
- package/skills/appstore-precheck/references/methodology.md +81 -26
- package/skills/appstore-precheck/references/optional-review.md +56 -0
- package/skills/appstore-precheck/references/pierre-deep-review.md +323 -44
- package/skills/appstore-precheck/references/review-catalog.json +740 -0
- package/skills/appstore-precheck/references/screenshot-vision-review.md +8 -8
- package/skills/appstore-precheck/references/simulator-dynamic-review.md +398 -54
- package/skills/appstore-precheck/references/typesafe-example.json +239 -0
- package/skills/appstore-precheck/references/typesafe.md +216 -0
- package/skills/appstore-precheck/scripts/app-discover.sh +138 -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 +400 -0
- package/skills/appstore-precheck/scripts/dynamic.sh +329 -0
- package/skills/appstore-precheck/scripts/evidence.sh +49 -15
- package/skills/appstore-precheck/scripts/findings.sh +76 -26
- package/skills/appstore-precheck/scripts/framework-detect.sh +101 -0
- package/skills/appstore-precheck/scripts/guideline-cite.sh +4 -1
- 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 +244 -0
- package/skills/appstore-precheck/scripts/lib/dyn-bundle.sh +185 -0
- package/skills/appstore-precheck/scripts/lib/dyn-demo-login.py +111 -0
- package/skills/appstore-precheck/scripts/lib/dyn-device.sh +123 -0
- package/skills/appstore-precheck/scripts/lib/dyn-explore.py +312 -0
- package/skills/appstore-precheck/scripts/lib/dyn-geometry.sh +75 -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-hosts.sh +134 -0
- package/skills/appstore-precheck/scripts/lib/dyn-process.py +75 -0
- package/skills/appstore-precheck/scripts/lib/dyn-quorum.sh +90 -0
- package/skills/appstore-precheck/scripts/lib/dyn-scrub.py +79 -0
- package/skills/appstore-precheck/scripts/lib/dyn-signals.sh +120 -0
- package/skills/appstore-precheck/scripts/lib/guideline-text.sh +23 -5
- package/skills/appstore-precheck/scripts/lib/metadata-review.py +369 -0
- package/skills/appstore-precheck/scripts/lib/optin-scan.sh +73 -0
- package/skills/appstore-precheck/scripts/lib/optional-records.py +60 -0
- package/skills/appstore-precheck/scripts/lib/png-uniform.py +115 -0
- package/skills/appstore-precheck/scripts/lib/runtime-blocking.py +26 -0
- package/skills/appstore-precheck/scripts/lib/safe_write.py +61 -0
- package/skills/appstore-precheck/scripts/lib/scan-guidelines.sh +199 -0
- package/skills/appstore-precheck/scripts/lib/static-guidelines.py +341 -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 +132 -21
- package/skills/appstore-precheck/scripts/semantic/__init__.py +1 -0
- package/skills/appstore-precheck/scripts/semantic/client.py +95 -0
- package/skills/appstore-precheck/scripts/semantic/collect.py +165 -0
- package/skills/appstore-precheck/scripts/semantic/engine.py +320 -0
- package/skills/appstore-precheck/scripts/semantic/questions.py +167 -0
- package/skills/appstore-precheck/scripts/semantic/review_v4.py +81 -0
- package/skills/appstore-precheck/scripts/semantic-review.py +61 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# lib/dyn-quorum.sh — the DECISION RULES of the Phase 6 dynamic tier, as pure
|
|
3
|
+
# functions: how four launch signals become one launch verdict, and how N repeated
|
|
4
|
+
# verdicts become one transcript line. No simctl, no Maestro, no files: this is the
|
|
5
|
+
# part of dynamic-run.sh that CI can pin, so the determinism policy is tested code,
|
|
6
|
+
# not prose. Sourced by dynamic-run.sh. Bash 3.2 compatible.
|
|
7
|
+
#
|
|
8
|
+
# POLICY (from the Phase 2 contract)
|
|
9
|
+
# * N=3 repeats, each on a freshly erased device. A FINDING needs 3/3; mixed or incomplete
|
|
10
|
+
# observations are SKIP, with their counts preserved for human review.
|
|
11
|
+
# * A driver timeout or an unreadable run is a SKIP for that repeat, never a
|
|
12
|
+
# FINDING. If every repeat was a SKIP, the check is a SKIP.
|
|
13
|
+
# * Launch evidence combines four signals: process alive, screenshot not
|
|
14
|
+
# uniform, no crash in the log stream, accessibility tree size. A signal that
|
|
15
|
+
# could not be read is named in the line. A degenerate tree (Flutter / Compose)
|
|
16
|
+
# is never a failure on its own. A flat screenshot alone is not a crash.
|
|
17
|
+
# A clean log alone cannot establish a successful launch.
|
|
18
|
+
|
|
19
|
+
# dyn_launch_verdict <process> <screenshot> <log> <tree>
|
|
20
|
+
# process: alive | dead | unread
|
|
21
|
+
# screenshot: varied | uniform | unread
|
|
22
|
+
# log: clean | crash | unread
|
|
23
|
+
# tree: <node count> | unread
|
|
24
|
+
# -> "<PASS|FINDING|SKIP><TAB><detail>"
|
|
25
|
+
dyn_launch_verdict() {
|
|
26
|
+
local proc="${1:-unread}" shot="${2:-unread}" log="${3:-unread}" tree="${4:-unread}"
|
|
27
|
+
local unread="" fail="" ok="" degenerate="" positive=0
|
|
28
|
+
case "$proc" in
|
|
29
|
+
alive) ok="process alive"; positive=1 ;;
|
|
30
|
+
dead) fail="process gone" ;;
|
|
31
|
+
*) unread="process state" ;;
|
|
32
|
+
esac
|
|
33
|
+
case "$log" in
|
|
34
|
+
crash) fail="${fail:+$fail, }crash in log stream" ;;
|
|
35
|
+
clean) ok="${ok:+$ok, }no crash in log" ;;
|
|
36
|
+
*) unread="${unread:+$unread, }log stream" ;;
|
|
37
|
+
esac
|
|
38
|
+
case "$shot" in
|
|
39
|
+
varied) ok="${ok:+$ok, }screenshot not uniform"; positive=1 ;;
|
|
40
|
+
uniform) unread="${unread:+$unread, }flat screenshot (first-screen review required)" ;;
|
|
41
|
+
*) unread="${unread:+$unread, }screenshot" ;;
|
|
42
|
+
esac
|
|
43
|
+
case "$tree" in
|
|
44
|
+
unread|"") unread="${unread:+$unread, }accessibility tree" ;;
|
|
45
|
+
*) if [[ ! "$tree" =~ ^[0-9]+$ ]]; then unread="${unread:+$unread, }accessibility tree"
|
|
46
|
+
elif (( tree <= 3 )); then degenerate="accessibility tree has $tree node(s) (degenerate: Flutter/Compose expose no semantics; not a failure on its own)"
|
|
47
|
+
else ok="${ok:+$ok, }accessibility tree $tree nodes"; positive=1; fi ;;
|
|
48
|
+
esac
|
|
49
|
+
local detail=""
|
|
50
|
+
if [[ -n "$fail" ]]; then
|
|
51
|
+
detail="$fail"
|
|
52
|
+
[[ -n "$degenerate" ]] && detail="$detail; $degenerate"
|
|
53
|
+
[[ -n "$unread" ]] && detail="$detail ($unread could not be read)"
|
|
54
|
+
printf 'FINDING\t%s\n' "$detail"; return 0
|
|
55
|
+
fi
|
|
56
|
+
if (( positive == 0 )) || [[ "$shot" == uniform ]]; then
|
|
57
|
+
detail="launch health inconclusive${ok:+; $ok}"
|
|
58
|
+
[[ -n "$degenerate" ]] && detail="$detail; $degenerate"
|
|
59
|
+
[[ -n "$unread" ]] && detail="$detail ($unread could not be read)"
|
|
60
|
+
printf 'SKIP\t%s\n' "$detail"; return 0
|
|
61
|
+
fi
|
|
62
|
+
detail="$ok"
|
|
63
|
+
[[ -n "$degenerate" ]] && detail="$detail; $degenerate"
|
|
64
|
+
[[ -n "$unread" ]] && detail="$detail ($unread could not be read)"
|
|
65
|
+
printf 'PASS\t%s\n' "$detail"
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
# dyn_quorum <pass> <finding> <skip>: conclusions need three observed repeats.
|
|
69
|
+
# Mixed evidence and incomplete runs stay SKIP with counts for human review.
|
|
70
|
+
dyn_quorum() {
|
|
71
|
+
local pass="${1:-0}" finding="${2:-0}" skip="${3:-0}" n
|
|
72
|
+
n=$((pass + finding + skip))
|
|
73
|
+
if (( n >= 3 && finding == n )); then
|
|
74
|
+
printf 'FINDING\tquorum %d/%d: failed on every launch\n' "$finding" "$n"
|
|
75
|
+
elif (( n >= 3 && pass == n )); then
|
|
76
|
+
printf 'PASS\tquorum %d/%d passed\n' "$pass" "$n"
|
|
77
|
+
else
|
|
78
|
+
printf 'SKIP\tquorum %d/%d failures, %d passed, %d skipped; at least three unanimous observations required\n' "$finding" "$n" "$pass" "$skip"
|
|
79
|
+
fi
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
# Strip control characters from untrusted bundle names, ids and diagnostic text.
|
|
83
|
+
dyn_line() {
|
|
84
|
+
local kind="$1" guideline="$2" id="$3" msg="$4"
|
|
85
|
+
case "$kind" in PASS|FINDING|SKIP) ;; *) kind=SKIP ;; esac
|
|
86
|
+
guideline="$(printf '%s' "$guideline" | LC_ALL=C tr '[:cntrl:]' ' ')"
|
|
87
|
+
id="$(printf '%s' "$id" | LC_ALL=C tr '[:cntrl:]' ' ')"
|
|
88
|
+
msg="$(printf '%s' "$msg" | LC_ALL=C tr '[:cntrl:]' ' ')"
|
|
89
|
+
printf 'DYNAMIC-%s: %s [%s] — %s\n' "$kind" "$guideline" "$id" "$msg"
|
|
90
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Redact runtime hierarchies before any persistent write; raw trees stay in memory."""
|
|
3
|
+
import argparse
|
|
4
|
+
import importlib.util
|
|
5
|
+
import json
|
|
6
|
+
import os
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
import re
|
|
9
|
+
import subprocess
|
|
10
|
+
|
|
11
|
+
EMAIL = re.compile(r'[A-Za-z0-9.!#$%&\x27*+/=?^_`{|}~-]+@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+')
|
|
12
|
+
STRUCTURAL = {'bounds', 'type', 'class', 'packageName', 'bundleId'}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def sibling(name):
|
|
16
|
+
spec = importlib.util.spec_from_file_location(name, Path(__file__).with_name(name + '.py'))
|
|
17
|
+
module = importlib.util.module_from_spec(spec)
|
|
18
|
+
spec.loader.exec_module(module)
|
|
19
|
+
return module
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def scrub_text(value):
|
|
23
|
+
for key in ('USERNAME', 'PASSWORD'):
|
|
24
|
+
secret = os.getenv('PRECHECK_DEMO_' + key, '')
|
|
25
|
+
if secret:
|
|
26
|
+
value = value.replace(secret, '[redacted]')
|
|
27
|
+
return EMAIL.sub('[redacted email]', value)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def scrub_tree(value, authenticated=False, allowed=None, key=''):
|
|
31
|
+
allowed = allowed or set()
|
|
32
|
+
if isinstance(value, str):
|
|
33
|
+
clean = scrub_text(value)
|
|
34
|
+
if authenticated and key not in STRUCTURAL and clean not in allowed:
|
|
35
|
+
return '[redacted]'
|
|
36
|
+
return clean
|
|
37
|
+
if isinstance(value, list):
|
|
38
|
+
return [scrub_tree(x, authenticated, allowed, key) for x in value]
|
|
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()}
|
|
43
|
+
return value
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def count_nodes(value):
|
|
47
|
+
if isinstance(value, list):
|
|
48
|
+
return sum(count_nodes(x) for x in value)
|
|
49
|
+
if isinstance(value, dict):
|
|
50
|
+
return int('attributes' in value) + sum(count_nodes(x) for x in value.get('children', []))
|
|
51
|
+
return 0
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def capture(udid, out, timeout):
|
|
55
|
+
result = sibling('dyn-process').run(['maestro', '--device', udid, 'hierarchy'],
|
|
56
|
+
timeout=timeout, grace=1, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
|
|
57
|
+
if result.returncode:
|
|
58
|
+
raise ValueError('Hierarchy driver failed')
|
|
59
|
+
tree = scrub_tree(json.loads(result.stdout.decode('utf-8')))
|
|
60
|
+
sibling('safe_write').write_text(out, json.dumps(tree, ensure_ascii=True))
|
|
61
|
+
return count_nodes(tree)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def main():
|
|
65
|
+
parser = argparse.ArgumentParser()
|
|
66
|
+
parser.add_argument('--udid', required=True)
|
|
67
|
+
parser.add_argument('--out', type=Path, required=True)
|
|
68
|
+
parser.add_argument('--timeout', type=float, default=45)
|
|
69
|
+
args = parser.parse_args()
|
|
70
|
+
try:
|
|
71
|
+
print(capture(args.udid, args.out, args.timeout))
|
|
72
|
+
except (OSError, ValueError, subprocess.SubprocessError):
|
|
73
|
+
print('unread')
|
|
74
|
+
return 1
|
|
75
|
+
return 0
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
if __name__ == '__main__':
|
|
79
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# lib/dyn-signals.sh — one launch repeat of the Phase 6 runner: start the observers,
|
|
3
|
+
# launch the app, wait the window, then read the FOUR launch-health signals and hand
|
|
4
|
+
# them to dyn_launch_verdict (lib/dyn-quorum.sh). Sourced by dynamic-run.sh. Bash 3.2.
|
|
5
|
+
#
|
|
6
|
+
# process alive kill -0 on the PID `simctl launch` printed (simulator apps are
|
|
7
|
+
# host processes).
|
|
8
|
+
# screenshot `simctl io screenshot` + lib/png-uniform.py: a flat frame is a
|
|
9
|
+
# hung splash or a dead process. Unreadable -> "unread".
|
|
10
|
+
# log stream `simctl spawn <udid> log stream --style compact` filtered to the
|
|
11
|
+
# app, started BEFORE launch; a crash / SIGABRT / EXC_BAD_ACCESS /
|
|
12
|
+
# "Terminating app" line, or a new .ips report for the executable in
|
|
13
|
+
# ~/Library/Logs/DiagnosticReports, is "crash". No file -> "unread".
|
|
14
|
+
# accessibility `maestro hierarchy` node count. Maestro missing or timing out ->
|
|
15
|
+
# "unread" (a driver timeout is never a FINDING). A tiny tree is
|
|
16
|
+
# reported as its count; dyn_launch_verdict knows it is degenerate.
|
|
17
|
+
# The app is launched with SIMCTL_CHILD_CFNETWORK_DIAGNOSTICS=3 so the same log file
|
|
18
|
+
# also feeds dyn-hosts-contacted (lib/dyn-hosts.sh).
|
|
19
|
+
|
|
20
|
+
: "${DYN_DRY_RUN:=0}"
|
|
21
|
+
: "${DYN_MAESTRO_TIMEOUT:=45}"
|
|
22
|
+
DYN_LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
23
|
+
|
|
24
|
+
# dyn_with_timeout <secs> <argv…> — run with a wall-clock cap (macOS has no
|
|
25
|
+
# coreutils timeout). Exit 124 on expiry, else the command's status.
|
|
26
|
+
dyn_with_timeout() {
|
|
27
|
+
local secs="$1"; shift
|
|
28
|
+
"$@" & local pid=$! waited=0
|
|
29
|
+
while kill -0 "$pid" 2>/dev/null; do
|
|
30
|
+
if (( waited >= secs )); then kill -9 "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; return 124; fi
|
|
31
|
+
sleep 1; waited=$((waited + 1))
|
|
32
|
+
done
|
|
33
|
+
wait "$pid"
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
DYN_LOG_PID=""
|
|
37
|
+
# dyn_log_start <udid> <executable> <bundle-id> <out-file> — background log stream.
|
|
38
|
+
dyn_log_start() {
|
|
39
|
+
local udid="$1" exe="$2" bid="$3" out="$4"
|
|
40
|
+
if [[ "$DYN_DRY_RUN" == 1 ]]; then dyn_plan "xcrun simctl spawn $udid log stream --style compact --predicate 'process == \"$exe\" OR eventMessage CONTAINS \"$bid\"' > $out &"; return 0; fi
|
|
41
|
+
xcrun simctl spawn "$udid" log stream --style compact \
|
|
42
|
+
--predicate "process == \"$exe\" OR eventMessage CONTAINS \"$bid\" OR (subsystem == \"com.apple.CFNetwork\" AND process == \"$exe\")" \
|
|
43
|
+
> "$out" 2>/dev/null &
|
|
44
|
+
DYN_LOG_PID=$!
|
|
45
|
+
}
|
|
46
|
+
dyn_log_stop() {
|
|
47
|
+
[[ -n "$DYN_LOG_PID" ]] && { kill "$DYN_LOG_PID" 2>/dev/null; wait "$DYN_LOG_PID" 2>/dev/null; }
|
|
48
|
+
DYN_LOG_PID=""
|
|
49
|
+
return 0
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
# dyn_launch <udid> <bundle-id> -> PID (stdout) or "" ; always --terminate-running-process.
|
|
53
|
+
dyn_launch() {
|
|
54
|
+
local udid="$1" bid="$2" out
|
|
55
|
+
if [[ "$DYN_DRY_RUN" == 1 ]]; then dyn_plan "SIMCTL_CHILD_CFNETWORK_DIAGNOSTICS=3 xcrun simctl launch --terminate-running-process $udid $bid"; echo ""; return 0; fi
|
|
56
|
+
out="$(SIMCTL_CHILD_CFNETWORK_DIAGNOSTICS=3 xcrun simctl launch --terminate-running-process "$udid" "$bid" 2>/dev/null)" || { echo ""; return 1; }
|
|
57
|
+
# "com.example.app: 41231"
|
|
58
|
+
printf '%s' "${out##*: }" | tr -dc '0-9'
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
# dyn_signal_process <pid> -> alive | dead | unread
|
|
62
|
+
dyn_signal_process() {
|
|
63
|
+
local pid="${1:-}"
|
|
64
|
+
[[ -n "$pid" ]] || { echo unread; return 0; }
|
|
65
|
+
if kill -0 "$pid" 2>/dev/null; then echo alive; else echo dead; fi
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
# dyn_signal_screenshot <udid> <png-out> -> varied | uniform | unread
|
|
69
|
+
dyn_signal_screenshot() {
|
|
70
|
+
local udid="$1" png="$2" r
|
|
71
|
+
if [[ "$DYN_DRY_RUN" == 1 ]]; then dyn_plan "xcrun simctl io $udid screenshot --type=png $png"; echo unread; return 0; fi
|
|
72
|
+
xcrun simctl io "$udid" screenshot --type=png "$png" >/dev/null 2>&1 || { echo unread; return 0; }
|
|
73
|
+
command -v python3 >/dev/null 2>&1 || { echo unread; return 0; }
|
|
74
|
+
r="$(python3 "$DYN_LIB_DIR/png-uniform.py" "$png" 2>/dev/null)" || { echo unread; return 0; }
|
|
75
|
+
case "$r" in uniform) echo uniform ;; varied*) echo varied ;; *) echo unread ;; esac
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
# dyn_signal_log <log-file> <executable> <since-marker-file> -> clean | crash | unread
|
|
79
|
+
dyn_signal_log() {
|
|
80
|
+
local log="$1" exe="$2" marker="${3:-}" reports=""
|
|
81
|
+
[[ -s "$log" || -f "$log" ]] || { echo unread; return 0; }
|
|
82
|
+
if grep -qE 'SIGABRT|SIGSEGV|SIGBUS|SIGILL|SIGTRAP|EXC_BAD_ACCESS|EXC_CRASH|EXC_BREAKPOINT|Terminating app due to|Fatal error:|fatalError|crashed' "$log" 2>/dev/null; then
|
|
83
|
+
echo crash; return 0
|
|
84
|
+
fi
|
|
85
|
+
if [[ -n "$marker" && -d "$HOME/Library/Logs/DiagnosticReports" ]]; then
|
|
86
|
+
reports="$(find "$HOME/Library/Logs/DiagnosticReports" -maxdepth 1 -name "${exe}-*.ips" -newer "$marker" 2>/dev/null | head -1)"
|
|
87
|
+
[[ -n "$reports" ]] && { echo crash; return 0; }
|
|
88
|
+
fi
|
|
89
|
+
echo clean
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
# dyn_signal_tree <udid> <json-out> -> <node count> | unread
|
|
93
|
+
dyn_signal_tree() {
|
|
94
|
+
local udid="$1" out="$2" n
|
|
95
|
+
if [[ "$DYN_DRY_RUN" == 1 ]]; then dyn_plan "maestro --device $udid hierarchy > $out # one Maestro invocation, one flow"; echo unread; return 0; fi
|
|
96
|
+
command -v maestro >/dev/null 2>&1 || { echo unread; return 0; }
|
|
97
|
+
n="$(python3 -B "$DYN_LIB_DIR/dyn-scrub.py" --udid "$udid" --out "$out" --timeout "$DYN_MAESTRO_TIMEOUT")" || { echo unread; return 0; }
|
|
98
|
+
[[ "$n" =~ ^[0-9]+$ ]] && echo "$n" || echo unread
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
# dyn_repeat <udid> <bundle-id> <executable> <window-secs> <out-dir> <i>
|
|
102
|
+
# -> "<verdict><TAB><detail><TAB><proc>,<shot>,<log>,<tree>" for dyn-launch; files in out-dir.
|
|
103
|
+
dyn_repeat() {
|
|
104
|
+
local udid="$1" bid="$2" exe="$3" window="$4" out="$5" i="$6"
|
|
105
|
+
local marker="$out/marker-$i" log="$out/log-$i.txt" png="$out/launch-$i.png" hier="$out/hierarchy-$i.json"
|
|
106
|
+
local pid proc shot lg tree verdict
|
|
107
|
+
: > "$marker"; : > "$log"
|
|
108
|
+
dyn_log_start "$udid" "$exe" "$bid" "$log"
|
|
109
|
+
pid="$(dyn_launch "$udid" "$bid")"
|
|
110
|
+
[[ -z "${DYN_EXT_DIR:-}" ]] || printf '%s\n' "$pid" > "$DYN_EXT_DIR/pid-$i.txt"
|
|
111
|
+
if [[ "$DYN_DRY_RUN" == 1 ]]; then dyn_plan "sleep $window # observation window, repeat $i"; else sleep "$window"; fi
|
|
112
|
+
proc="$(dyn_signal_process "$pid")"
|
|
113
|
+
shot="$(dyn_signal_screenshot "$udid" "$png")"
|
|
114
|
+
tree="$(dyn_signal_tree "$udid" "$hier")"
|
|
115
|
+
dyn_log_stop
|
|
116
|
+
lg="$(dyn_signal_log "$log" "$exe" "$marker")"
|
|
117
|
+
[[ "$DYN_DRY_RUN" == 1 ]] && lg=unread
|
|
118
|
+
verdict="$(dyn_launch_verdict "$proc" "$shot" "$lg" "$tree")"
|
|
119
|
+
printf '%s\t%s,%s,%s,%s\n' "$verdict" "$proc" "$shot" "$lg" "$tree"
|
|
120
|
+
}
|
|
@@ -5,22 +5,40 @@
|
|
|
5
5
|
# ingestion) so the extraction logic has exactly one implementation.
|
|
6
6
|
|
|
7
7
|
# gd_section_ids <html> -> numeric guideline anchor ids, document order, deduped.
|
|
8
|
-
#
|
|
9
|
-
# (id="1".."5")
|
|
10
|
-
#
|
|
8
|
+
# Sub-sections come out as anchored (id="2.3.3" -> 2.3.3). The five bare category
|
|
9
|
+
# anchors (id="1".."5") come out as "N.0": Apple's own rejection notices cite the
|
|
10
|
+
# category intro prose that way ("Guideline 4.0 - Design", the #1 removal reason in
|
|
11
|
+
# Apple's 2024 transparency report), but the page has no id="4.0" — only the
|
|
12
|
+
# category header's id="4", verified live 2026-09-01. Mapping it here is what lets
|
|
13
|
+
# the intro prose be baselined, fingerprinted and cited like any other section.
|
|
14
|
+
# Anything else with a bare digit id (nav chrome such as id="globalnav-4") has a
|
|
15
|
+
# non-numeric prefix and is not matched.
|
|
11
16
|
gd_section_ids() {
|
|
12
|
-
grep -oE 'id="[1-5](\.[0-9]+)
|
|
17
|
+
grep -oE 'id="[1-5](\.[0-9]+)*"' "$1" 2>/dev/null \
|
|
13
18
|
| sed -E 's/^id="//; s/"$//' \
|
|
19
|
+
| sed -E 's/^([1-5])$/\1.0/' \
|
|
14
20
|
| awk '!seen[$0]++'
|
|
15
21
|
}
|
|
16
22
|
|
|
23
|
+
# gd_anchor_id <section> -> the id attribute that section carries on the live page.
|
|
24
|
+
# "N.0" is our name for a category intro; Apple anchors it as the bare "N". Every
|
|
25
|
+
# other section is its own anchor. Shared by the text helpers and the URL builders
|
|
26
|
+
# so a "#4.0" link (which resolves to nothing) can never be produced.
|
|
27
|
+
gd_anchor_id() {
|
|
28
|
+
case "$1" in
|
|
29
|
+
[1-5].0) printf '%s' "${1%.0}" ;;
|
|
30
|
+
*) printf '%s' "$1" ;;
|
|
31
|
+
esac
|
|
32
|
+
}
|
|
33
|
+
|
|
17
34
|
# _gd_section_raw <html> <id> -> normalized prose for exactly that section, in the
|
|
18
35
|
# ORIGINAL case. Shared by gd_section_text (which lowercases it for fingerprinting)
|
|
19
36
|
# and gd_section_quote (which keeps the case, because a citation has to read like
|
|
20
37
|
# Apple wrote it). Lowercasing moved to the caller: tr and the whitespace squeeze
|
|
21
38
|
# commute, so gd_section_text is byte-identical to before this split.
|
|
22
39
|
_gd_section_raw() {
|
|
23
|
-
local html="$1" want
|
|
40
|
+
local html="$1" want
|
|
41
|
+
want="$(gd_anchor_id "$2")"
|
|
24
42
|
# Replace each opening guideline-anchor tag (e.g. <span id="2.3.3"> or <li id="2.3.3" ...>)
|
|
25
43
|
# with a whole-tag sentinel @@SEC:<id>@@ on its own line, so no partial tag leaks.
|
|
26
44
|
sed -E 's#<[a-zA-Z]+[^>]*id="([1-5](\.[0-9]+)*)"[^>]*>#\'$'\n''@@SEC:\1@@#g' "$html" \
|