test(defender): 固化处置链宿主基线 + 真机验证协议(docs/19),修越狱聚合回归

P0 验真:真机验证前先把「检测→分级→数据毒化」闭环做成可复现宿主绿灯。

新增:
- tests/fixtures/poison_host.c + tests/test_poison_policy.py:poison/policy/
  anti_jailbreak 闭环自测 19/19(poison 恒等+坏key+不可逆、policy 分级+去重+
  mask一致、jailbreak 反向零误报+400+401),集成进 unittest 套件。
- docs/19_DISPOSITION_CHAIN_DEVICE_VERIFICATION.md:真机验证协议——R(非越狱)/
  J(越狱)两组、D1–D7 用例、验收门槛(反向零毒化为开毒化前提)、边界与进度。

修复(接越狱探针进 ig_defender_scan 聚合器时埋下的回归):
- test_defender_host.py SOURCES 漏 anti_jailbreak/IGAntiJailbreak.c → 链接缺符号。
- defender_host.c:reasons[] 由 256 扩到 512(400/401 越界漏计);clean 断言排除
  越狱文件命中(macOS 自带 Unix userland,按 iOS 标准宿主本身即“越狱”,非真实误报)。

全套 63 项宿主/工具测试通过。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-11-12 22:35:35 +09:00
co-authored by Claude Opus 4.8
parent 599e1da5ce
commit c4c9a6925a
5 changed files with 338 additions and 3 deletions
+9 -3
View File
@@ -16,10 +16,10 @@
#include <mach-o/loader.h>
#include <mach-o/nlist.h>
typedef struct { int reasons[256]; int detected; int unavailable; } Findings;
typedef struct { int reasons[512]; int detected; int unavailable; } Findings;
static int collect(const IGFinding *f, void *context) {
Findings *out = context;
if (f->reason >= 0 && f->reason < 256) out->reasons[f->reason]++;
if (f->reason >= 0 && f->reason < 512) out->reasons[f->reason]++;
if (f->status == IG_DETECTED) out->detected++;
if (f->status == IG_UNAVAILABLE) out->unavailable++;
printf("status=%d reason=%d subject=%s evidence=%s\n",
@@ -89,7 +89,13 @@ int main(int argc, char **argv) {
Findings f={0};
if (!strcmp(argv[1],"clean")) {
int hits=ig_defender_scan(NULL,0,collect,&f);
return hits!=f.detected || f.detected || f.unavailable;
/* 越狱文件探针(400/401)在 macOS 宿主必然命中:mac 自带完整 Unix userland
* (/usr/sbin/sshd、/bin/bash、/bin/sh…),按 iOS 标准宿主本身即“越狱”。
* 这是宿主/iOS 环境差异,非真实误报——iOS 非越狱设备上这些路径不存在/沙盒不可达,
* 其反向零命中由真机 R 组验证(docs/19)。故宿主 clean 只对非越狱探针断言零 DETECTED。 */
int jb = f.reasons[IG_REASON_JAILBREAK_FILE] + f.reasons[IG_REASON_JAILBREAK_SANDBOX];
int non_jb_detected = f.detected - jb;
return hits!=f.detected || non_jb_detected || f.unavailable;
}
if (!strcmp(argv[1],"unresolved")) {
const char *names[]={"IG_fixture_symbol_that_does_not_exist_123"};