appstore-precheck 1.20.2 → 1.23.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 +55 -0
- package/README.md +48 -8
- package/bin/cli.js +11 -1
- package/package.json +2 -2
- package/skills/appstore-precheck/SKILL.md +20 -14
- package/skills/appstore-precheck/guidelines-baseline.json +10 -3
- package/skills/appstore-precheck/guidelines-fingerprints.json +243 -339
- package/skills/appstore-precheck/references/methodology.md +67 -1
- package/skills/appstore-precheck/references/pierre-deep-review.md +19 -8
- package/skills/appstore-precheck/references/screenshot-vision-review.md +1 -0
- package/skills/appstore-precheck/references/typesafe.md +2 -2
- package/skills/appstore-precheck/scripts/evidence.sh +13 -4
- package/skills/appstore-precheck/scripts/findings.sh +17 -3
- package/skills/appstore-precheck/scripts/lib/coverage-sections.py +8 -5
- package/skills/appstore-precheck/scripts/lib/scan-artifact.sh +46 -0
- package/skills/appstore-precheck/scripts/lib/scan-guidelines.sh +7 -1
- package/skills/appstore-precheck/scripts/lib/static-guidelines.py +155 -4
- package/skills/appstore-precheck/scripts/scan.sh +69 -15
- package/skills/appstore-precheck/scripts/suppress.sh +35 -2
|
@@ -17,6 +17,7 @@ FORMAT="text"
|
|
|
17
17
|
SCAN_DIR=""
|
|
18
18
|
OPT_NO_RUNTIME=0 OPT_DEMO=0 OPT_ASC_VERSION="" OPT_ASC_INFO=""
|
|
19
19
|
OPT_BUILD=0 OPT_APP="" OPT_METADATA=0 OPT_ASC="" OPT_URLS=0 OPT_DYN_BLOCK=0 OPT_DRY=0 OPT_OUT="" OPT_TEMP="" OPT_RAN_OK=0
|
|
20
|
+
OPT_BASELINE="" OPT_SAVE_BASELINE="" OPT_ARTIFACT=""
|
|
20
21
|
while [[ $# -gt 0 ]]; do
|
|
21
22
|
case "$1" in
|
|
22
23
|
--format)
|
|
@@ -47,6 +48,18 @@ while [[ $# -gt 0 ]]; do
|
|
|
47
48
|
--out)
|
|
48
49
|
if [[ $# -lt 2 ]]; then echo "scan.sh: --out needs a path" >&2; exit 64; fi
|
|
49
50
|
OPT_OUT="$2"; shift 2 ;;
|
|
51
|
+
--baseline)
|
|
52
|
+
if [[ $# -lt 2 ]]; then echo "scan.sh: --baseline needs a file" >&2; exit 64; fi
|
|
53
|
+
OPT_BASELINE="$2"; shift 2 ;;
|
|
54
|
+
--baseline=*) OPT_BASELINE="${1#*=}"; shift ;;
|
|
55
|
+
--save-baseline)
|
|
56
|
+
if [[ $# -lt 2 ]]; then echo "scan.sh: --save-baseline needs a file" >&2; exit 64; fi
|
|
57
|
+
OPT_SAVE_BASELINE="$2"; shift 2 ;;
|
|
58
|
+
--save-baseline=*) OPT_SAVE_BASELINE="${1#*=}"; shift ;;
|
|
59
|
+
--artifact|--ipa)
|
|
60
|
+
if [[ $# -lt 2 ]]; then echo "scan.sh: $1 needs a .app, .ipa or .xcarchive path" >&2; exit 64; fi
|
|
61
|
+
OPT_ARTIFACT="$2"; shift 2 ;;
|
|
62
|
+
--artifact=*|--ipa=*) OPT_ARTIFACT="${1#*=}"; shift ;;
|
|
50
63
|
*) shift ;;
|
|
51
64
|
esac
|
|
52
65
|
done
|
|
@@ -59,6 +72,11 @@ if [[ -n "$SCAN_DIR" ]]; then
|
|
|
59
72
|
else
|
|
60
73
|
ROOT="$(git rev-parse --show-toplevel 2>/dev/null)" || ROOT="$(pwd)"
|
|
61
74
|
fi
|
|
75
|
+
# Option paths are the caller's, not the scanned repo's: make them absolute before cd.
|
|
76
|
+
for _opt in OPT_BASELINE OPT_SAVE_BASELINE OPT_ARTIFACT; do
|
|
77
|
+
eval "_v=\${$_opt}"
|
|
78
|
+
if [[ -n "$_v" && "$_v" != /* ]]; then eval "$_opt=\"\$PWD/\$_v\""; fi
|
|
79
|
+
done
|
|
62
80
|
cd "$ROOT" || { echo "FAIL: repo-root — could not enter repository root"; exit 0; }
|
|
63
81
|
|
|
64
82
|
source "$SCRIPT_DIR/findings.sh"
|
|
@@ -116,8 +134,8 @@ _tag() {
|
|
|
116
134
|
[[ -n "$lbl" ]] && printf ' %s\n' "$lbl"
|
|
117
135
|
return 0
|
|
118
136
|
}
|
|
119
|
-
fail() { if is_suppressed "$_CURRENT_RULE" "${2:-}" "${3:-}"; then _record_suppressed FAIL "$1" "${2:-}" "${3:-}"; _LAST_SUPPRESSED=1; else echo "FAIL: $1"; _record FAIL "$1" "${2:-}" "${3:-}"; _tag; _LAST_SUPPRESSED=0; fi; }
|
|
120
|
-
warn() { if is_suppressed "$_CURRENT_RULE" "${2:-}" "${3:-}"; then _record_suppressed WARN "$1" "${2:-}" "${3:-}"; _LAST_SUPPRESSED=1; else echo "WARN: $1"; _record WARN "$1" "${2:-}" "${3:-}"; _tag; _LAST_SUPPRESSED=0; fi; }
|
|
137
|
+
fail() { if is_suppressed "$_CURRENT_RULE" "${2:-}" "${3:-}" "$1"; then _record_suppressed FAIL "$1" "${2:-}" "${3:-}"; _LAST_SUPPRESSED=1; else echo "FAIL: $1"; _record FAIL "$1" "${2:-}" "${3:-}"; _tag; _LAST_SUPPRESSED=0; fi; }
|
|
138
|
+
warn() { if is_suppressed "$_CURRENT_RULE" "${2:-}" "${3:-}" "$1"; then _record_suppressed WARN "$1" "${2:-}" "${3:-}"; _LAST_SUPPRESSED=1; else echo "WARN: $1"; _record WARN "$1" "${2:-}" "${3:-}"; _tag; _LAST_SUPPRESSED=0; fi; }
|
|
121
139
|
pass() { if is_suppressed "$_CURRENT_RULE" "${2:-}" "${3:-}"; then _record_suppressed PASS "$1" "${2:-}" "${3:-}"; _LAST_SUPPRESSED=1; else echo "PASS: $1"; _record PASS "$1" "${2:-}" "${3:-}"; _LAST_SUPPRESSED=0; fi; }
|
|
122
140
|
|
|
123
141
|
# skip <message> — a check that could NOT run (a missing artifact, not a clean
|
|
@@ -161,6 +179,9 @@ SRC_INC=( --include='*.swift' --include='*.m' --include='*.mm' --include='*.h' )
|
|
|
161
179
|
# Load .precheck-ignore path exclusions (Task 2 suppress.sh) and extend both
|
|
162
180
|
# prune sets so a suppressed path is skipped by detection AND grep passes.
|
|
163
181
|
load_precheck_ignore "$ROOT"
|
|
182
|
+
# --baseline <file>: findings recorded by an earlier --save-baseline are treated like
|
|
183
|
+
# a .precheck-ignore suppression (counted, kept in JSON, dropped from text + verdict).
|
|
184
|
+
[[ -n "$OPT_BASELINE" ]] && load_baseline "$OPT_BASELINE"
|
|
164
185
|
while IFS= read -r _g; do
|
|
165
186
|
[[ -z "$_g" ]] && continue
|
|
166
187
|
PRUNE+=( -not -path "*/$_g/*" -not -path "$_g/*" )
|
|
@@ -748,7 +769,7 @@ ext_purchase=""
|
|
|
748
769
|
grep -rqE 'ExternalPurchase|ExternalPurchaseLink|ExternalPurchaseCustomLink' "${IOS_DIR:-.}" "${GREP_PRUNE[@]}" "${SRC_INC[@]}" 2>/dev/null && ext_purchase=1
|
|
749
770
|
grep -rqE 'external-purchase' "${IOS_DIR:-.}" "${GREP_PRUNE[@]}" --include='*.entitlements' 2>/dev/null && ext_purchase=1
|
|
750
771
|
if [[ -n "$ext_purchase" ]]; then
|
|
751
|
-
warn "3.1.1(a) External purchase link detected — review the offering, storefront, distribution and applicable agreement before checking entitlement, disclosure and reporting duties. United States storefront links do not require these entitlements under 3.1.1(a); SDK presence alone is not a violation."
|
|
772
|
+
warn "3.1.1(a) External purchase link detected — the link may only lead to a permitted destination for that storefront (approved destinations vary by region), under a StoreKit External Purchase Link or, where permitted, Music Streaming Services entitlement; review the offering, storefront, distribution and applicable agreement before checking entitlement, disclosure and reporting duties. United States storefront links do not require these entitlements under 3.1.1(a); SDK presence alone is not a violation."
|
|
752
773
|
fi
|
|
753
774
|
|
|
754
775
|
# ===================================================================
|
|
@@ -875,14 +896,19 @@ fi
|
|
|
875
896
|
# Apps with UGC must provide: a content filter, a report mechanism, the ability
|
|
876
897
|
# to block abusive users, and published contact info. We detect a UGC signal and
|
|
877
898
|
# warn when no report/block/moderation affordance is found anywhere in the source.
|
|
899
|
+
# Since October 16, 2026 the rule names apps that let users "create, generate,
|
|
900
|
+
# upload, share, or otherwise contribute content", explicitly including AI content
|
|
901
|
+
# creation apps, and adds nonconsensual intimate imagery to the harms; failing to
|
|
902
|
+
# implement safeguards is a Developer Code of Conduct matter. The signal list
|
|
903
|
+
# therefore also covers image/video generation endpoints and SDKs.
|
|
878
904
|
set_rule "ugc-no-moderation"
|
|
879
905
|
if [[ -n "$IOS_DIR" ]]; then
|
|
880
|
-
ugc_signal=$(grep -rlE 'userGeneratedContent|\bUGC\b|StreamChat|MessageKit|SendbirdSDK|PubNub|postComment|submitComment|createPost|publishPost|uploadUserPhoto|uploadVideo' "$IOS_DIR" "${GREP_PRUNE[@]}" "${SRC_INC[@]}" 2>/dev/null | head -1)
|
|
906
|
+
ugc_signal=$(grep -rlE 'userGeneratedContent|\bUGC\b|StreamChat|MessageKit|SendbirdSDK|PubNub|postComment|submitComment|createPost|publishPost|uploadUserPhoto|uploadVideo|/images/generations|/images/edits|/v1/videos/generations|api\.replicate\.com|replicate\.run|api\.stability\.ai|stability\.ai|fal\.ai|fal\.run|api\.runwayml\.com|api\.dev\.runwayml\.com|import ImagePlayground|ImageCreator\b|ImagePlaygroundViewController|imagePlaygroundSheet|generateImage\b|generateVideo\b|imageGeneration\b|videoGeneration\b|textToImage\b|text-to-image|txt2img|StableDiffusion' "$IOS_DIR" "${GREP_PRUNE[@]}" "${SRC_INC[@]}" 2>/dev/null | head -1)
|
|
881
907
|
if [[ -n "$ugc_signal" ]]; then
|
|
882
908
|
if grep -rqiE 'report(Content|User|Abuse|Post|Comment|Message|Reason|ed)|block(ed)?User|unblockUser|moderat(e|ion|or)|flag(Content|Post|User|Comment|Message)|content.?filter' "$IOS_DIR" "${GREP_PRUNE[@]}" "${SRC_INC[@]}" 2>/dev/null; then
|
|
883
909
|
pass "1.2 UGC — user-generated content with report/block/moderation affordances present"
|
|
884
910
|
else
|
|
885
|
-
warn "1.2 UGC — user-generated content detected (e.g. $(basename "$ugc_signal")) but no report/block/moderation mechanism found;
|
|
911
|
+
warn "1.2 UGC — user-generated or AI-generated content detected (e.g. $(basename "$ugc_signal")) but no report/block/moderation mechanism found; apps that let users create, generate, upload or share content (including AI content creation apps) must offer content filtering, a report mechanism, user blocking, and published contact info, and must guard against nonconsensual intimate imagery; missing safeguards are also a Developer Code of Conduct violation (1.2)"
|
|
886
912
|
fi
|
|
887
913
|
fi
|
|
888
914
|
fi
|
|
@@ -940,7 +966,7 @@ fi
|
|
|
940
966
|
set_rule "misleading-marketing"
|
|
941
967
|
if [[ -d "$META_DIR" ]]; then
|
|
942
968
|
mislead_re='virus scan|virus scanner|antivirus|anti-virus|malware (scan|remov|clean)|spyware remov|clean your (iphone|device)|speed booster|boost.*(speed|ram)|free money|guaranteed.*(win|prize)'
|
|
943
|
-
mislead_hits=$(grep -rEniI "$mislead_re" "$META_DIR" 2>/dev/null | grep -v "^Binary file" | head -10)
|
|
969
|
+
mislead_hits=$(grep -rEniI "$mislead_re" "$META_DIR" 2>/dev/null | grep -v "^Binary file" | LC_ALL=C sort -t: -k1,1 -k2,2n | head -10)
|
|
944
970
|
if [[ -n "$mislead_hits" ]]; then
|
|
945
971
|
mislead_file="$(printf '%s\n' "$mislead_hits" | head -1 | cut -d: -f1)"
|
|
946
972
|
warn "2.3.1 Misleading marketing — claims that often violate 2.3.1 (e.g. iOS virus/malware scanners, fake speed boosters) in metadata; verify the app truly delivers them or remove the claim:" "$mislead_file"
|
|
@@ -956,7 +982,7 @@ fi
|
|
|
956
982
|
set_rule "kids-wording"
|
|
957
983
|
if [[ -d "$META_DIR" ]]; then
|
|
958
984
|
kids_re='for kids|for children|for your (kid|child)|kids[[:space:]]?app|für kinder|para niños|pour enfants'
|
|
959
|
-
kids_hits=$(grep -rEniI "$kids_re" "$META_DIR" 2>/dev/null | grep -v "^Binary file" | head -10)
|
|
985
|
+
kids_hits=$(grep -rEniI "$kids_re" "$META_DIR" 2>/dev/null | grep -v "^Binary file" | LC_ALL=C sort -t: -k1,1 -k2,2n | head -10)
|
|
960
986
|
# Cross-gate with §39 (5.1.4): when an ads/analytics SDK is also linked, §39 fires the
|
|
961
987
|
# more specific Kids finding for the same wording signal — don't double-count it here
|
|
962
988
|
# (one root signal must not cost two WARNs against the 5-WARN YELLOW threshold).
|
|
@@ -1169,7 +1195,7 @@ fi
|
|
|
1169
1195
|
set_rule "realmoney-gambling"
|
|
1170
1196
|
if [[ -d "$META_DIR" ]]; then
|
|
1171
1197
|
gamble_re='real[ -]?money|gambling|casino|sportsbook|sports[ -]?betting|place[ -].*bets|wager(ing)?|roulette.*real'
|
|
1172
|
-
gamble_hits=$(grep -rEniI "$gamble_re" "$META_DIR" 2>/dev/null | grep -v "^Binary file" | head -10)
|
|
1198
|
+
gamble_hits=$(grep -rEniI "$gamble_re" "$META_DIR" 2>/dev/null | grep -v "^Binary file" | LC_ALL=C sort -t: -k1,1 -k2,2n | head -10)
|
|
1173
1199
|
if [[ -n "$gamble_hits" ]]; then
|
|
1174
1200
|
gamble_first="$(printf '%s\n' "$gamble_hits" | head -1)" # "path:line:match"
|
|
1175
1201
|
gamble_file="${gamble_first%%:*}"
|
|
@@ -1548,6 +1574,21 @@ if [[ -n "$IOS_DIR" ]]; then
|
|
|
1548
1574
|
pass "4.5.4 Marketing push — SDK present and a notification-preferences signal exists; verify promotional pushes are consent-gated"
|
|
1549
1575
|
fi
|
|
1550
1576
|
fi
|
|
1577
|
+
# Live Activities (ActivityKit / NSSupportsLiveActivities) are an Apple Service under
|
|
1578
|
+
# 4.5.3 since the June 2026 rewrite: they may not carry spam, phishing or unsolicited
|
|
1579
|
+
# messages. Push-to-start Live Activities driven by a marketing-push SDK are the
|
|
1580
|
+
# risky combination; ActivityKit alone is a note for deep-review check 15.
|
|
1581
|
+
live_act=$(grep -rlE 'import ActivityKit|ActivityKit\.|Activity<[A-Za-z_]+Attributes>|ActivityAttributes\b' "$IOS_DIR" "${GREP_PRUNE[@]}" "${SRC_INC[@]}" 2>/dev/null | head -1)
|
|
1582
|
+
if [[ -z "$live_act" && -f "$INFO_PLIST" ]] && grep -qA1 'NSSupportsLiveActivities' "$INFO_PLIST" 2>/dev/null && grep -A1 'NSSupportsLiveActivities' "$INFO_PLIST" 2>/dev/null | grep -q '<true/>'; then
|
|
1583
|
+
live_act="$INFO_PLIST"
|
|
1584
|
+
fi
|
|
1585
|
+
if [[ -n "$live_act" ]]; then
|
|
1586
|
+
if [[ -n "$push_mkt" ]]; then
|
|
1587
|
+
warn "4.5.3 Live Activities — ActivityKit/NSSupportsLiveActivities ($(basename "$live_act")) coexists with a marketing-push SDK ($(basename "$push_mkt")); Live Activities may not be used to spam or send unsolicited promotional updates (4.5.3). Verify every Live Activity (including push-to-start) reflects a user-initiated, time-bound activity" "$live_act"
|
|
1588
|
+
else
|
|
1589
|
+
pass "4.5.3 Live Activities — ActivityKit/NSSupportsLiveActivities present without a marketing-push SDK; verify Live Activities stay tied to user-initiated activity and never carry promotions (4.5.3)"
|
|
1590
|
+
fi
|
|
1591
|
+
fi
|
|
1551
1592
|
fi
|
|
1552
1593
|
|
|
1553
1594
|
# ===================================================================
|
|
@@ -1559,8 +1600,8 @@ fi
|
|
|
1559
1600
|
# tracks "upgrade to recommended settings", not the actual toolchain, so this
|
|
1560
1601
|
# is WARN-verify only, and only fires when the value is clearly pre-26.
|
|
1561
1602
|
set_rule "xcode-sdk-requirement"
|
|
1562
|
-
last_upgrade=$(find . "${PRUNE[@]}" -name 'project.pbxproj' -type f 2>/dev/null
|
|
1563
|
-
| xargs grep -h 'LastUpgradeCheck' 2>/dev/null | grep -oE '[0-9]+' | sort -n | tail -1)
|
|
1603
|
+
last_upgrade=$(find . "${PRUNE[@]}" -name 'project.pbxproj' -type f -print0 2>/dev/null \
|
|
1604
|
+
| xargs -0 grep -h 'LastUpgradeCheck' 2>/dev/null | grep -oE '[0-9]+' | sort -n | tail -1)
|
|
1564
1605
|
if [[ -n "$last_upgrade" ]] && (( last_upgrade < 2600 )); then
|
|
1565
1606
|
warn "2.1 Xcode/SDK minimum — LastUpgradeCheck=$last_upgrade suggests the project was last upgraded with a pre-26 Xcode; since April 2026 App Store uploads must be built with the iOS 26 SDK (Xcode 26) or they are auto-rejected at upload. Verify the actual build toolchain (heuristic: this field tracks the upgrade-check, not the build)"
|
|
1566
1607
|
fi
|
|
@@ -1582,7 +1623,7 @@ fi
|
|
|
1582
1623
|
set_rule "saturated-category"
|
|
1583
1624
|
if [[ -d "$META_DIR" ]]; then
|
|
1584
1625
|
# Word-boundary anchored so 'fart' does not match 'farther', nor 'dating' 'updating'.
|
|
1585
|
-
sat_re='(^|[^a-z])(dating|flashlight|sound effects?|wallpapers?|fortune telling|fortune teller|drinking games?|kama sutra|fart|burp)([^a-z]|$)'
|
|
1626
|
+
sat_re='(^|[^a-z])(dating|flashlight|sound effects?|wallpapers?|simple timers?|fortune telling|fortune teller|drinking games?|kama sutra|fart|burp)([^a-z]|$)'
|
|
1586
1627
|
sat_hits=""
|
|
1587
1628
|
for loc in "${LOCALES[@]+"${LOCALES[@]}"}"; do
|
|
1588
1629
|
for mf in name.txt subtitle.txt keywords.txt; do
|
|
@@ -1619,8 +1660,10 @@ if [[ -n "$IOS_DIR" ]]; then
|
|
|
1619
1660
|
# The trailing class also rejects the IPv6-capable siblings (sockaddr_in6, AF_INET6,
|
|
1620
1661
|
# gethostbyname2) because their next character is alphanumeric.
|
|
1621
1662
|
ipv4_api_re='(^|[^A-Za-z0-9_])(inet_addr|inet_aton|gethostbyname|sockaddr_in|AF_INET)([^A-Za-z0-9_]|$)'
|
|
1663
|
+
# Sorted by path then line before the cap: grep -r walks directories in filesystem
|
|
1664
|
+
# order (APFS and ext4 differ), and the golden tests pin this text verbatim.
|
|
1622
1665
|
ipv4_api_hits=$(grep -rnEI "$ipv4_api_re" "$IOS_DIR" "${GREP_PRUNE[@]}" "${SRC_INC[@]}" 2>/dev/null \
|
|
1623
|
-
| grep -vE '^[^:]+:[0-9]+:[[:space:]]*(//|\*|/\*|#)' | head -5)
|
|
1666
|
+
| grep -vE '^[^:]+:[0-9]+:[[:space:]]*(//|\*|/\*|#)' | LC_ALL=C sort -t: -k1,1 -k2,2n | head -5)
|
|
1624
1667
|
# Literals: dotted quads in source AND plists (ATS exception domains, endpoints).
|
|
1625
1668
|
# Pre-filter with grep, then let awk apply the exclusions per match. No brace
|
|
1626
1669
|
# intervals in the awk regexes: mawk (Ubuntu CI) does not support them.
|
|
@@ -1648,9 +1691,9 @@ if [[ -n "$IOS_DIR" ]]; then
|
|
|
1648
1691
|
}
|
|
1649
1692
|
}' "$ipv4_f" 2>/dev/null | head -2)
|
|
1650
1693
|
[[ -n "$ipv4_h" ]] && ipv4_lit_hits+="$ipv4_h"$'\n'
|
|
1651
|
-
done < <(grep -rlE '(^|[^0-9])[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}([^0-9]|$)' "$IOS_DIR" "${GREP_PRUNE[@]}" "${SRC_INC[@]}" --include='*.plist' 2>/dev/null | head -50)
|
|
1694
|
+
done < <(grep -rlE '(^|[^0-9])[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}([^0-9]|$)' "$IOS_DIR" "${GREP_PRUNE[@]}" "${SRC_INC[@]}" --include='*.plist' 2>/dev/null | LC_ALL=C sort | head -50)
|
|
1652
1695
|
ipv4_lit_hits="$(printf '%s' "$ipv4_lit_hits" | grep -v '^$' | head -5)"
|
|
1653
|
-
ipv4_hits="$(printf '%s\n%s\n' "$ipv4_api_hits" "$ipv4_lit_hits" | grep -v '^$')"
|
|
1696
|
+
ipv4_hits="$(printf '%s\n%s\n' "$ipv4_api_hits" "$ipv4_lit_hits" | grep -v '^$' | LC_ALL=C sort -t: -k1,1 -k2,2n -k3)"
|
|
1654
1697
|
if [[ -n "$ipv4_hits" ]]; then
|
|
1655
1698
|
ipv4_n="$(printf '%s\n' "$ipv4_hits" | wc -l | tr -d ' ')"
|
|
1656
1699
|
ipv4_first="$(printf '%s\n' "$ipv4_hits" | head -1)"
|
|
@@ -1665,10 +1708,21 @@ fi
|
|
|
1665
1708
|
# shellcheck source=skills/appstore-precheck/scripts/lib/scan-guidelines.sh
|
|
1666
1709
|
source "$SCRIPT_DIR/lib/scan-guidelines.sh"
|
|
1667
1710
|
|
|
1711
|
+
# --artifact / --ipa: the nine read-only artifact-review checks on a built
|
|
1712
|
+
# .app / .ipa / .xcarchive, as catalogued rules with `artifact` evidence.
|
|
1713
|
+
if [[ -n "$OPT_ARTIFACT" ]]; then
|
|
1714
|
+
# shellcheck source=skills/appstore-precheck/scripts/lib/scan-artifact.sh
|
|
1715
|
+
source "$SCRIPT_DIR/lib/scan-artifact.sh"
|
|
1716
|
+
fi
|
|
1717
|
+
|
|
1668
1718
|
optin_run || exit $?
|
|
1719
|
+
[[ -n "$OPT_SAVE_BASELINE" ]] && save_baseline "$OPT_SAVE_BASELINE"
|
|
1669
1720
|
echo "---END-OF-SCAN---"
|
|
1670
1721
|
if [[ "$FORMAT" == text && "${_SUPPRESSED_COUNT:-0}" -gt 0 ]]; then
|
|
1671
|
-
printf '(%s finding(s) suppressed via .precheck-ignore)\n' "$_SUPPRESSED_COUNT"
|
|
1722
|
+
printf '(%s finding(s) suppressed via .precheck-ignore)\n' "$((_SUPPRESSED_COUNT - ${_BASELINE_COUNT:-0}))"
|
|
1723
|
+
fi
|
|
1724
|
+
if [[ "$FORMAT" == text && "${_BASELINE_COUNT:-0}" -gt 0 ]]; then
|
|
1725
|
+
printf '(%s finding(s) matched the baseline %s)\n' "$_BASELINE_COUNT" "$OPT_BASELINE"
|
|
1672
1726
|
fi
|
|
1673
1727
|
if [[ "$FORMAT" == json ]]; then exec 1>&4 4>&-; render_json | coverage_run_json | optin_render_json;
|
|
1674
1728
|
elif [[ "$FORMAT" == sarif ]]; then exec 1>&4 4>&-; render_sarif; fi
|
|
@@ -6,6 +6,8 @@ _SUPP_RULES="" # rule-ids suppressed everywhere, one per line
|
|
|
6
6
|
_SUPP_RULE_PATH="" # "rule<TAB>glob" per line
|
|
7
7
|
_SUPP_PATHS="" # path globs excluded from scanning, one per line (trailing / stripped)
|
|
8
8
|
_SUPP_REASON="" # set by is_suppressed on a hit
|
|
9
|
+
_BASE_KEYS="" # "rule<TAB>file<TAB>message" per line, from --baseline
|
|
10
|
+
_BASE_FILE=""
|
|
9
11
|
|
|
10
12
|
# _is_catalog_rule <token> -> 0 if token is a known rule slug.
|
|
11
13
|
# The bound is derived from the catalog itself (rule_slug returns "" past the
|
|
@@ -54,6 +56,33 @@ load_precheck_ignore() {
|
|
|
54
56
|
done < "$file"
|
|
55
57
|
}
|
|
56
58
|
|
|
59
|
+
# load_baseline <file> — read a --save-baseline file. Problems are reported on stderr
|
|
60
|
+
# and leave the scan untouched: a baseline that cannot be read must never hide anything.
|
|
61
|
+
load_baseline() {
|
|
62
|
+
local file="$1" keys
|
|
63
|
+
_BASE_KEYS=""; _BASE_FILE="$file"
|
|
64
|
+
if [[ ! -f "$file" ]]; then printf 'scan.sh: baseline file not found: %s (ignored)\n' "$file" >&2; return 0; fi
|
|
65
|
+
if ! command -v jq >/dev/null 2>&1; then printf 'scan.sh: --baseline needs jq (ignored)\n' >&2; return 0; fi
|
|
66
|
+
# Fields are joined with US (0x1f) and newlines inside a message flattened to spaces, the
|
|
67
|
+
# same normalisation is_suppressed applies to the live message, so the two keys agree.
|
|
68
|
+
keys="$(jq -r '.findings[]? | select(.rule_id != null and .message != null) | [.rule_id, (.file // ""), (.message | gsub("\n"; " "))] | join("\u001f")' "$file" 2>/dev/null)" \
|
|
69
|
+
|| { printf 'scan.sh: baseline is not a findings JSON file: %s (ignored)\n' "$file" >&2; return 0; }
|
|
70
|
+
_BASE_KEYS="$keys"
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
# save_baseline <file> — write the live FAIL/WARN findings of this run as a baseline.
|
|
74
|
+
# Reads the JSONL findings buffer, so it works in text and json mode alike.
|
|
75
|
+
save_baseline() {
|
|
76
|
+
local file="$1"
|
|
77
|
+
if ! command -v jq >/dev/null 2>&1; then printf 'scan.sh: --save-baseline needs jq\n' >&2; return 0; fi
|
|
78
|
+
[[ -s "${FINDINGS_TMP:-}" ]] || printf '' > "${FINDINGS_TMP:-/dev/null}"
|
|
79
|
+
jq -s --arg v "${PRECHECK_VERSION:-dev}" --arg d "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
|
|
80
|
+
'{tool:"appstore-precheck", version:$v, created:$d,
|
|
81
|
+
findings: [ .[] | select(.suppressed == false and (.severity == "FAIL" or .severity == "WARN"))
|
|
82
|
+
| {rule_id, severity, file, message} ]}' "$FINDINGS_TMP" > "$file" 2>/dev/null \
|
|
83
|
+
|| printf 'scan.sh: could not write the baseline %s\n' "$file" >&2
|
|
84
|
+
}
|
|
85
|
+
|
|
57
86
|
# precheck_prune_globs -> one path glob per line (for scan.sh PRUNE/GREP_PRUNE).
|
|
58
87
|
precheck_prune_globs() { printf '%s' "$_SUPP_PATHS"; }
|
|
59
88
|
|
|
@@ -66,10 +95,14 @@ _inline_marker() {
|
|
|
66
95
|
[[ "$spec" == "$rule" ]] # scoped marker must match
|
|
67
96
|
}
|
|
68
97
|
|
|
69
|
-
# is_suppressed <rule> <file> <line> -> 0 if suppressed (+ _SUPP_REASON), else 1.
|
|
98
|
+
# is_suppressed <rule> <file> <line> [<message>] -> 0 if suppressed (+ _SUPP_REASON), else 1.
|
|
99
|
+
# The message is passed only for FAIL/WARN: a baseline match needs rule + file + text.
|
|
70
100
|
is_suppressed() {
|
|
71
|
-
local rule="$1" file="${2:-}" line="${3:-}" r g target
|
|
101
|
+
local rule="$1" file="${2:-}" line="${3:-}" msg="${4:-}" r g target
|
|
72
102
|
_SUPP_REASON=""
|
|
103
|
+
if [[ -n "$msg" && -n "$_BASE_KEYS" ]] && printf '%s\n' "$_BASE_KEYS" | grep -qxF "$(printf '%s\037%s\037%s' "$rule" "$file" "${msg//$'\n'/ }")"; then
|
|
104
|
+
_SUPP_REASON="baseline"; return 0
|
|
105
|
+
fi
|
|
73
106
|
if [[ -n "$rule" ]] && printf '%s\n' "$_SUPP_RULES" | grep -qxF "$rule"; then
|
|
74
107
|
_SUPP_REASON="rule:$rule"; return 0
|
|
75
108
|
fi
|