cognis-digital/storagelens

GitHub: cognis-digital/storagelens

一款智能合约存储布局差异对比工具,通过在代理升级时检测存储冲突和未初始化槽位来防止数据损坏。

Stars: 0 | Forks: 0

STORAGELENS # STORAGELENS ### 对比和解码跨代理升级的合约存储布局,以捕获存储冲突和未初始化槽的 bug。 [![PyPI](https://img.shields.io/pypi/v/cognis-storagelens.svg?color=6b46c1)](https://pypi.org/project/cognis-storagelens/) [![CI](https://static.pigsec.cn/wp-content/uploads/repos/2026/06/6fea357833162751.svg)](https://github.com/cognis-digital/storagelens/actions) [![License: COCL 1.0](https://img.shields.io/badge/License-COCL%201.0-2b6cb0.svg)](LICENSE) [![Suite](https://img.shields.io/badge/Cognis-Neural%20Suite-6b46c1.svg)](https://github.com/cognis-digital) *Web3 与智能合约安全 — 链上安全与分析。*
``` pip install cognis-storagelens storagelens scan . # → prioritized findings in seconds ``` ## 用法 — 逐步指南 1. **安装** (Python 3.9+): pip install storagelens 2. **对比两个存储布局。** 将旧布局与新布局进行对比,以发现升级风险: storagelens diff old_layout.json new_layout.json 3. **以 JSON 格式读取输出**用于工具处理: storagelens --format json diff old_layout.json new_layout.json | jq . 4. **检查版本**以便在环境中固定版本: storagelens --version 5. **在 CI 中进行拦截。** 退出码 `0` 表示布局与升级兼容;`1` 表示检测到存储冲突(拦截失败);`2` 表示使用错误: storagelens diff old_layout.json new_layout.json || echo "Storage collision detected" ## 目录 - [为什么选择 storagelens?](#why) · [功能](#features) · [快速开始](#quick-start) · [示例](#example) · [架构](#architecture) · [AI 栈](#ai-stack) · [对比](#how-it-compares) · [集成](#integrations) · [任意平台安装](#install-anywhere) · [相关工具](#related) · [贡献](#contributing) ## 为什么选择 storagelens? 存储冲突 bug 会导致可升级代理静默损坏;一个对比版本间布局的 CI 拦截机制是必不可少的,但目前没有独立的工具包提供此功能。 `storagelens` 是单一用途、可脚本化且可自托管的:将其指向目标,以您的工作流已支持的格式(表格 · JSON · SARIF)获取优先级排序的结果,据此拦截 CI,并允许代理通过 MCP 驱动它。
↑ 回到顶部
## 功能 - ✅ 解析布局 - ✅ 加载布局 - ✅ 对比布局 - ✅ 可在 Linux/macOS/Windows · Docker · devcontainer 上运行 - ✅ 支持 Python、JavaScript、Go 和 Rust 版本 (`ports/`)
↑ 回到顶部
## 快速开始 ``` pip install cognis-storagelens storagelens --version storagelens scan . # scan current project storagelens scan . --format json # machine-readable storagelens scan . --fail-on high # CI gate (non-zero exit) ```
↑ 回到顶部
## 示例 ``` $ storagelens scan . [HIGH ] STO-001 example finding (./src/app.py) [MEDIUM ] STO-002 another signal (./config.yaml) 2 findings · risk score 5 · 38ms ```
↑ 回到顶部
## 架构 ``` flowchart LR IN[input] --> P[storagelens
analyze + score] P --> OUT[report] ```
↑ 回到顶部
## 从任何 AI 栈中使用 `storagelens` 与所有流行的 AI 使用方式兼容: - **MCP 服务器** — `storagelens mcp` (Claude Desktop, Cursor, Cognis.Studio, [uncensored-fleet](https://github.com/cognis-digital/uncensored-fleet)) - **兼容 OpenAI / JSON** — 将 `storagelens scan . --format json` 通过管道传递给任何代理或 LLM - **LangChain · CrewAI · AutoGen · LlamaIndex** — 用一行代码将 CLI/JSON 封装为工具 - **CI / 脚本** — 为非 AI 流水线提供退出码 + SARIF
↑ 回到顶部
## 对比 | | **Cognis storagelens** | OpenZeppelin Upgrades plugin | |---|:---:|:---:| | 可自托管,无需账号 | ✅ | 视情况而定 | | 单条命令,零配置 | ✅ | ⚠️ | | 用于 CI 的 JSON + SARIF | ✅ | 视情况而定 | | MCP 原生支持(AI 代理) | ✅ | ❌ | | 多语言端口 (JS/Go/Rust) | ✅ | ❌ | | 开源许可 | ✅ COCL | 视情况而定 | *秉承 **OpenZeppelin Upgrades plugin** 的精神,以 Cognis 的方式重新构建。漏掉了谁的致谢?提交一个 PR 吧。*
↑ 回到顶部
## 集成 接入您的技术栈:用于代码扫描的 **SARIF**,用于一切的 **JSON**,用于 AI 代理的 **MCP 服务器**(`storagelens mcp`),以及用于 SIEM/Slack/Jira 的 webhook 转发器。详见 [`docs/INTEGRATIONS.md`](docs/INTEGRATIONS.md)。
↑ 回到顶部
## 安装 — 各种方式,各个平台 ``` pip install "git+https://github.com/cognis-digital/storagelens.git" # pip (works today) pipx install "git+https://github.com/cognis-digital/storagelens.git" # isolated CLI uv tool install "git+https://github.com/cognis-digital/storagelens.git" # uv pip install cognis-storagelens # PyPI (when published) docker run --rm ghcr.io/cognis-digital/storagelens:latest --help # Docker brew install cognis-digital/tap/storagelens # Homebrew tap curl -fsSL https://raw.githubusercontent.com/cognis-digital/storagelens/main/install.sh | sh ``` | Linux | macOS | Windows | Docker | Cloud | |---|---|---|---|---| | `scripts/setup-linux.sh` | `scripts/setup-macos.sh` | `scripts/setup-windows.ps1` | `docker run ghcr.io/cognis-digital/storagelens` | [DEPLOY.md](docs/DEPLOY.md) (AWS/Azure/GCP/k8s) |
↑ 回到顶部
## 相关 Cognis 工具 - [`reentryx`](https://github.com/cognis-digital/reentryx) — 静态 + 符号执行检测器,标记 Solidity/Vyper 中的重入、跨函数和只读重入路径,并输出用于 CI 拦截的 SARIF。 - [`forkfuzz`](https://github.com/cognis-digital/forkfuzz) — 主网分叉不变性模糊测试工具,针对实时状态和有状态序列重放您的合约,以在部署前破坏协议不变性。 - [`approvewarden`](https://github.com/cognis-digital/approvewarden) — 扫描任何钱包中的危险 ERC-20/721/1155 代币授权和无限额度,对资产被盗风险进行评分并生成撤销交易。 - [`mevscope`](https://github.com/cognis-digital/mevscope) — 重放交易或地址历史,以归因三明治攻击、抢跑和尾随 MEV 提取,并进行每笔交易的损失核算。 - [`rugradar`](https://github.com/cognis-digital/rugradar) — 代币合约风险扫描器,在您盲目投资之前检测蜜罐、隐藏的铸币/黑名单功能、所有者后门以及未锁定的流动性。 - [`sigsleuth`](https://github.com/cognis-digital/sigsleuth) — 将原始 calldata 和 EIP-712 类型数据解码为人类可读的意图,标记盲目签名和恶意的 permit/Permit2 payload。 **探索套件 →** [🗂️ 全部 170+ 工具](https://github.com/cognis-digital/cognis-neural-suite) · [⭐ awesome-cognis](https://github.com/cognis-digital/awesome-cognis) · [🔗 cognis-sources](https://github.com/cognis-digital/cognis-sources) · [🤖 uncensored-fleet](https://github.com/cognis-digital/uncensored-fleet) · [🧠 engram](https://github.com/cognis-digital/engram)
↑ 回到顶部
## 互操作性 `{}` 与 300+ 工具的 Cognis 套件组合使用 — JSON 输入/输出以及共享的 兼容 OpenAI 的 `/v1` 主干网络。有关套件映射、组合模式和参考技术栈, 请参阅 **[INTEROP.md](INTEROP.md)**。 ## 许可证 源代码可见,基于 **Cognis Open Collaboration License (COCL) v1.0** — 可免费用于个人、内部评估、研究和教育用途;**商业/生产用途需要许可证** (licensing@cognis.digital)。详见 [LICENSE](LICENSE)。
Cognis Digital · Cognis Neural Suite 中的 170+ 工具之一 · 让明天在今天更美好
标签:SOC Prime, Web3安全, 以太坊, 可视化界面, 安全漏洞检测, 开发工具, 数据可视化, 日志审计, 智能合约审计, 请求拦截, 逆向工具