audit-prep-assistant by trailofbits/skills
npx skills add https://github.com/trailofbits/skills --skill audit-prep-assistant帮助使用 Trail of Bits 的检查清单为安全审查做准备。准备充分的代码库能使审查过程更顺畅、更有效。
使用时机:安全审计前 1-2 周
帮助定义您希望从审查中获得什么:
关键问题:
记录目标并与评估团队分享。
运行静态分析并帮助修复容易解决的问题:
运行静态分析:
对于 Solidity:
slither . --exclude-dependencies
对于 Rust:
dylint --all
对于 Go:
golangci-lint run
对于 Go/Rust/C++:
# CodeQL 和 Semgrep 检查
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
然后我将:
提高测试覆盖率:
移除死代码:
目标:干净的静态分析报告、高测试覆盖率、最少的死代码
帮助使代码清晰且易于访问:
提供详细文件列表:
创建构建说明:
冻结稳定版本:
识别样板代码:
帮助创建文档:
流程图和序列图:
用户故事:
链上/链下假设:
参与者和权限:
外部开发者文档:
函数文档:
术语表:
视频演示(可选):
调用时,我将:
根据以下内容进行调整:
| 借口 | 为什么是错的 | 必需的行动 |
|---|---|---|
| "README 涵盖了设置,不需要详细的构建说明" | README 假设了审计员不具备的上下文 | 在新环境中测试构建,记录每个依赖项版本 |
| "静态分析已经运行过,不需要再次运行" | 代码库自上次运行后已更改 | 执行静态分析工具,生成新报告 |
| "测试覆盖率看起来不错" | "看起来不错"不是可衡量的覆盖率 | 运行覆盖率工具,识别特定的未测试代码路径 |
| "没多少死代码需要担心" | 死代码在手动审查中会被隐藏 | 使用自动检测工具查找未使用的函数/变量 |
| "架构很直接,不需要图表" | 文本描述会遗漏视觉模式 | 生成实际的流程图和序列图 |
| "可以在审计前立即冻结版本" | 最后一刻冻结会导致匆忙的交接 | 现在确定并记录提交哈希,创建专用分支 |
| "术语不言自明" | 领域知识并非普遍具备 | 创建包含所有领域特定术语的全面术语表 |
| "我稍后再做这一步" | 步骤相互依赖 - 跳过会产生差距 | 按顺序完成所有 4 个步骤,使用清单跟踪进度 |
当我帮助您完成准备后,您将获得具体的交付成果,例如:
=== 审计准备包 ===
项目:DeFi DEX 协议
审计日期:2024年3月15日
准备状态:完成
---
## 审查目标文档
安全目标:
- 验证流动性池交换的经济安全性
- 验证对 Oracle 操纵的抵抗能力
- 评估闪电贷攻击向量
关注领域:
1. 复杂的 AMM 定价计算 (src/SwapRouter.sol:89-156)
2. 多跳交换路由逻辑 (src/Router.sol)
3. Oracle 价格聚合 (src/PriceOracle.sol:45-78)
最坏情况:
- 闪电贷攻击通过 Oracle 操纵耗尽流动性池
给审计员的问题:
- AMM 定价模型在边缘情况下是否会产生负滑点?
- 滑点保护是否足以防止三明治攻击?
- 系统对临时 Oracle 故障的恢复能力如何?
---
## 静态分析报告
Slither 扫描结果:
✓ 高:0 个问题
✓ 中:0 个问题
⚠ 低:2 个问题(已分类 - 记录在 TRIAGE.md 中)
ℹ 信息:5 个问题(代码风格,可接受)
工具:slither . --exclude-dependencies
日期:2024年3月1日
状态:干净(所有关键问题已解决)
---
## 测试覆盖率报告
总体覆盖率:94%
- 语句:1,245 / 1,321 (94%)
- 分支:456 / 498 (92%)
- 函数:89 / 92 (97%)
未覆盖区域:
- 紧急暂停管理功能(手动测试)
- 治理迁移路径(一次性使用)
命令:forge coverage
状态:优秀
---
## 代码范围
范围内文件(8):
✓ src/SwapRouter.sol (456 行)
✓ src/LiquidityPool.sol (234 行)
✓ src/PairFactory.sol (389 行)
✓ src/PriceOracle.sol (167 行)
✓ src/LiquidityManager.sol (298 行)
✓ src/Governance.sol (201 行)
✓ src/FlashLoan.sol (145 行)
✓ src/RewardsDistributor.sol (178 行)
范围外:
- lib/ (OpenZeppelin, 外部依赖项)
- test/ (测试合约)
- scripts/ (部署脚本)
总范围内:2,068 行 Solidity 代码
---
## 构建说明
先决条件:
- Foundry 0.2.0+
- Node.js 18+
- Git
设置:
```bash
git clone https://github.com/project/repo.git
cd repo
git checkout audit-march-2024 # 冻结分支
forge install
forge build
forge test
验证:✓ 构建成功无错误 ✓ 所有 127 个测试通过 ✓ 编译器无警告
生成的工件:✓ ARCHITECTURE.md - 带图的系统概述 ✓ USER_STORIES.md - 12 个用户交互流程 ✓ GLOSSARY.md - 定义了 34 个领域术语 ✓ docs/diagrams/contract-interactions.png ✓ docs/diagrams/swap-flow.png ✓ docs/diagrams/state-machine.png
NatSpec 覆盖率:100% 的公共函数
网络:以太坊主网 提交:abc123def456 (audit-march-2024 分支) 已部署合约:
准备包已就绪,可供审计 ✓ 下一步:与 Trail of Bits 评估团队分享
---
## 您将获得什么
**审查目标文档**:
- 安全目标
- 关注领域
- 最坏情况
- 给审计员的问题
**干净的代码库**:
- 已分类的静态分析(或干净的报告)
- 高测试覆盖率
- 无死代码
- 清晰的范围
**可访问性包**:
- 带范围的文件列表
- 构建说明
- 冻结的提交/分支
- 已识别的样板代码
**文档套件**:
- 流程图和图表
- 用户故事
- 架构文档
- 参与者/权限映射
- 内联代码注释
- 术语表
- 视频演示(如已创建)
**审计准备清单**:
- [ ] 审查目标已记录
- [ ] 静态分析干净/已分类
- [ ] 测试覆盖率 >80%
- [ ] 死代码已移除
- [ ] 构建说明已验证
- [ ] 稳定版本已冻结
- [ ] 流程图已创建
- [ ] 用户故事已记录
- [ ] 假设已记录
- [ ] 参与者/权限已列出
- [ ] 函数文档完整
- [ ] 术语表已创建
---
## 时间表
**审计前 2 周**:
- 设定审查目标
- 运行静态分析
- 开始修复问题
**审计前 1 周**:
- 提高测试覆盖率
- 移除死代码
- 冻结稳定版本
- 开始文档工作
**审计前几天**:
- 完成文档
- 验证构建说明
- 创建最终清单
- 将包发送给审计员
---
## 准备就绪
请告诉我您何时准备好,我将帮助您为安全审查做准备!
每周安装量
1.1K
仓库
GitHub 星标
3.9K
首次出现
Jan 19, 2026
安全审计
安装于
claude-code993
opencode968
gemini-cli949
codex945
cursor911
github-copilot881
Helps prepare for a security review using Trail of Bits' checklist. A well-prepared codebase makes the review process smoother and more effective.
Use this : 1-2 weeks before your security audit
Helps define what you want from the review:
Key Questions :
Documents goals to share with the assessment team.
Runs static analysis and helps fix low-hanging fruit:
Run Static Analysis :
For Solidity:
slither . --exclude-dependencies
For Rust:
dylint --all
For Go:
golangci-lint run
For Go/Rust/C++:
# CodeQL and Semgrep checks
Then I'll:
Increase Test Coverage :
Remove Dead Code :
Goal : Clean static analysis report, high test coverage, minimal dead code
Helps make code clear and accessible:
Provide Detailed File List :
Create Build Instructions :
Freeze Stable Version :
Identify Boilerplate :
Helps create documentation:
Flowcharts and Sequence Diagrams :
User Stories :
On-chain/Off-chain Assumptions :
Actors and Privileges :
External Developer Docs :
Function Documentation :
Glossary :
Video Walkthroughs (optional):
When invoked, I will:
Adapts based on:
| Rationalization | Why It's Wrong | Required Action |
|---|---|---|
| "README covers setup, no need for detailed build instructions" | READMEs assume context auditors don't have | Test build on fresh environment, document every dependency version |
| "Static analysis already ran, no need to run again" | Codebase changed since last run | Execute static analysis tools, generate fresh report |
| "Test coverage looks decent" | "Looks decent" isn't measured coverage | Run coverage tools, identify specific untested code paths |
| "Not much dead code to worry about" | Dead code hides during manual review | Use automated detection tools to find unused functions/variables |
| "Architecture is straightforward, no diagrams needed" | Text descriptions miss visual patterns | Generate actual flowcharts and sequence diagrams |
| "Can freeze version right before audit" | Last-minute freezing creates rushed handoff | Identify and document commit hash now, create dedicated branch |
| "Terms are self-explanatory" | Domain knowledge isn't universal | Create comprehensive glossary with all domain-specific terms |
When I finish helping you prepare, you'll have concrete deliverables like:
=== AUDIT PREP PACKAGE ===
Project: DeFi DEX Protocol
Audit Date: March 15, 2024
Preparation Status: Complete
---
## REVIEW GOALS DOCUMENT
Security Objectives:
- Verify economic security of liquidity pool swaps
- Validate oracle manipulation resistance
- Assess flash loan attack vectors
Areas of Concern:
1. Complex AMM pricing calculation (src/SwapRouter.sol:89-156)
2. Multi-hop swap routing logic (src/Router.sol)
3. Oracle price aggregation (src/PriceOracle.sol:45-78)
Worst-Case Scenario:
- Flash loan attack drains liquidity pools via oracle manipulation
Questions for Auditors:
- Can the AMM pricing model produce negative slippage under edge cases?
- Is the slippage protection sufficient to prevent sandwich attacks?
- How resilient is the system to temporary oracle failures?
---
## STATIC ANALYSIS REPORT
Slither Scan Results:
✓ High: 0 issues
✓ Medium: 0 issues
⚠ Low: 2 issues (triaged - documented in TRIAGE.md)
ℹ Info: 5 issues (code style, acceptable)
Tool: slither . --exclude-dependencies
Date: March 1, 2024
Status: CLEAN (all critical issues resolved)
---
## TEST COVERAGE REPORT
Overall Coverage: 94%
- Statements: 1,245 / 1,321 (94%)
- Branches: 456 / 498 (92%)
- Functions: 89 / 92 (97%)
Uncovered Areas:
- Emergency pause admin functions (tested manually)
- Governance migration path (one-time use)
Command: forge coverage
Status: EXCELLENT
---
## CODE SCOPE
In-Scope Files (8):
✓ src/SwapRouter.sol (456 lines)
✓ src/LiquidityPool.sol (234 lines)
✓ src/PairFactory.sol (389 lines)
✓ src/PriceOracle.sol (167 lines)
✓ src/LiquidityManager.sol (298 lines)
✓ src/Governance.sol (201 lines)
✓ src/FlashLoan.sol (145 lines)
✓ src/RewardsDistributor.sol (178 lines)
Out-of-Scope:
- lib/ (OpenZeppelin, external dependencies)
- test/ (test contracts)
- scripts/ (deployment scripts)
Total In-Scope: 2,068 lines of Solidity
---
## BUILD INSTRUCTIONS
Prerequisites:
- Foundry 0.2.0+
- Node.js 18+
- Git
Setup:
```bash
git clone https://github.com/project/repo.git
cd repo
git checkout audit-march-2024 # Frozen branch
forge install
forge build
forge test
Verification: ✓ Build succeeds without errors ✓ All 127 tests pass ✓ No warnings from compiler
Generated Artifacts: ✓ ARCHITECTURE.md - System overview with diagrams ✓ USER_STORIES.md - 12 user interaction flows ✓ GLOSSARY.md - 34 domain terms defined ✓ docs/diagrams/contract-interactions.png ✓ docs/diagrams/swap-flow.png ✓ docs/diagrams/state-machine.png
NatSpec Coverage: 100% of public functions
Network: Ethereum Mainnet Commit: abc123def456 (audit-march-2024 branch) Deployed Contracts:
PACKAGE READY FOR AUDIT ✓ Next Step: Share with Trail of Bits assessment team
---
## What You'll Get
**Review Goals Document**:
- Security objectives
- Areas of concern
- Worst-case scenarios
- Questions for auditors
**Clean Codebase**:
- Triaged static analysis (or clean report)
- High test coverage
- No dead code
- Clear scope
**Accessibility Package**:
- File list with scope
- Build instructions
- Frozen commit/branch
- Boilerplate identified
**Documentation Suite**:
- Flowcharts and diagrams
- User stories
- Architecture docs
- Actor/privilege map
- Inline code comments
- Glossary
- Video walkthroughs (if created)
**Audit Prep Checklist**:
- [ ] Review goals documented
- [ ] Static analysis clean/triaged
- [ ] Test coverage >80%
- [ ] Dead code removed
- [ ] Build instructions verified
- [ ] Stable version frozen
- [ ] Flowcharts created
- [ ] User stories documented
- [ ] Assumptions documented
- [ ] Actors/privileges listed
- [ ] Function docs complete
- [ ] Glossary created
---
## Timeline
**2 weeks before audit**:
- Set review goals
- Run static analysis
- Start fixing issues
**1 week before audit**:
- Increase test coverage
- Remove dead code
- Freeze stable version
- Start documentation
**Few days before audit**:
- Complete documentation
- Verify build instructions
- Create final checklist
- Send package to auditors
---
## Ready to Prep
Let me know when you're ready and I'll help you prepare for your security review!
Weekly Installs
1.1K
Repository
GitHub Stars
3.9K
First Seen
Jan 19, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
claude-code993
opencode968
gemini-cli949
codex945
cursor911
github-copilot881
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
103,800 周安装
| "I'll do this step later" | Steps build on each other - skipping creates gaps | Complete all 4 steps sequentially, track progress with checklist |