Files
iOSBuildServer/backend/automation/obfuscation/scripts/obfuscation_self_check.sh
T
shenlei 83a1db21e5 feat: 接入 iOSGuard LLVM 混淆工具链与 IPA 加固门禁,按分支策略兼容旧版本打包
- 新增 toolchain_manager:构建前自愈校验 LLVM opt 工具链,按 Xcode 版本与渠道隔离 obj_cache
- readoor31/readoor31OtherPay Archive 透传 IG_DIST_CHANNEL/IG_OBF_MODE/IG_ALL_GUARD_OFF/IG_RELEASE_SEED
- Archive 前核对分发渠道编译条件:上架包缺失 IG_APPSTORE_DISTRIBUTION 即阻断,非上架包带该条件仅告警,未接入 anti_tamper 的分支跳过
- 导出后执行 IPA 加固门禁审计,失败阻断上传;持久化 dSYM、混淆映射、诊断事件码与审计报告
- 混淆是否执行改由分支 AutoPacking/build_policy.json 声明:force_obfuscation=true 强制,否则按任务勾选,兼容旧分支/旧 Tag;恢复打包页混淆勾选框
- 分支未自带混淆脚本时回退服务端脚本并告警;同步更新服务端 L1 混淆脚本
- .gitignore 忽略 iosguard_cache 与 artifacts 运行时目录;README 补充分支打包策略说明
2026-11-24 12:03:54 +09:00

57 lines
2.1 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
# Scan repository for residual obfuscated tokens (both legacy Rd/YMH/ymh<hex> and curated natural CamelCase stems)
# Exits 0 when clean, non-zero when tokens are present.
ROOT="${1:-$(cd "$(dirname "$0")/../../.." && pwd)}"
echo "[obf-check] Scanning for residual obfuscated tokens in ${ROOT}"
EXCLUDE=(
"./Pods"
"./.git"
"./obfuscation_maps"
"./build_output"
"./DerivedData"
"./readoorTests"
"./iOSGuardIntegration"
"./Factorys"
"./AutoPacking"
)
GREP_EXCLUDE_ARGS=()
for e in "${EXCLUDE[@]}"; do
GREP_EXCLUDE_ARGS+=(--exclude-dir "${e#./}")
done
FOUND=0
TOKEN_SUFFIX_RE='([a-f0-9]{6}|[a-f0-9]{8}|[a-f0-9]{10})'
STEM_GROUP='(Breeze|Birch|Canopy|Cobalt|Harbor|Kestrel|Linden|Lumen|Meadow|Meridian|Osprey|Prism|Solace|Summit|Timber|Zephyr)'
NATURAL_TYPE_RE="\\b${STEM_GROUP}[A-Z][a-z]+([A-Z][a-z]+)+\\b"
NATURAL_METHOD_RE="\\b[a-z]+${STEM_GROUP}[A-Z][A-Za-z]+\\b"
echo "[obf-check] Looking for legacy token pattern '\\b(Rd|YMH|ymh)${TOKEN_SUFFIX_RE}\\b' in source files..."
if grep -R --line-number -E "\\b(Rd|YMH|ymh)${TOKEN_SUFFIX_RE}\\b" --include='*.swift' --include='*.m' --include='*.mm' --include='*.h' "${GREP_EXCLUDE_ARGS[@]}" "${ROOT}"; then
FOUND=1
fi
echo "[obf-check] Looking for natural CamelCase obfuscated tokens in source files..."
if grep -R --line-number -E "${NATURAL_TYPE_RE}|${NATURAL_METHOD_RE}" --include='*.swift' --include='*.m' --include='*.mm' --include='*.h' "${GREP_EXCLUDE_ARGS[@]}" "${ROOT}"; then
FOUND=1
fi
echo "[obf-check] Looking for obfuscated header imports like \"(Rd|YMH)XXXXXX.h\"..."
if grep -R --line-number -E "#import\\s+\"(Rd|YMH)${TOKEN_SUFFIX_RE}\\.h\"" --include='*.pch' --include='*.h' --include='*.m' --include='*.mm' "${GREP_EXCLUDE_ARGS[@]}" "${ROOT}"; then
FOUND=1
fi
if [[ ${FOUND} -ne 0 ]]; then
echo "[obf-check] ERROR: Found residual obfuscated tokens; aborting to avoid double-obfuscation."
echo "[obf-check] Run: python3 AutoPacking/obfuscation/obfuscate_symbols.py --restore-source-from-map-dir obfuscation_maps or run the auto-restore tool before archiving."
exit 2
fi
echo "[obf-check] Clean: no residual obfuscated tokens found."
exit 0