SuperAPI AI 工具集

harness-security-bench

安全与审计

查看项目

更新于 10-15 13:52

技能介绍

用途

harness-security-bench 用于运行上游 @metaharness/darwin 的 security bench 命令,即上游 ADR-155「Darwin Shield」。它被描述为 ruflo 夜间自学习安全 harness(#2417)最接近的参考实现。

该技能对 ruflo 的 ADR-155 的意义在于:ADR-155 提出三个学习循环(按维度置信度、严重性校准、自动修复出价)。其中 Loop A 在累积的 (finding, dimension, human_outcome) 元组上训练,但只有当底层检测机制在已知良好语料上收敛时,梯度信号才是可靠的。Darwin Shield 正是在一个 10 漏洞 / 9 诱饵的 ground-truth 集合上进化该机制。夜间运行它可提供:

  • 经验下限:如果 Darwin Shield 的冠军无法在基准语料上达到 TPR=1/FPR=0,则 Loop A 的奖励信号就是噪声。
  • 漂移检测:逐周冠军适应度差值可揭示安全态势(或变异策略)的变化。
  • 基线多样性:4 个基线(B0–B3)提供 4 个锚点,用于对按维度置信度进行加权。

主要能力

  • 运行 metaharness-darwin security bench 命令,支持 --population、--cycles、--seed 参数。
  • 解析 markdown 报告,得到整体 PASS/FAIL 以及逐门禁的通过/失败行。门禁示例包括:TPR improvement ≥ 25% vs fixed、FPR reduction ≥ 40%、Patch-test pass rate ≥ 80%、Reproduction success ≥ 90%、Unsafe outputs = 0、Cost increase ≤ 2× fixed、Beyond SOTA: champion statistically beats previous champion、Compounding: false-positive repeat-rate drop ≥ 35%。
  • 解析 baselines-vs-champion 表格(4 行:每个 harness 的 fitness/TPR/FPR/patchPass/repro/unsafe/cost)。
  • 输出结构化 JSON。
  • 配合 --alert-on-fail 时,当 overall = FAIL 以退出码 1 退出。

使用方式

实现位于 scripts/security-bench.mjs。

从已安装的 @metaharness/darwin 运行 metaharness-darwin security bench --population N --cycles N [--seed S](版本固定在 _darwin.mjs;仅当没有符合条件的已安装副本时才进行一次性缓存安装——绝不使用 npx)。

默认超时 = 3s × 19 次评估 × population × cycles + 30s 开销。默认 --population 2 --cycles 1 约 144s;--population 4 --cycles 3 约 12 分钟。

输出结构示例:

{ "success": true, "data": { "overall": { "ok": true, "icon": "✅" }, "gates": { "total": 11, "passed": 11, "failed": 0, "details": [{ "ok": true, "criterion": "TPR improvement ≥ 25% vs fixed harness", "measured": "+150% (B2 0.4 → B3 1)" }, ...] }, "baselines": [ { "harness": "static-only", "fitness": 0.5665, "tpr": 0.3, "fpr": 1, "unsafe": 0, ... }, { "harness": "LLM single-pass", "fitness": 0.1365, ... }, { "harness": "fixed agent", "fitness": 0.598, ... }, { "harness": "Darwin champion", "fitness": 0.93275, "tpr": 1, "fpr": 0, ... } ], "rawMarkdown": "...", "shape": { "population": 2, "cycles": 1, "seed": null }, "durationMs": 142000 } }

接入 ADR-155 夜间 harness

ADR-155 夜间工作流(按 #2418 任务 W1.5)会将其作为主动渗透测试维度的一次调用启动,其结果成为一条轨迹记录:

{ "dimension": "mcp-pentest", "subdimension": "darwin-shield-bench", "champion_fitness": 0.93275, "champion_tpr": 1, "champion_fpr": 0, "gates_passed": 11, "gates_failed": 0, "shape": { "population": 4, "cycles": 3 } }

Loop A 据此学习:如果 darwin-shield-bench 在种子语料上持续通过,则对仅由 mcp-pentest 捕获的发现赋予更高权重。

退出码

  • 0:基准已运行(整体 PASS 或 FAIL——通过 JSON overall.ok 区分),或降级。
  • 1:--alert-on-fail 且 overall.ok === false。
  • 2:配置错误或上游基础设施故障。

优雅降级

当 @metaharness/darwin 不存在时,输出 {degraded: true, reason: 'metaharness-darwin-not-available'} 并以退出码 0 退出。

限制

资料未提供该技能的收费、价格、支持平台或具体效果保证等信息。