caliperforge/chimera-template-pack

GitHub: caliperforge/chimera-template-pack

Chimera模板包:智能合约模糊测试环境搭建模板。

Stars: 0 | Forks: 0

# chimera-template-pack [![ci](https://static.pigsec.cn/wp-content/uploads/repos/2026/06/19e6a34df6030243.svg)](https://github.com/caliperforge/chimera-template-pack/actions/workflows/ci.yml) **可重用的 Foundry + Recon Chimera 脚手架,用于 CaliperForge 竞赛参赛作品。** 此模板生成每个 Cantina / Code4rena / 等效竞赛参赛作品附带的 标准 CaliperForge 公共-OSS 艺术品:一个可分叉的 Foundry 项目, 预先配置了 [Recon 的 Chimera](https://github.com/Recon-Fuzz/create-chimera-app) 状态性模糊模式 (Echidna + Medusa),包含三个种子协议特定不变量,一个模糊战役 运行器,以及一个 GitHub Actions CI 作业,该作业运行战役并将分数卡写入 `findings/` 在每次推送时。 源自: - [Recon-Fuzz/create-chimera-app](https://github.com/Recon-Fuzz/create-chimera-app)(此模板跟踪的上游模式)。 - 在 [cf-invariants-anchor](https://github.com/caliperforge/cf-invariants-anchor) 中使用的 CaliperForge 分数卡约定(ANSI 清理后的 捕获提交到 `findings//scorecard.{json,md}`)。 这是一个 **模板**,不是一个项目。使用 GitHub 上的 **Use this template** 按钮 (或 `gh repo create --template`)来生成竞赛参赛作品。在分叉仓库中的第一个操作是 遵循 [USAGE.md](./USAGE.md)。 ## 脚手架测试的内容 模式:**将目标协议的合约分叉到 `src/`,然后运行一个状态性模糊 战役,猛烈打击协议的公共表面以寻找不变量违规。** 三个种子不变量包含在 `test/recon/Properties.sol` 中,每个都带有 一个 `TODO(protocol)` 注释,指示分叉所有者必须提供的协议特定绑定: 1. **`INV-001 — 偿付能力 / 代币保存。** 用户端余额总和等于 合约端的会计。常见故障类别:提款 / 声明路径上的账目漂移。 2. **`INV-002 — 单调股价(或等效指数)。** 在仅存款或非重置条件下, 股价/指数价格永远不会下降。常见故障类别:捐赠攻击,首次存款时的股价操纵。 3. **`INV-003 — 访问控制限制。** 当由非特权参与者调用时,特权函数会回滚。 常见故障类别:在管理员 / 暂停 / 救援函数上缺少修饰符。 预期分叉将 **重命名、替换或扩展** 这些——它们是根据 常见的 Cantina/Code4rena 发现类别塑造的种子,而不是特定于协议的断言。 源中的 `TODO(protocol)` 标记是明确的编辑点。 发现目录包含一个示例预计算的分数卡 (`findings/INV-001-solvency/scorecard.expected.{json,md}`),显示 CI 在每次推送时捕获到 `findings//scorecard.{json,md}` 的形状。 ## 从全新克隆复制 ``` git clone https://github.com/caliperforge/chimera-template-pack.git cd chimera-template-pack # 1. Install Foundry (https://book.getfoundry.sh/getting-started/installation). curl -L https://foundry.paradigm.xyz | bash && foundryup # 2. Install Echidna + Medusa. # Echidna: https://github.com/crytic/echidna/releases # Medusa: https://github.com/crytic/medusa/releases # 3. Install forge deps (forge-std + recon-cyfrin/chimera). forge install # 4. Build. forge build # 5. Run the foundry-side sanity test (CryticToFoundry replays the campaign harness # under forge for fast local debug). forge test --match-path test/recon/CryticToFoundry.sol # 6. Run a short Echidna campaign + capture the scorecard. make echidna # 7. (Optional) Run a Medusa campaign. make medusa ``` 捆绑的 CI 工作流程在每次推送时执行步骤 3-6——绿色徽章 = 在 随附的脚手架上的干净运行。 ## 固定工具链 这些版本是 CI 构建所针对的合同。分叉应同步提升,而不是无声地漂移。 | 工具 | 固定 | 为什么 | |------|--------|-----| | Foundry | `nightly`(CI 使用 `foundry-rs/foundry-toolchain@v1`,每次运行的最新夜间版本) | Recon 的 create-chimera-app 跟踪 Foundry 夜间版本;进一步固定会风险与上游模式脱节。 | | Solidity | `0.8.28`(在 `foundry.toml` 中声明) | 最近稳定;与大多数当前协议目标兼容的 ABI。如果目标协议固定了特定的 Solidity 版本,则分叉将覆盖此版本。 | | `forge-std` | `v1.9.4` | 稳定的 forge std 库。 | | `chimera` ([Recon-Fuzz/chimera](https://github.com/Recon-Fuzz/chimera)) | `main`(上游库不标记版本;CI 在每次运行时重新安装) | 跟踪 Recon 的 harness 包装器。 | | Echidna | `2.2.5` | Crytic 的稳定线,截至 2026-06。 | | Medusa | `0.1.7` | Crytic 的稳定线,截至 2026-06。 | 请参阅 [foundry.toml](./foundry.toml),[Makefile](./Makefile),以及 [`.github/workflows/ci.yml`](./.github/workflows/ci.yml) 以获取绑定参考。 ## 布局 ``` chimera-template-pack/ ├── foundry.toml # solc / remappings / fuzz config ├── remappings.txt # explicit remappings (echidna + medusa read these) ├── echidna.yaml # echidna campaign config ├── medusa.json # medusa campaign config ├── Makefile # make echidna / make medusa / make scorecard ├── src/ # TODO(protocol): drop target contracts here ├── lib/ # forge deps (forge-std, chimera) ├── test/ │ └── recon/ # Chimera-pattern harness │ ├── Setup.sol # TODO(protocol): wire deploys / actors │ ├── TargetFunctions.sol # TODO(protocol): expose protocol fns to fuzzer │ ├── Properties.sol # 3 seeded invariants — rename / extend │ ├── BeforeAfter.sol # snapshot helpers for monotonicity checks │ └── CryticToFoundry.sol # forge-runnable replay harness ├── findings/ # CI writes scorecard.{json,md} per invariant │ └── INV-001-solvency/ # example pre-computed expected scorecard ├── scripts/ │ ├── run_campaign.sh # echidna / medusa runner + scorecard capture │ └── capture_scorecard.sh # ANSI-strip + scorecard.{json,md} renderer ├── prompts/ │ └── invariant_suggestion_v1.txt # optional AI-suggestion prompt (mirrors cf-invariants) ├── docs/ │ └── ai-disclosure.md # what AI does in this scaffold, how to disable ├── .github/workflows/ci.yml # build + sample campaign + scorecard capture ├── LICENSE # Apache-2.0 ├── LICENSE-MIT-CARVEOUT.md # MIT note for upstream-merge subset ├── README.md # this file (forks edit) └── USAGE.md # 6-step "stamp out a contest entry" checklist ``` ## 许可证 Apache-2.0。请参阅 [LICENSE](./LICENSE)。 当分叉打算合并到目标协议的 MIT 许可证 代码库中时,将应用 MIT 切片——请参阅 [LICENSE-MIT-CARVEOUT.md](./LICENSE-MIT-CARVEOUT.md)。 由人工智能辅助构建;源中标记了人工智能建议的不变量。完整政策在 [caliperforge.com/ai-disclosure](https://caliperforge.com/ai-disclosure)。请参阅 [docs/ai-disclosure.md](./docs/ai-disclosure.md) 以获取存储库中的详细信息。 chimera-template-pack 由 Michael Moffett 在 CaliperForge 标志下运营。 联系方式:michael@caliperforge.com(创始人),team@caliperforge.com(组织)。