Slither
$ slither 官方出品 低风险Slither(slither)对 Solidity 和 Vyper 智能合约执行快速的 AST、SSA 与数据流漏洞分析,兼容 Foundry、Hardhat、Truffle 及独立 .sol 文件。传入 --json - 可将结构化检测结果流式输出到 stdout,配合 --exclude-informational 与 --detect 可保持 Agent 审计结果精简。
pip install slither-analyzer 在 Foundry 或 Hardhat 工作区中直接运行 slither . --json - 可直接调用本地 solc 工具链,无需通过 MCP 传输整套合约源码。
Agent 友好度体检单
当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。
FCRS-1.0 六维评分拆解
支持 --json - 标准输出流、--sarif、--detect、--exclude-informational 及 --list-detectors 自描述。
--json -streams structured detector output to stdout- Granular
--detect,--exclude-low, and--exclude-informationalfilters
静态分析工具,绝不部署或广播交易,但会在本地调用 solc / Foundry / Hardhat 构建命令。
- Purely local static analysis; compilation writes project build artifacts
可通过 pip install slither-analyzer 轻松安装,但项目需要匹配的 solc 版本(通常配合 solc-select)。
- PyPI package plus external
solccompiler dependency
业界标准的 Solidity 静态分析器,内置 90+ 检测器、打印器(human-summary、call-graph)及可升级性检查。
- Deep Solidity/Vyper IR (
SlithIR) analysis across Foundry and Hardhat
Trail of Bits 官方安全工程项目(crytic/slither),持续活跃更新。
- Trail of Bits Crytic organization
GitHub Wiki 上提供详尽的检测器目录、打印器指南和框架集成文档。
- Comprehensive detector docs in
crytic/slither/wiki
安全边界、鉴权与放权指南
本地合约审计无需任何凭据;拉取链上已验证合约时使用 --etherscan-apikey 或 ETHERSCAN_API_KEY。
本地审计 100% 免费、离线、开源(AGPL-3.0)。
# Slither Agent Rules - Always pass `--json -` (note the trailing `-` for stdout) and `--exclude-informational` to keep output structured and concise. - Verify the matching `solc` compiler version is active via `solc-select` before diagnosing compilation errors. - Remember Slither invokes Foundry/Hardhat compilation in the repo, which updates local `out/` or `artifacts/` directories.
Agent 高频安全命令配方
只读查询(安全推荐)
slither . --json - --exclude-informational --exclude-low
运行 Slither 检测器,过滤低危与信息类噪音,并将 JSON 结果写入 stdout(-)。
slither --list-detectors
在不编译合约的情况下输出所有内置检测器及其严重程度和置信度元数据。
受控写入与预演
slither . --sarif slither-results.sarif
将 SARIF v2.1.0 报告写入 slither-results.sarif,用于 CI 代码安全扫描。
核心优势
- + 原生支持
--json -标准输出流与--sarif导出,并可按严重性与检测器过滤。 - + 深度 Solidity/Vyper 中间表示(
SlithIR)分析,原生适配 Foundry、Hardhat 与solc。
注意事项与踩坑点
- ! 需要与合约 pragma 精确匹配的
solc版本(常需配合solc-select切换)。 - ! 运行
slither .会触发项目编译,未初始化依赖的工作区可能编译失败并写入构建产物。