用途:为 OpenTaint 的规则(source/sink)或数据流近似创建最小可编译测试项目,用可复现的样本验证某条规则或近似。样本让数据在真实库方法与脚手架提供的通用污点标记之间流动,每个样本只对应一个必须产生的判定:必须命中的正样本,或必须不命中的负样本。交付物是编译出的模型,样本源码与其放在一起。
必要输入:language(语言,必填)、type(rule-source、rule-sink 或 dataflow,必填)。project-root 可选,默认当前目录;OpenTaint 工件固定放在 <project-root>/.opentaint/ 下。rule-source/rule-sink 需 unit(其成员与依赖来自 .opentaint/tracking/rules/sources|sinks/<unit>.yaml);dataflow 需 batch(数据流方法来自 .opentaint/tracking/approximations/<batch>.yaml)。项目文件夹名即该标识符。
用法:按语言与类型读取对应参考(rule 看 references/<lang>-rule.md,dataflow 看 references/<lang>-approximation.md),脚手架会提供通用污点标记与固定测试规则,只需编写样本;sink 单元的方法嵌在 groups[].sinks 下,需保留分组边界;样本判定记录在 rule-test.yaml。若项目已存在则扩展而非重建。编译命令:rule 侧用 opentaint compile .opentaint/test-projects/<name>/sources -o .opentaint/test-compiled/<name>/sources;dataflow 用 opentaint compile .opentaint/test-projects/<name> -o .opentaint/test-compiled/<name>。编译通过即完成该阶段。
适用场景与限制:OpenTaint 是整程序、跨过程、字段敏感的别名分析引擎,已能传播可见应用代码、调用、别名与字段;自定义规则和近似只建模指定的 source、sink 或不透明方法边界。编译期常量与字面量不带污点,输出仅常量的 source 或 carrier 不引入污点。每个 unit 一个 <name> 文件夹,不要写入其他 unit 的测试项目以免并发冲突。连续约 3 次修复仍无法编译时报告失败并保持该阶段为 pending。失败或无法编写样本的方法需标记 failed 并说明原因。具体 scaffold 命令与样本代码形式以对应语言参考为准。