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,329 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# dynamic.sh — turn a Phase 6 transcript into findings, and reconcile them with the
|
|
3
|
+
# static scan. Pure text transform: it launches nothing, touches no device, and runs
|
|
4
|
+
# anywhere findings.sh runs (ubuntu CI included). Bash 3.2 compatible: no
|
|
5
|
+
# associative arrays; the catalogue and the reconciliation table are functions.
|
|
6
|
+
#
|
|
7
|
+
# WHY THIS EXISTS
|
|
8
|
+
# ---------------
|
|
9
|
+
# Before Phase 1 the DYNAMIC-PASS / DYNAMIC-FINDING / DYNAMIC-SKIP lines the agent
|
|
10
|
+
# printed never reached findings.sh: no rule_id, absent from --format json and
|
|
11
|
+
# SARIF, no evidence class, unmeasurable. The tier was a narrative running beside
|
|
12
|
+
# the machine-readable pipeline. This script is the bridge, in the same JSONL shape
|
|
13
|
+
# scan.sh writes, with two additions that make runtime evidence honest:
|
|
14
|
+
# * every record says where it came from (runtime_target, build_config), and a
|
|
15
|
+
# Debug/unknown build never clears needs_build_verification (evidence.sh);
|
|
16
|
+
# * a runtime observation that contradicts a static finding can RESOLVE it only
|
|
17
|
+
# when the dynamic check is the COMPLETE test of the same proposition — and
|
|
18
|
+
# RESOLVED is structurally inert (see findings.sh), so the verdict arithmetic
|
|
19
|
+
# in verdict.sh / thresholds.sh is untouched.
|
|
20
|
+
#
|
|
21
|
+
# INPUT GRAMMAR (column 0 only; prose, "Pierre:" lines and indented text are ignored)
|
|
22
|
+
# DYNAMIC-PASS: <guideline> [<rule-id>] — <message>
|
|
23
|
+
# DYNAMIC-FINDING: <guideline> [<rule-id>] — <message>
|
|
24
|
+
# DYNAMIC-SKIP: <guideline> [<rule-id>] — <why it could not be driven>
|
|
25
|
+
# <rule-id> is one of the D-check ids below, optionally suffixed ":<KEY>" for a
|
|
26
|
+
# per-key observation (D4: dyn-permission-prompt:NSCameraUsageDescription). A line
|
|
27
|
+
# without a bracketed id is recorded with an empty rule_id and reconciles with
|
|
28
|
+
# nothing. A FINDING is recorded as WARN: the tier is advisory in Phase 1, and the
|
|
29
|
+
# opt-in blocking channel is Phase 3's job.
|
|
30
|
+
#
|
|
31
|
+
# USAGE
|
|
32
|
+
# dynamic.sh [--transcript FILE|-] [--findings FILE] [--target simulator|device]
|
|
33
|
+
# [--build-config release|debug|unknown] [--format json|jsonl] [--not-run]
|
|
34
|
+
# --findings the static side: scan.sh's --format json envelope, or its raw JSONL.
|
|
35
|
+
# --not-run emit the runtime-not-audited gap record instead of reading a
|
|
36
|
+
# transcript (the tier was not run: no .app / UDID supplied).
|
|
37
|
+
# Exit 64 on a bad argument, 66 on a missing file.
|
|
38
|
+
|
|
39
|
+
set -u
|
|
40
|
+
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
41
|
+
# shellcheck source=findings.sh
|
|
42
|
+
. "$HERE/findings.sh"
|
|
43
|
+
# shellcheck source=evidence.sh
|
|
44
|
+
. "$HERE/evidence.sh"
|
|
45
|
+
|
|
46
|
+
# --- Dynamic-check catalogue ----------------------------------------------------
|
|
47
|
+
# dyn_catalogue -> every D-check id, one per line. dyn-install is D0 (setup), the
|
|
48
|
+
# rest are observations. Counts derived from this list (the gap record) can never
|
|
49
|
+
# disagree with it.
|
|
50
|
+
dyn_catalogue() {
|
|
51
|
+
printf '%s\n' dyn-install dyn-launch dyn-first-screen dyn-paywall-visible \
|
|
52
|
+
dyn-restore-tap dyn-permission-prompt dyn-demo-login dyn-screenshot-parity \
|
|
53
|
+
dyn-dark-mode dyn-dynamic-type dyn-ipad-layout \
|
|
54
|
+
dyn-shipped-bundle dyn-shipped-sdk dyn-shipped-links dyn-hosts-contacted \
|
|
55
|
+
dyn-cpu-idle dyn-capture-indicator dyn-musickit-auth dyn-miniapp-index \
|
|
56
|
+
dyn-miniapp-rating-label dyn-location-timing
|
|
57
|
+
}
|
|
58
|
+
dyn_is_setup() { [[ "${1:-}" == "dyn-install" ]]; }
|
|
59
|
+
|
|
60
|
+
# dyn_rule_confidence <base-id> -> who acts on it. A person: every D-check is about
|
|
61
|
+
# what a reviewer sees in front of them, none is an upload validator. D0 is setup,
|
|
62
|
+
# so its PASS is at most a hint that the bundle was installable.
|
|
63
|
+
# Phase 2 additions: the geometry heuristics (dark mode, Dynamic Type, iPad) are
|
|
64
|
+
# judgment calls — a clipped frame is a hint, not a rejection; hosts contacted vs
|
|
65
|
+
# NSPrivacyTrackingDomains is a reviewer call; the shipped-bundle family reads the
|
|
66
|
+
# INSTALLED product (plist keys, DTXcode, otool -L), which is exactly what the upload
|
|
67
|
+
# validator reads, so those are validator-blocking — and, being runtime evidence, still
|
|
68
|
+
# subject to the build_config guard (a Debug DerivedData bundle establishes nothing).
|
|
69
|
+
dyn_rule_confidence() {
|
|
70
|
+
case "$1" in
|
|
71
|
+
dyn-launch|dyn-first-screen|dyn-paywall-visible|dyn-restore-tap) echo review-risk ;;
|
|
72
|
+
dyn-permission-prompt|dyn-demo-login|dyn-screenshot-parity) echo review-risk ;;
|
|
73
|
+
dyn-hosts-contacted) echo review-risk ;;
|
|
74
|
+
dyn-cpu-idle|dyn-capture-indicator|dyn-miniapp-index|dyn-miniapp-rating-label) echo judgment-call ;;
|
|
75
|
+
dyn-musickit-auth|dyn-location-timing) echo review-risk ;;
|
|
76
|
+
dyn-dark-mode|dyn-dynamic-type|dyn-ipad-layout) echo judgment-call ;;
|
|
77
|
+
dyn-shipped-bundle|dyn-shipped-sdk|dyn-shipped-links) echo validator-blocking ;;
|
|
78
|
+
dyn-install) echo judgment-call ;;
|
|
79
|
+
*) echo "" ;;
|
|
80
|
+
esac
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
# New observation families have no complete static equivalent; they stay standalone.
|
|
84
|
+
# Even manually supplied transcripts must carry an explicit unanimous fresh quorum.
|
|
85
|
+
dyn_extended_kind() {
|
|
86
|
+
local id="$1" kind="$2" msg="$3" observed total
|
|
87
|
+
case "$id" in
|
|
88
|
+
dyn-cpu-idle|dyn-capture-indicator|dyn-musickit-auth|dyn-miniapp-index|dyn-miniapp-rating-label|dyn-location-timing) ;;
|
|
89
|
+
*) printf '%s' "$kind"; return ;;
|
|
90
|
+
esac
|
|
91
|
+
if [[ "$kind" != SKIP ]]; then
|
|
92
|
+
if [[ "$msg" =~ quorum[[:space:]]([1-9][0-9]{0,5})/([1-9][0-9]{0,5})[\;[:space:]] && "$msg" == *'fresh erase verified'* ]]; then
|
|
93
|
+
observed="${BASH_REMATCH[1]}"; total="${BASH_REMATCH[2]}"
|
|
94
|
+
if (( observed >= 3 && observed == total )); then printf '%s' "$kind"; return; fi
|
|
95
|
+
fi
|
|
96
|
+
printf SKIP
|
|
97
|
+
else printf SKIP; fi
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
# --- Reconciliation table -------------------------------------------------------
|
|
101
|
+
# reconcile_map -> JSON array of {dyn, static, complete, keyed}. "complete" means
|
|
102
|
+
# the dynamic check tests the WHOLE proposition the static rule asserts, so a
|
|
103
|
+
# runtime contradiction may RESOLVE it; anything less only downgrades (FAIL→WARN)
|
|
104
|
+
# and annotates, never to PASS. Rationale per row:
|
|
105
|
+
# demo-account ↔ dyn-demo-login: complete. The static rule asks "are working
|
|
106
|
+
# reviewer credentials declared?"; the dynamic check logs in with them. If the
|
|
107
|
+
# login works, the claim "no working demo path" is false in full.
|
|
108
|
+
# usage-description-crosscheck ↔ dyn-permission-prompt: complete PER KEY only
|
|
109
|
+
# (keyed:true). The static rule finds "API used, NS*UsageDescription missing"
|
|
110
|
+
# per key; a prompt observed for THAT key with the declared text is the whole
|
|
111
|
+
# test. A keyless observation (one permission tried) is partial for every key.
|
|
112
|
+
# subscription-links-restore ↔ dyn-restore-tap: partial. The static rule wants
|
|
113
|
+
# Restore + terms + privacy visible on the paywall; a non-inert Restore tap
|
|
114
|
+
# tests one of three links. Never resolves; FAIL→WARN with the observation.
|
|
115
|
+
# Phase 2 — the shipped-bundle family reads the INSTALLED product, executing nothing:
|
|
116
|
+
# usage-description-crosscheck ↔ dyn-shipped-bundle:<KEY>: complete per key,
|
|
117
|
+
# require_key. The installed Info.plist either declares the key or it does not —
|
|
118
|
+
# that is the whole proposition the static grep approximated. A keyless
|
|
119
|
+
# dyn-shipped-bundle line is the drift summary and aims at nothing (require_key):
|
|
120
|
+
# unlike D4, "one permission tried" has no partial reading here.
|
|
121
|
+
# att-usage ↔ dyn-shipped-bundle:NSUserTrackingUsageDescription: the same, for the
|
|
122
|
+
# one key ATT needs (ITMS-90683 reads the installed plist).
|
|
123
|
+
# xcode-sdk-requirement ↔ dyn-shipped-sdk: complete. LastUpgradeCheck was a proxy;
|
|
124
|
+
# DTXcode / DTSDKName in the installed plist are what ITMS-90725 reads. Still
|
|
125
|
+
# runtime evidence: on a Debug/unknown build it only downgrades (simulator build ≠
|
|
126
|
+
# the archive's toolchain), on a release build it resolves.
|
|
127
|
+
# private-api ↔ dyn-shipped-links: partial. otool -L shows linked frameworks (a
|
|
128
|
+
# /System/Library/PrivateFrameworks link is decisive), but the static rule also
|
|
129
|
+
# greps private selectors and deprecated classes, which linkage cannot see.
|
|
130
|
+
# A dyn id may map to SEVERAL static rules (dyn-shipped-bundle above); every mapping is
|
|
131
|
+
# applied, and consumption is tracked per record id so nothing is double-counted.
|
|
132
|
+
reconcile_map() {
|
|
133
|
+
cat <<'JSON'
|
|
134
|
+
[
|
|
135
|
+
{"dyn":"dyn-demo-login", "static":"demo-account", "complete":true, "keyed":false, "require_key":false},
|
|
136
|
+
{"dyn":"dyn-permission-prompt", "static":"usage-description-crosscheck", "complete":true, "keyed":true, "require_key":false},
|
|
137
|
+
{"dyn":"dyn-restore-tap", "static":"subscription-links-restore", "complete":false, "keyed":false, "require_key":false},
|
|
138
|
+
{"dyn":"dyn-shipped-bundle", "static":"usage-description-crosscheck", "complete":true, "keyed":true, "require_key":true},
|
|
139
|
+
{"dyn":"dyn-shipped-bundle", "static":"att-usage", "complete":true, "keyed":true, "require_key":true},
|
|
140
|
+
{"dyn":"dyn-shipped-sdk", "static":"xcode-sdk-requirement", "complete":true, "keyed":false, "require_key":false},
|
|
141
|
+
{"dyn":"dyn-shipped-links", "static":"private-api", "complete":false, "keyed":false, "require_key":false}
|
|
142
|
+
]
|
|
143
|
+
JSON
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
# --- Arguments ------------------------------------------------------------------
|
|
147
|
+
TRANSCRIPT="-" STATIC="" TARGET="" CONFIG="unknown" FORMAT="json" NOT_RUN="false"
|
|
148
|
+
usage_err() { echo "dynamic.sh: $1" >&2; exit 64; }
|
|
149
|
+
while [[ $# -gt 0 ]]; do
|
|
150
|
+
case "$1" in
|
|
151
|
+
--transcript) [[ $# -ge 2 ]] || usage_err "--transcript needs a value"; TRANSCRIPT="$2"; shift 2 ;;
|
|
152
|
+
--findings) [[ $# -ge 2 ]] || usage_err "--findings needs a value"; STATIC="$2"; shift 2 ;;
|
|
153
|
+
--target) [[ $# -ge 2 ]] || usage_err "--target needs a value"; TARGET="$2"; shift 2 ;;
|
|
154
|
+
--build-config) [[ $# -ge 2 ]] || usage_err "--build-config needs a value"; CONFIG="$2"; shift 2 ;;
|
|
155
|
+
--format) [[ $# -ge 2 ]] || usage_err "--format needs a value"; FORMAT="$2"; shift 2 ;;
|
|
156
|
+
--not-run) NOT_RUN="true"; shift ;;
|
|
157
|
+
*) usage_err "unknown option '$1'" ;;
|
|
158
|
+
esac
|
|
159
|
+
done
|
|
160
|
+
case "$TARGET" in ""|simulator|device) ;; *) usage_err "--target must be simulator|device" ;; esac
|
|
161
|
+
case "$CONFIG" in release|debug|unknown) ;; *) usage_err "--build-config must be release|debug|unknown" ;; esac
|
|
162
|
+
case "$FORMAT" in json|jsonl) ;; *) usage_err "--format must be json|jsonl" ;; esac
|
|
163
|
+
if [[ -n "$STATIC" && ! -f "$STATIC" ]]; then echo "dynamic.sh: no such file '$STATIC'" >&2; exit 66; fi
|
|
164
|
+
if [[ "$NOT_RUN" == "false" && "$TRANSCRIPT" != "-" && ! -f "$TRANSCRIPT" ]]; then
|
|
165
|
+
echo "dynamic.sh: no such file '$TRANSCRIPT'" >&2; exit 66
|
|
166
|
+
fi
|
|
167
|
+
|
|
168
|
+
WORK="$(mktemp -d)"; trap 'rm -rf "$WORK"' EXIT
|
|
169
|
+
STATIC_JSONL="$WORK/static.jsonl"; DYN_JSONL="$WORK/dyn.jsonl"; OUT_JSONL="$WORK/out.jsonl"
|
|
170
|
+
: > "$STATIC_JSONL"; : > "$DYN_JSONL"
|
|
171
|
+
|
|
172
|
+
# --- Static side: accept the public envelope or raw JSONL -----------------------
|
|
173
|
+
if [[ -n "$STATIC" ]]; then
|
|
174
|
+
jq -c 'if (type=="object" and has("findings")) then .findings[] else . end' "$STATIC" > "$STATIC_JSONL" \
|
|
175
|
+
|| { echo "dynamic.sh: --findings is not JSON" >&2; exit 65; }
|
|
176
|
+
fi
|
|
177
|
+
|
|
178
|
+
# --- Dynamic side: parse the transcript into records ----------------------------
|
|
179
|
+
FINDINGS_TMP="$DYN_JSONL"
|
|
180
|
+
set_runtime "$TARGET" "$CONFIG"
|
|
181
|
+
|
|
182
|
+
# _trim <string> — strip a trailing CR and surrounding blanks (transcripts get pasted
|
|
183
|
+
# from editors and terminals that disagree about line endings).
|
|
184
|
+
_trim() {
|
|
185
|
+
local v="${1:-}"
|
|
186
|
+
v="${v%$'\r'}"
|
|
187
|
+
while [[ "$v" == *' ' || "$v" == *$'\t' ]]; do v="${v%?}"; done
|
|
188
|
+
while [[ "$v" == ' '* || "$v" == $'\t'* ]]; do v="${v#?}"; done
|
|
189
|
+
printf '%s' "$v"
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
# parse_line <line> — one column-0 DYNAMIC-* line -> one record. Everything else is
|
|
193
|
+
# silently not a record. Fields: <guideline> [<id>] — <message>; each optional past
|
|
194
|
+
# the guideline, any run of blanks between them.
|
|
195
|
+
parse_line() {
|
|
196
|
+
local line kind rest guideline id="" msg sev
|
|
197
|
+
# Column 0 is decided on the raw line: an indented DYNAMIC-* is commentary.
|
|
198
|
+
line="${1%$'\r'}"
|
|
199
|
+
case "$line" in
|
|
200
|
+
DYNAMIC-PASS:*) kind=PASS ;;
|
|
201
|
+
DYNAMIC-FINDING:*) kind=FINDING ;;
|
|
202
|
+
DYNAMIC-SKIP:*) kind=SKIP ;;
|
|
203
|
+
*) return 0 ;;
|
|
204
|
+
esac
|
|
205
|
+
rest="$(_trim "${line#DYNAMIC-*:}")"
|
|
206
|
+
if [[ "$rest" == *' '* ]]; then guideline="${rest%% *}"; rest="$(_trim "${rest#* }")"
|
|
207
|
+
else guideline="$rest"; rest=""; fi
|
|
208
|
+
if [[ "$rest" == \[*\]* ]]; then id="${rest%%]*}"; id="${id#[}"; rest="$(_trim "${rest#*]}")"; fi
|
|
209
|
+
msg="${rest#— }"; msg="${msg#- }"; msg="$(_trim "$msg")"
|
|
210
|
+
if [[ "$(dyn_extended_kind "${id%%:*}" "$kind" "$msg")" == SKIP && "$kind" != SKIP ]]; then
|
|
211
|
+
kind=SKIP; msg="Unverified fresh quorum; observation not accepted: $msg"
|
|
212
|
+
fi
|
|
213
|
+
case "$kind" in PASS) sev=PASS ;; FINDING) sev=WARN ;; SKIP) sev=SKIP ;; esac
|
|
214
|
+
set_rule "$id"
|
|
215
|
+
set_evidence "runtime"
|
|
216
|
+
set_confidence "$(dyn_rule_confidence "${id%%:*}")"
|
|
217
|
+
if [[ -n "$msg" ]]; then _record "$sev" "$guideline $msg"; else _record "$sev" "$guideline"; fi
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if [[ "$NOT_RUN" == "true" ]]; then
|
|
221
|
+
n=0; while IFS= read -r d; do dyn_is_setup "$d" || n=$((n + 1)); done < <(dyn_catalogue)
|
|
222
|
+
set_runtime "" ""
|
|
223
|
+
set_rule "runtime-not-audited"
|
|
224
|
+
_record SKIP "runtime — the Phase 6 dynamic tier did not run (no built simulator .app or booted UDID + bundle id was supplied): $n dynamic checks were not observed. Supply a simulator .app path (or a booted UDID + bundle id) and ask for the dynamic check to close this gap"
|
|
225
|
+
else
|
|
226
|
+
if [[ "$TRANSCRIPT" == "-" ]]; then
|
|
227
|
+
[[ -t 0 ]] && usage_err "no --transcript given and stdin is a terminal (pass --transcript FILE, pipe the transcript in, or use --not-run)"
|
|
228
|
+
src="/dev/stdin"
|
|
229
|
+
else src="$TRANSCRIPT"; fi
|
|
230
|
+
while IFS= read -r line || [[ -n "$line" ]]; do parse_line "$line"; done < "$src"
|
|
231
|
+
fi
|
|
232
|
+
# Detach the buffer: findings.sh reads FINDINGS_TMP, which the linter cannot see.
|
|
233
|
+
# shellcheck disable=SC2034
|
|
234
|
+
FINDINGS_TMP=""
|
|
235
|
+
|
|
236
|
+
# --- Corroborate the caller's build_config against D0 ----------------------------
|
|
237
|
+
# --build-config is a caller assertion; the guard it feeds must not rest on a typo.
|
|
238
|
+
# D0 records the .app's parent directory in its own line. A "release" claim over a
|
|
239
|
+
# transcript whose D0 says Debug-iphonesimulator is degraded to unknown, loudly.
|
|
240
|
+
if [[ "$CONFIG" == "release" ]] \
|
|
241
|
+
&& jq -e 'select(.rule_id=="dyn-install") | select(.message|test("Debug-iphonesimulator"))' "$DYN_JSONL" >/dev/null 2>&1; then
|
|
242
|
+
echo "dynamic.sh: --build-config release contradicted by the D0 line (Debug-iphonesimulator); treating the run as unknown" >&2
|
|
243
|
+
CONFIG="unknown"
|
|
244
|
+
tmp="$WORK/dyn.cfg.jsonl"
|
|
245
|
+
jq -c 'if .build_config != null then .build_config = "unknown" else . end' "$DYN_JSONL" > "$tmp" && mv "$tmp" "$DYN_JSONL"
|
|
246
|
+
fi
|
|
247
|
+
|
|
248
|
+
# --- Reconcile -----------------------------------------------------------------
|
|
249
|
+
# The derivation for a runtime observation stays in evidence.sh: this is the only
|
|
250
|
+
# value jq needs, computed once for the run's build_config.
|
|
251
|
+
RT_NB="$(needs_build_verification runtime validator-blocking "$CONFIG")"
|
|
252
|
+
|
|
253
|
+
jq -n -c \
|
|
254
|
+
--slurpfile static "$STATIC_JSONL" --slurpfile dyn "$DYN_JSONL" \
|
|
255
|
+
--argjson map "$(reconcile_map)" --argjson rt_nb "$RT_NB" \
|
|
256
|
+
--arg target "$TARGET" --arg config "$CONFIG" '
|
|
257
|
+
def tgt: ($target | if .=="" then null else . end);
|
|
258
|
+
def runtime_fields: {runtime_target:tgt, build_config:$config};
|
|
259
|
+
def obs_text($d): ($d.message | sub("^[^ ]+ ?"; ""));
|
|
260
|
+
# Every aimed observation is folded into the message — the winner decides the
|
|
261
|
+
# branch, but no observation (or screenshot reference) is ever dropped.
|
|
262
|
+
def fold($a): " · runtime: " + ([$a[] | obs_text(.)] | join("; "));
|
|
263
|
+
# confirm: same severity, evidence runtime. The qualifier can only be CLEARED by
|
|
264
|
+
# a release run, never raised: an already-established claim (manifest evidence)
|
|
265
|
+
# stays established.
|
|
266
|
+
def confirm($c; $a): $c + runtime_fields
|
|
267
|
+
+ {evidence:"runtime",
|
|
268
|
+
needs_build_verification:($c.needs_build_verification and $rt_nb),
|
|
269
|
+
message:($c.message + fold($a))};
|
|
270
|
+
# resolve: withdrawn by a complete runtime test; inert downstream.
|
|
271
|
+
def resolve($c; $a): $c + runtime_fields
|
|
272
|
+
+ {severity:"RESOLVED", resolved_by:"runtime", evidence:"runtime",
|
|
273
|
+
needs_build_verification:false, message:($c.message + fold($a))};
|
|
274
|
+
# downgrade: FAIL→WARN only, evidence and qualifier untouched, observation appended.
|
|
275
|
+
def downgrade($c; $a; $why): $c + runtime_fields
|
|
276
|
+
+ {severity:(if $c.severity=="FAIL" then "WARN" else $c.severity end),
|
|
277
|
+
message:($c.message + fold($a) + $why)};
|
|
278
|
+
# A per-key id is free text an agent typed. Only a well-formed key may aim at a
|
|
279
|
+
# static record: at most one colon, and a plist-key-shaped token (letters, digits,
|
|
280
|
+
# underscore, at least 5 characters). Anything else aims at nothing.
|
|
281
|
+
def key_ok($k): ($k == null) or ($k | test("^[A-Za-z][A-Za-z0-9_]{4,}$"));
|
|
282
|
+
def complete($d): ($d._m.complete and (($d._m.keyed|not) or $d._key!=null));
|
|
283
|
+
# For one static record, the observations aimed at it. A key must match as a whole
|
|
284
|
+
# token of the message, never as a bare substring.
|
|
285
|
+
def aimed($c; $mapped): [$mapped[] | select(._m.static==$c.rule_id)
|
|
286
|
+
| . as $d | select($d._key==null
|
|
287
|
+
or ($c.message|test("(^|[^A-Za-z0-9_])" + $d._key + "([^A-Za-z0-9_]|$)")))];
|
|
288
|
+
def reconcile_one($c; $mapped):
|
|
289
|
+
aimed($c; $mapped) as $a
|
|
290
|
+
| if ($a|length)==0 then {rec:$c, confirmed:0, resolved:0, used:[]}
|
|
291
|
+
elif ($c.severity!="FAIL" and $c.severity!="WARN") or $c.suppressed then
|
|
292
|
+
{rec:$c, confirmed:0, resolved:0, used:[]}
|
|
293
|
+
elif ([$a[]|select(.severity=="WARN")]|length)>0 then
|
|
294
|
+
{rec:confirm($c; $a), confirmed:1, resolved:0, used:[$a[].id]}
|
|
295
|
+
else ([$a[]|select(.severity=="PASS")][0]) as $d
|
|
296
|
+
| if complete($d) and (($c.needs_build_verification|not) or $config=="release") then
|
|
297
|
+
{rec:resolve($c; $a), confirmed:0, resolved:1, used:[$a[].id]}
|
|
298
|
+
elif complete($d) then
|
|
299
|
+
{rec:downgrade($c; $a; " (observed on a " + $config + " build; does not establish the shipping archive, so not resolved)"),
|
|
300
|
+
confirmed:0, resolved:0, used:[$a[].id]}
|
|
301
|
+
else
|
|
302
|
+
{rec:downgrade($c; $a; " (partial check; the static claim is wider than what was observed)"),
|
|
303
|
+
confirmed:0, resolved:0, used:[$a[].id]}
|
|
304
|
+
end
|
|
305
|
+
end;
|
|
306
|
+
($dyn | map(. + {_base:(.rule_id|split(":")[0]),
|
|
307
|
+
_key:(.rule_id|split(":") | if length==2 then .[1] elif length>2 then "" else null end)})) as $dyn
|
|
308
|
+
# Observations that may touch a static record: mapped, non-SKIP, well-formed key.
|
|
309
|
+
# One entry per (observation, mapping) pair: a dyn id mapped to several static
|
|
310
|
+
# rules aims at each of them. A mapping with require_key ignores keyless lines.
|
|
311
|
+
| ([$dyn[] | select(.severity!="SKIP") | select(key_ok(._key))
|
|
312
|
+
| . as $d | $map[] | select(.dyn==$d._base) | select((.require_key|not) or $d._key!=null)
|
|
313
|
+
| $d + {_m:.}]) as $mapped
|
|
314
|
+
| ($static | map(reconcile_one(.; $mapped))) as $r
|
|
315
|
+
# Consumption is tracked per RECORD (its id), so two lines with one rule id are
|
|
316
|
+
# never conflated: each is either folded into a static record or kept standalone.
|
|
317
|
+
| ([$r[].used[]] | unique) as $used
|
|
318
|
+
| ($dyn | map(select((.id as $id | $used | index($id)) | not)) | map(del(._base,._key))) as $standalone
|
|
319
|
+
| {records:([$r[].rec] + $standalone),
|
|
320
|
+
stats:{observed:([$dyn[]|select(.severity!="SKIP")]|length),
|
|
321
|
+
resolved:([$r[].resolved]|add // 0),
|
|
322
|
+
confirmed:([$r[].confirmed]|add // 0)}}
|
|
323
|
+
' > "$WORK/reconciled.json" || { echo "dynamic.sh: reconciliation failed" >&2; exit 70; }
|
|
324
|
+
|
|
325
|
+
jq -c '.records[]' "$WORK/reconciled.json" > "$OUT_JSONL"
|
|
326
|
+
STATS="$(jq -c '.stats' "$WORK/reconciled.json")"
|
|
327
|
+
|
|
328
|
+
if [[ "$FORMAT" == "jsonl" ]]; then cat "$OUT_JSONL"; exit 0; fi
|
|
329
|
+
FINDINGS_TMP="$OUT_JSONL" render_json | jq --argjson rt "$STATS" '.summary.runtime = $rt'
|
|
@@ -24,8 +24,21 @@
|
|
|
24
24
|
# Consumed by tests (vocabulary and completeness checks) and by rules_with_evidence,
|
|
25
25
|
# across a `source` boundary the linter cannot follow — hence the disable below.
|
|
26
26
|
# shellcheck disable=SC2034
|
|
27
|
-
# Evidence classes
|
|
28
|
-
#
|
|
27
|
+
# Evidence classes. "Strength" is how faithfully the artifact represents what
|
|
28
|
+
# actually ships:
|
|
29
|
+
# runtime an observation of the RUNNING app (Phase 6 dynamic tier). Not a
|
|
30
|
+
# proxy for shipping behaviour but the behaviour itself — for the
|
|
31
|
+
# binary that was run. Two caveats, both load-bearing:
|
|
32
|
+
# (a) the list below is NOT a single axis of strength. `metadata`
|
|
33
|
+
# is about the store listing, `runtime` is about the binary;
|
|
34
|
+
# neither can establish the other's claims. Within the
|
|
35
|
+
# repo-read classes the order is strongest -> weakest.
|
|
36
|
+
# (b) simulator != archive. A simulator build differs in
|
|
37
|
+
# architecture, in StoreKit (no products under a plain
|
|
38
|
+
# launch), in `#if targetEnvironment(simulator)` branches and
|
|
39
|
+
# usually in configuration (Debug from DerivedData). So a
|
|
40
|
+
# runtime observation only clears needs_build_verification
|
|
41
|
+
# when it came from a release build_config; see below.
|
|
29
42
|
# metadata fastlane/metadata/** — uploaded to App Store Connect verbatim.
|
|
30
43
|
# manifest Info.plist, *.entitlements, PrivacyInfo.xcprivacy — ship as authored.
|
|
31
44
|
# resource String Catalogs, screenshot assets — shipped/uploaded files.
|
|
@@ -33,7 +46,7 @@
|
|
|
33
46
|
# so a repo-level read is a proxy for what the archive was built with.
|
|
34
47
|
# source .swift/.m/.mm/.h greps — the weakest: presence in a file is not
|
|
35
48
|
# proof of presence in the shipping binary.
|
|
36
|
-
EVIDENCE_CLASSES="metadata manifest resource build-setting source"
|
|
49
|
+
EVIDENCE_CLASSES="runtime metadata manifest resource build-setting source"
|
|
37
50
|
|
|
38
51
|
# Confidence levels — who acts on the finding, and how deterministically:
|
|
39
52
|
# validator-blocking Apple's automated validation (upload or App Store Connect)
|
|
@@ -55,6 +68,9 @@ GUIDELINES_BASE_URL="https://developer.apple.com/app-store/review/guidelines/"
|
|
|
55
68
|
# plist read was. A rule may refine this for one finding with set_evidence.
|
|
56
69
|
rule_evidence() {
|
|
57
70
|
case "$1" in
|
|
71
|
+
release-notes-specificity|apple-endorsement-claims ) echo metadata ;;
|
|
72
|
+
device-restart-instructions|browser-engine|intent-handler-parity|call-filter-controls|face-authentication|document-browser-access|extension-bundle-parity|matter-extension|extension-advertising|ar-integration-depth|companion-app-required|game-center-id-sharing|miniapp-native-bridge ) echo source ;;
|
|
73
|
+
metadata-emoji ) echo resource ;;
|
|
58
74
|
# --- metadata: read from fastlane/metadata/**, uploaded to ASC verbatim ---
|
|
59
75
|
competitor-mentions|metadata-char-limits|locale-metadata-parity) echo metadata ;;
|
|
60
76
|
subscription-eula-metadata|support-privacy-url|placeholder-metadata) echo metadata ;;
|
|
@@ -84,7 +100,7 @@ rule_evidence() {
|
|
|
84
100
|
executable-code-download|crypto-wallet-mining|webview-wrapper|remote-desktop) echo source ;;
|
|
85
101
|
account-no-delete|mdm|permission-priming-cta|paywall-trial-emphasis) echo source ;;
|
|
86
102
|
ai-provider-consent|paywall-urgency|rating-sentiment-gate|forced-login) echo source ;;
|
|
87
|
-
push-marketing-optout) echo source ;;
|
|
103
|
+
push-marketing-optout|ipv4-literal) echo source ;;
|
|
88
104
|
|
|
89
105
|
*) echo "" ;;
|
|
90
106
|
esac
|
|
@@ -97,6 +113,7 @@ rule_evidence() {
|
|
|
97
113
|
# a heuristic must never be graded above judgment-call.
|
|
98
114
|
rule_confidence() {
|
|
99
115
|
case "$1" in
|
|
116
|
+
release-notes-specificity|device-restart-instructions|browser-engine|intent-handler-parity|call-filter-controls|face-authentication|document-browser-access|extension-bundle-parity|matter-extension|extension-advertising|ar-integration-depth|companion-app-required|game-center-id-sharing|metadata-emoji|miniapp-native-bridge|apple-endorsement-claims ) echo judgment-call ;;
|
|
100
117
|
# --- validator-blocking: Apple's machinery refuses the build or the submission ---
|
|
101
118
|
# Missing purpose string / required-reason declaration / private API -> upload
|
|
102
119
|
# validation. Metadata limits, missing localized metadata, missing screenshots,
|
|
@@ -116,6 +133,9 @@ rule_confidence() {
|
|
|
116
133
|
health-icloud-sync|vpn-networkextension|demo-account|executable-code-download) echo review-risk ;;
|
|
117
134
|
background-modes-unused|safari-extension|account-no-delete) echo review-risk ;;
|
|
118
135
|
kids-ads-analytics|realmoney-gambling|trial-disclosure|autorenew-disclosure) echo review-risk ;;
|
|
136
|
+
# 2.5.5: App Review runs on an IPv6-only NAT64 network. Nothing at upload checks
|
|
137
|
+
# for IPv4 literals; the app simply fails to connect in front of a reviewer.
|
|
138
|
+
ipv4-literal) echo review-risk ;;
|
|
119
139
|
|
|
120
140
|
# --- judgment-call: heuristic signal, false positives expected ---
|
|
121
141
|
min-functionality-nav|crypto-wallet-mining|webview-wrapper|remote-desktop) echo judgment-call ;;
|
|
@@ -133,7 +153,7 @@ rule_confidence() {
|
|
|
133
153
|
esac
|
|
134
154
|
}
|
|
135
155
|
|
|
136
|
-
# needs_build_verification <evidence> <confidence> -> "true" | "false"
|
|
156
|
+
# needs_build_verification <evidence> <confidence> [<build_config>] -> "true" | "false"
|
|
137
157
|
#
|
|
138
158
|
# DERIVED, never stored — so it cannot drift out of sync with the two catalogues.
|
|
139
159
|
# A validator-blocking claim is only established when the evidence reflects what
|
|
@@ -141,22 +161,31 @@ rule_confidence() {
|
|
|
141
161
|
# same finding means "this WILL block the upload if it ships as-is" — true and
|
|
142
162
|
# actionable, but not yet confirmed. Non-validator findings never carry the
|
|
143
163
|
# qualifier: a human reviewer looks at the running app either way.
|
|
164
|
+
#
|
|
165
|
+
# build_config (release|debug|unknown, default unknown) matters ONLY for `runtime`:
|
|
166
|
+
# a runtime observation of a Release build establishes the claim; one of a Debug
|
|
167
|
+
# or unknown build does not (see the class comment: simulator != archive). This is
|
|
168
|
+
# the guard the whole dynamic tier rests on — a Debug DerivedData .app observed on
|
|
169
|
+
# a simulator must never clear the qualifier. All pre-existing two-argument calls
|
|
170
|
+
# keep their behaviour: the third argument is ignored for the static classes.
|
|
144
171
|
needs_build_verification() {
|
|
145
|
-
local ev="${1:-}" cf="${2:-}"
|
|
172
|
+
local ev="${1:-}" cf="${2:-}" cfg="${3:-unknown}"
|
|
146
173
|
[[ "$cf" == "validator-blocking" ]] || { echo false; return; }
|
|
147
174
|
case "$ev" in
|
|
148
175
|
source|build-setting) echo true ;;
|
|
176
|
+
runtime) [[ "$cfg" == "release" ]] && echo false || echo true ;;
|
|
149
177
|
*) echo false ;;
|
|
150
178
|
esac
|
|
151
179
|
}
|
|
152
180
|
|
|
153
|
-
# evidence_label <evidence> <confidence> -> the one-line
|
|
154
|
-
# when the rule is unclassified (an unlabelled finding is
|
|
181
|
+
# evidence_label <evidence> <confidence> [<build_config>] -> the one-line
|
|
182
|
+
# human-readable tag, or "" when the rule is unclassified (an unlabelled finding is
|
|
183
|
+
# honest; a guessed one is not).
|
|
155
184
|
evidence_label() {
|
|
156
|
-
local ev="${1:-}" cf="${2:-}"
|
|
185
|
+
local ev="${1:-}" cf="${2:-}" cfg="${3:-unknown}"
|
|
157
186
|
[[ -n "$ev" && -n "$cf" ]] || { echo ""; return; }
|
|
158
187
|
local out="evidence: $ev · $cf"
|
|
159
|
-
[[ "$(needs_build_verification "$ev" "$cf")" == "true" ]] && out+=" · needs build verification"
|
|
188
|
+
[[ "$(needs_build_verification "$ev" "$cf" "$cfg")" == "true" ]] && out+=" · needs build verification"
|
|
160
189
|
echo "$out"
|
|
161
190
|
}
|
|
162
191
|
|
|
@@ -165,10 +194,11 @@ evidence_label() {
|
|
|
165
194
|
# .precheck-ignore (a signed acknowledgment, counted as suppressed, never erased from
|
|
166
195
|
# not_audited). It establishes nothing, so it carries no evidence class or confidence
|
|
167
196
|
# and sits outside the catalogue and its completeness test. Convention: the id ends
|
|
168
|
-
# in "-not-audited". Today: store-listing-not-audited.
|
|
197
|
+
# in "-not-audited". Today: store-listing-not-audited (scan.sh) and
|
|
198
|
+
# runtime-not-audited (dynamic.sh, when the Phase 6 tier was not run).
|
|
169
199
|
is_gap_record() { [[ "${1:-}" == *-not-audited ]]; }
|
|
170
200
|
|
|
171
|
-
# rules_with_evidence <class> -> the catalogued rule ids in that evidence class, one
|
|
201
|
+
# rules_with_evidence <class> [last-section] -> the catalogued rule ids in that evidence class, one
|
|
172
202
|
# per line. Derived by asking rule_evidence about every slug in the findings.sh
|
|
173
203
|
# catalogue, so it can never disagree with the classification it reports on. Used to
|
|
174
204
|
# tell the user how many checks a missing artifact actually cost them, rather than
|
|
@@ -179,7 +209,7 @@ rules_with_evidence() {
|
|
|
179
209
|
command -v rule_slug >/dev/null 2>&1 || return 0
|
|
180
210
|
while IFS= read -r slug; do
|
|
181
211
|
[[ "$(rule_evidence "$slug")" == "$want" ]] && echo "$slug"
|
|
182
|
-
done < <(catalogue_slugs)
|
|
212
|
+
done < <(catalogue_slugs "${2:-}")
|
|
183
213
|
return 0
|
|
184
214
|
}
|
|
185
215
|
|
|
@@ -188,9 +218,10 @@ rules_with_evidence() {
|
|
|
188
218
|
# edited when a section is added — the hardcoded 53 this replaced was already wrong
|
|
189
219
|
# the day §54 landed.
|
|
190
220
|
catalogue_slugs() {
|
|
191
|
-
local n=1 slug
|
|
221
|
+
local n=1 slug limit="${1:-}"
|
|
192
222
|
command -v rule_slug >/dev/null 2>&1 || return 0
|
|
193
223
|
while :; do
|
|
224
|
+
[[ -z "$limit" || "$n" -le "$limit" ]] || break
|
|
194
225
|
slug="$(rule_slug "$n")"
|
|
195
226
|
[[ -n "$slug" ]] || break
|
|
196
227
|
echo "$slug"; n=$((n + 1))
|
|
@@ -201,10 +232,13 @@ catalogue_slugs() {
|
|
|
201
232
|
# guideline_url <guideline-number> -> deep link to that section, or "" if the
|
|
202
233
|
# token is not a guideline number. Apple anchors each section by its bare number
|
|
203
234
|
# (id="5.1.1"), so the link is derivable; parenthetical suffixes like 5.1.1(v)
|
|
204
|
-
# and 3.1.1(a) are not anchors and are trimmed to their numeric stem.
|
|
235
|
+
# and 3.1.1(a) are not anchors and are trimmed to their numeric stem. A category
|
|
236
|
+
# intro ("4.0", Apple's own name for the Design intro prose) is anchored as the bare
|
|
237
|
+
# category id="4" — the page has no id="4.0" — so it maps to "#4".
|
|
205
238
|
guideline_url() {
|
|
206
239
|
local g="${1:-}" stem
|
|
207
240
|
stem="$(printf '%s' "$g" | sed -E 's/\(.*$//')"
|
|
208
241
|
[[ "$stem" =~ ^[1-5](\.[0-9]+)+$ ]] || { echo ""; return; }
|
|
242
|
+
case "$stem" in [1-5].0) stem="${stem%.0}" ;; esac
|
|
209
243
|
echo "${GUIDELINES_BASE_URL}#${stem}"
|
|
210
244
|
}
|
|
@@ -33,6 +33,15 @@ rule_slug() {
|
|
|
33
33
|
49) echo rating-sentiment-gate ;; 50) echo forced-login ;;
|
|
34
34
|
51) echo push-marketing-optout ;; 52) echo xcode-sdk-requirement ;;
|
|
35
35
|
53) echo subscription-eula-metadata ;; 54) echo saturated-category ;;
|
|
36
|
+
55) echo ipv4-literal ;;
|
|
37
|
+
56) echo release-notes-specificity ;; 57) echo device-restart-instructions ;;
|
|
38
|
+
58) echo browser-engine ;; 59) echo intent-handler-parity ;;
|
|
39
|
+
60) echo call-filter-controls ;; 61) echo face-authentication ;;
|
|
40
|
+
62) echo document-browser-access ;; 63) echo extension-bundle-parity ;;
|
|
41
|
+
64) echo matter-extension ;; 65) echo extension-advertising ;;
|
|
42
|
+
66) echo ar-integration-depth ;; 67) echo companion-app-required ;;
|
|
43
|
+
68) echo game-center-id-sharing ;; 69) echo metadata-emoji ;;
|
|
44
|
+
70) echo miniapp-native-bridge ;; 71) echo apple-endorsement-claims ;;
|
|
36
45
|
*) echo "" ;;
|
|
37
46
|
esac
|
|
38
47
|
}
|
|
@@ -76,37 +85,89 @@ _confidence_of() {
|
|
|
76
85
|
# violation ("this blocks the upload if it ships as-is"), so it is meaningless on a
|
|
77
86
|
# PASS: nothing is being claimed against the build. Evidence and confidence stay on
|
|
78
87
|
# a PASS — they still say how the rule reached its conclusion — but the qualifier
|
|
79
|
-
# does not.
|
|
88
|
+
# does not. For runtime evidence the run's build_config decides (evidence.sh).
|
|
80
89
|
_needs_build_of() {
|
|
81
|
-
# PASS asserts no violation; SKIP asserts nothing at all
|
|
82
|
-
# to confirm a claim it
|
|
83
|
-
case "${1:-}" in PASS|SKIP) printf 'false'; return ;; esac
|
|
90
|
+
# PASS asserts no violation; SKIP asserts nothing at all; RESOLVED has been
|
|
91
|
+
# withdrawn. None can need a build to confirm a claim it no longer makes.
|
|
92
|
+
case "${1:-}" in PASS|SKIP|RESOLVED) printf 'false'; return ;; esac
|
|
84
93
|
command -v needs_build_verification >/dev/null 2>&1 \
|
|
85
|
-
&& needs_build_verification "$(_evidence_of)" "$(_confidence_of)" || printf 'false'
|
|
94
|
+
&& needs_build_verification "$(_evidence_of)" "$(_confidence_of)" "${_BUILD_CONFIG:-unknown}" || printf 'false'
|
|
86
95
|
}
|
|
87
96
|
_guideline_url_of() {
|
|
88
97
|
command -v guideline_url >/dev/null 2>&1 && guideline_url "$1" || printf ''
|
|
89
98
|
}
|
|
90
99
|
|
|
91
|
-
|
|
100
|
+
# --- Runtime provenance (Phase 6 dynamic tier, via dynamic.sh) -------------------
|
|
101
|
+
# Run-wide, not per rule, so set_rule does not clear them. Empty means "no runtime
|
|
102
|
+
# observation touched this record" and renders as null. A SKIP observed nothing, so
|
|
103
|
+
# it never carries a target or a build config (see _runtime_field_of).
|
|
104
|
+
: "${_RUNTIME_TARGET:=}"
|
|
105
|
+
: "${_BUILD_CONFIG:=}"
|
|
106
|
+
: "${_RESOLVED_BY:=}"
|
|
107
|
+
# set_runtime <target|""> <build_config|""> — declare where the observations come from.
|
|
108
|
+
set_runtime() { _RUNTIME_TARGET="${1:-}"; _BUILD_CONFIG="${2:-}"; }
|
|
109
|
+
_runtime_field_of() { # <severity> <value>
|
|
110
|
+
[[ "${1:-}" == "SKIP" ]] && { printf ''; return; }
|
|
111
|
+
printf '%s' "${2:-}"
|
|
112
|
+
}
|
|
92
113
|
|
|
93
|
-
#
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
114
|
+
# _finding_id <rule> <file> <line> <message> — a stable identity for one finding:
|
|
115
|
+
# the first 16 hex digits of sha256 over the four fields. Lets a later run (or the
|
|
116
|
+
# dynamic tier's reconciliation) refer to "this finding" without re-matching text.
|
|
117
|
+
# The message is part of it on purpose: a rewritten message is a different claim.
|
|
118
|
+
# The one deliberate exception: dynamic.sh reconciliation APPENDS a runtime
|
|
119
|
+
# observation to a static record's message and keeps the original id, so the id
|
|
120
|
+
# stays a handle for the same finding across the static and reconciled outputs.
|
|
121
|
+
# The hasher is resolved once at source time (this runs for every record).
|
|
122
|
+
if command -v shasum >/dev/null 2>&1; then _HASH_CMD="shasum -a 256"
|
|
123
|
+
elif command -v sha256sum >/dev/null 2>&1; then _HASH_CMD="sha256sum"
|
|
124
|
+
else _HASH_CMD=""; fi
|
|
125
|
+
_finding_id() {
|
|
126
|
+
[[ -n "$_HASH_CMD" ]] || { printf ''; return; }
|
|
127
|
+
local key="${1:-}|${2:-}|${3:-}|${4:-}" out
|
|
128
|
+
out="$(printf '%s' "$key" | $_HASH_CMD)"
|
|
129
|
+
printf '%s' "${out:0:16}"
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
# _emit <severity> <message> <file> <line> <suppressed:true|false>
|
|
133
|
+
# The single writer of the JSONL shape; _record and _record_suppressed wrap it.
|
|
134
|
+
# Severity is one of FAIL / WARN / PASS / SKIP / RESOLVED. RESOLVED (set only by
|
|
135
|
+
# dynamic.sh reconciliation) is structurally inert: render_json, sarif.sh and
|
|
136
|
+
# verdict.sh select by string equality on the other four, so a RESOLVED record is
|
|
137
|
+
# kept for the reader and counted by nothing. It is NOT suppressed:true — that
|
|
138
|
+
# field means a human signed for the finding in .precheck-ignore.
|
|
139
|
+
_emit() {
|
|
140
|
+
local sev="$1" msg="$2" file="${3:-}" line="${4:-}" sup="${5:-false}" guideline
|
|
97
141
|
guideline="$(printf '%s' "$msg" | awk '{print $1}')"
|
|
98
142
|
jq -nc --arg r "$_CURRENT_RULE" --arg s "$sev" --arg g "$guideline" \
|
|
99
143
|
--arg m "$msg" --arg f "$file" --arg l "$line" \
|
|
144
|
+
--arg id "$(_finding_id "$_CURRENT_RULE" "$file" "$line" "$msg")" \
|
|
100
145
|
--arg ev "$(_evidence_of "$sev")" --arg cf "$(_confidence_of "$sev")" \
|
|
101
146
|
--arg nb "$(_needs_build_of "$sev")" --arg gu "$(_guideline_url_of "$guideline")" \
|
|
102
|
-
|
|
147
|
+
--arg rb "$(_runtime_field_of "$sev" "$_RESOLVED_BY")" \
|
|
148
|
+
--arg rt "$(_runtime_field_of "$sev" "$_RUNTIME_TARGET")" \
|
|
149
|
+
--arg bc "$(_runtime_field_of "$sev" "$_BUILD_CONFIG")" \
|
|
150
|
+
--argjson sup "$sup" \
|
|
151
|
+
'{id:(if $id=="" then null else $id end),
|
|
152
|
+
rule_id:$r, severity:$s, guideline:$g, message:$m,
|
|
103
153
|
file:(if $f=="" then null else $f end),
|
|
104
154
|
line:(if $l=="" then null else ($l|tonumber) end),
|
|
105
155
|
evidence:(if $ev=="" then null else $ev end),
|
|
106
156
|
confidence:(if $cf=="" then null else $cf end),
|
|
107
157
|
needs_build_verification:($nb=="true"),
|
|
108
158
|
guideline_url:(if $gu=="" then null else $gu end),
|
|
109
|
-
|
|
159
|
+
resolved_by:(if $rb=="" then null else $rb end),
|
|
160
|
+
runtime_target:(if $rt=="" then null else $rt end),
|
|
161
|
+
build_config:(if $bc=="" then null else $bc end),
|
|
162
|
+
suppressed:$sup}' >> "$FINDINGS_TMP"
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
: "${FINDINGS_TMP:=}"
|
|
166
|
+
|
|
167
|
+
# _record <severity> <message> [<file>] [<line>]
|
|
168
|
+
_record() {
|
|
169
|
+
[[ -z "$FINDINGS_TMP" ]] && return 0
|
|
170
|
+
_emit "$1" "$2" "${3:-}" "${4:-}" false
|
|
110
171
|
}
|
|
111
172
|
|
|
112
173
|
: "${_SUPPRESSED_COUNT:=0}"
|
|
@@ -115,20 +176,7 @@ _record() {
|
|
|
115
176
|
# Same JSONL record as _record but suppressed:true, and bumps the counter.
|
|
116
177
|
_record_suppressed() {
|
|
117
178
|
[[ -z "$FINDINGS_TMP" ]] && { _SUPPRESSED_COUNT=$((_SUPPRESSED_COUNT + 1)); return 0; }
|
|
118
|
-
|
|
119
|
-
guideline="$(printf '%s' "$msg" | awk '{print $1}')"
|
|
120
|
-
jq -nc --arg r "$_CURRENT_RULE" --arg s "$sev" --arg g "$guideline" \
|
|
121
|
-
--arg m "$msg" --arg f "$file" --arg l "$line" \
|
|
122
|
-
--arg ev "$(_evidence_of "$sev")" --arg cf "$(_confidence_of "$sev")" \
|
|
123
|
-
--arg nb "$(_needs_build_of "$sev")" --arg gu "$(_guideline_url_of "$guideline")" \
|
|
124
|
-
'{rule_id:$r, severity:$s, guideline:$g, message:$m,
|
|
125
|
-
file:(if $f=="" then null else $f end),
|
|
126
|
-
line:(if $l=="" then null else ($l|tonumber) end),
|
|
127
|
-
evidence:(if $ev=="" then null else $ev end),
|
|
128
|
-
confidence:(if $cf=="" then null else $cf end),
|
|
129
|
-
needs_build_verification:($nb=="true"),
|
|
130
|
-
guideline_url:(if $gu=="" then null else $gu end),
|
|
131
|
-
suppressed:true}' >> "$FINDINGS_TMP"
|
|
179
|
+
_emit "$1" "$2" "${3:-}" "${4:-}" true
|
|
132
180
|
_SUPPRESSED_COUNT=$((_SUPPRESSED_COUNT + 1))
|
|
133
181
|
}
|
|
134
182
|
|
|
@@ -153,6 +201,8 @@ render_json() {
|
|
|
153
201
|
| ($live|map(select(.severity=="FAIL"))|length) as $f
|
|
154
202
|
| ($live|map(select(.severity=="WARN"))|length) as $w
|
|
155
203
|
| ($live|map(select(.severity=="PASS"))|length) as $p
|
|
204
|
+
# RESOLVED (dynamic.sh) matches none of the four selectors below and so is
|
|
205
|
+
# counted by nothing — that inertness is asserted by tests, not assumed.
|
|
156
206
|
# not_audited counts EVERY SKIP, suppressed ones included: acknowledging a gap
|
|
157
207
|
# in .precheck-ignore signs it, it does not close it. (suppressed counts it too —
|
|
158
208
|
# two different questions: "was it examined?" and "who took responsibility?")
|