AI 优先的安全扫描器。v2026.7 新增:Claude Code 失陷检测——在克隆前审查 .claude/ 钩子、权限与技能——另配备常驻的 AI 攻击特征扫描器,以及原生 Rust 与 PHP 规则。此外:medusa scan --git 可审查任意仓库,medusa secrets scan 可扫描泄露的 API 密钥。40,000+ 种模式,零配置。
AI 优先的安全扫描器,拥有 40,000+ 检测模式,覆盖 AI/ML、代理和 LLM 应用。
🤖 开箱即用 - 无需安装任何工具。
🚨 200 个 CVE:Log4Shell、Spring4Shell、XZ Utils、LangChain RCE、MCP-Remote RCE、React2Shell
🔥 medusa scan --git <URL> — 扫描任意仓库以发现 AI 供应链攻击(仓库投毒、提示注入、MCP 工具投毒)
🔐 medusa secrets scan — 在你的 Claude / Cursor / Copilot / shell 历史记录中发现泄漏的 API 密钥。支持 21 种签发者类型。交互式就地脱敏。
🚀 v2026.7.0:Claude Code 失陷检测、常驻的 AI 攻击特征扫描器、原生 Rust 和 PHP 安全规则,以及规则级诊断 — 基于 40,000+ 检测模式之上。
MEDUSA 是一款 AI 优先的安全扫描器,拥有 40,000+ 检测模式,开箱即用。只需安装并扫描 — 无需安装任何外部工具。MEDUSA 的内置规则可检测 AI/ML 应用、LLM 代理、MCP 服务器、RAG 流水线和传统代码中的漏洞。
medusa scan --git <URL> - 数秒内扫描任意 GitHub 仓库,检测 AI 供应链攻击medusa secrets scan + purge - 查找泄漏到 Claude Code / Cursor / Copilot / Zed / Gemini 聊天记录以及你的 bash / zsh / psql / mysql / python REPL 历史中的 API 密钥 / 令牌 / 私钥。支持 21 种签发者类型(Anthropic、OpenAI、PyPI、GitHub PAT、AWS、GCP、Stripe、Slack…)。交互式 [y/n/s/a/q] 清除,强制生成字节级一致的备份,并采用 JSONL 安全的脱敏方式。仅本地处理,无遥测。pip install 后立即可用 - 无需安装工具.medusa.yml 进行项目级设置Claude Code 供应链检测、更广泛的语言覆盖,以及规则级可观测性。
| 变更 | 详情 | |
|---|---|---|
| 🛡️ | Claude Code 失陷检测 | medusa scan --git 现在会在你克隆之前对 .claude/ 进行结构性审查 — 被投毒的 hooks(curl|bash、base64→exec、凭据外泄、反向 shell)、过度宽泛的 permissions(Bash(*)、bypassPermissions)、通配符工具 subagents,以及投放器 skills。 |
| 🎯 | 常驻攻击特征扫描器 | 弥补假阴性空白 — 数据文件(.jsonl/.csv)和普通文本中的越狱 / 提示注入载荷现在无论 LLM 上下文置信度如何都会被捕获,此外还支持隐形 Unicode / 双向文本(Trojan Source,CVE-2021-42574)恢复。 |
| 🦀 | 原生 Rust 安全规则 | 22 条开箱即用的规则(无需工具链)— 禁用 TLS 验证、命令注入、不可信反序列化、原始 SQL、不安全的内存操作、弱加密、SSRF。 |
| 🐘 | 原生 PHP 安全规则 | 16 条开箱即用的规则 — SQLi、命令/eval 注入、LFI/RFI、路径遍历、unserialize() 对象注入、无限制上传、反射型 XSS、SSRF、弱加密。 |
| 🔬 | 规则诊断(--trace-rules) | 每条规则的触发日志 + 计时(rule-trace.jsonl、slow_rules.csv),以及可抵御挂起的心跳机制 — 发现并修复了一个真实的灾难性回溯 ReDoS,还新增了一条 ReDoS/嵌套集合 lint 规则,可在编写时阻止不良模式。 |
| ⚡ | 引擎 + 准确性 | 扫描引擎性能快速优化、针对 --git 目标审核的上下文感知筛选模式、大文件字节上限采样,以及文档占位符导致秘密误报的修复。 |
v2026.5.12 — 最大的模式发布:检测模式从 9,600 增至 40,000+,从 8,466 篇 AI 安全研究论文中提取,并进行了误报加固;新增结构性规则完整性扫描器。
v2026.5.10 — 安全加固:修复 VS Code 扩展命令注入漏洞、--fail-on 缓存发现缺陷、工具缓存过期路径问题,用户主目录 MCP 配置改为需主动启用(opt-in)。
v2026.5.9 — 智能体商务覆盖:UCPScanner + AP2Scanner + 45 条手工调优的正向模式规则。
v2026.5.8 — medusa secrets:扫描 AI 聊天与 shell 历史中的泄漏凭据(21 种签发者类型),支持交互式 [y/n/s/a/q] 清除。
v2026.5.7 — 间接提示注入规则(101/102)、供应链导入扫描器、macOS/Windows 多进程修复。
v2026.5.5 — 安全加固发布(argv 注入防御、git SSRF、HMAC 缓存完整性、markdown XSS 修复)。
外部 Linter(可选):MEDUSA 会自动检测已安装的 bandit、eslint、shellcheck 等工具。参见 可选工具指南。
你的 PyPI 令牌现在可能就在你的 Claude 聊天记录里。
开发人员每天都在将 API 密钥、令牌和凭据粘贴到 AI 助手中 —
「用 pypi-AgEI... 部署这个」、「用我的 ghp_... 推送」、「AWS 密钥是 AKIA...」。
这些助手将对话以明文形式保存在磁盘上。任何对 $HOME 有读取权限的人 — 或任何未来拥有 shell 访问权限的恶意软件 — 都可以执行 grep -r 'sk-\|ghp_\|AKIA' ~/
并在数秒内收割生产凭据。
medusa secrets scan 会找到它们。medusa secrets purge 会清理它们。
medusa secrets scan
The input section is empty — no chunk content was provided to translate. Please supply the source text for chunk 3 of 73, and I’ll translate it into Chinese following all the formatting rules.```text
Scanning 118 file(s)...
── claude-code ──────────────────────────────────────────────
/home/ross/.claude/history.jsonl (13 finding(s))
[CRITICAL] Anthropic API key (anthropic)
/home/ross/.claude/history.jsonl:1005:13
sk-ant-api03***...***
[CRITICAL] PyPI API token (pypi)
/home/ross/.claude/history.jsonl:125:94
pypi-AgEIc***...***
[CRITICAL] GitHub fine-grained PAT (github)
/home/ross/.claude/history.jsonl:2306:13
github_pat_11A***...***
[HIGH] HuggingFace token (huggingface)
/home/ross/.claude/history.jsonl:3387:13
hf_JOi***...***
...
Total: 13 credentials across 1 file(s).
Report: /home/ross/.medusa/secrets-scan/secrets-20260519-074452.json
The input chunk is empty — there is no translatable content provided. Please supply chunk 5 of 73 so I can translate it.```bash medusa secrets purge
The input content appears to be empty — no source text was provided after "INPUT:". Please supply the actual Markdown chunk you'd like translated.```text
[CRITICAL] PyPI API token (pypi)
/home/ross/.claude/history.jsonl:125:94
pypi-AgEIc***...***
redact? [y/n/s/a/q/?]: y
[CRITICAL] Anthropic API key (anthropic)
/home/ross/.claude/history.jsonl:1005:13
sk-ant-api03***...***
redact? [y/n/s/a/q/?]: y
...
✓ /home/ross/.claude/history.jsonl (13 redacted)
backup → /home/ross/.medusa/secrets-scan/backups/20260519-074452/home/ross/.claude/history.jsonl
原始文件在每次更改前都会逐字节备份。JSONL 在脱敏后仍保持可解析。脱敏标记([REDACTED-MEDUSA-...-<run-id>])每次运行都是唯一的,因此你可以追溯到产生它的扫描。
medusa secrets scan # everything (default — chat + shell) medusa secrets scan --source ai-chats # AI assistants only medusa secrets scan --source shell # ~/.bash_history, ~/.zsh_history, fish, psql, mysql, ... medusa secrets scan --path FILE # explicit file (e.g. a ChatGPT export) medusa secrets scan --reveal # show real values (requires 'I UNDERSTAND')
medusa secrets purge # interactive [y/n/s/a/q] medusa secrets purge SCAN_ID # purge a specific report medusa secrets purge --all --yes-i-know # batch mode for power users / CI
### 检测内容(21 个签发方)
**AI 提供商**:Anthropic、OpenAI、HuggingFace、Replicate、Cohere
**软件包注册表**:PyPI、npm
**代码托管平台**:GitHub PAT(经典 + 细粒度 + OAuth + App)、GitLab PAT
**云服务**:AWS 访问密钥、GCP 服务账号 JSON
**支付 / 通信**:Stripe 在线/受限密钥、Slack 机器人/用户令牌、SendGrid、Twilio、Discord Webhook
**加密**:PEM 编码的私钥(RSA、DSA、EC、OpenSSH、PGP)
### 安全特性
- **仅本地运行。** 报告保存在 `~/.medusa/secrets-scan/` 目录下,权限为 `0o600`。无网络、无遥测、绝不写入项目目录树。
- **写入前备份。** 每次脱敏操作前都会创建字节级完全相同的备份。`cp` 命令可恢复。
- **JSONL 安全。** 脱敏标记不包含任何 JSON 不安全字符;写入后受影响的行会重新解析。
- **漂移时拒绝操作。** 如果源文件在扫描和清除之间发生了变化,清除工具将拒绝操作,而不是冒险覆盖编辑内容。
- **原子写入。** 临时文件 + `os.replace` 替换。要么重写生效,要么保留原文件。
[**📖 完整 secrets-scanner 指南 →**](https://github.com/pantheon-security/medusa/blob/main/docs/SECRETS_SCANNER.md)
---
## 🚀 快速开始
### 安装```bash
# Install MEDUSA (works on Windows, macOS, Linux)
pip install medusa-security
# Run your first scan - that's it!
medusa scan .
虚拟环境(推荐):```bash
python3 -m venv medusa-env source medusa-env/bin/activate # On Windows: medusa-env\Scripts\activate
pip install medusa-security medusa scan .
**平台说明:**
- **Windows**:如果找不到 `medusa` 命令,请使用 `py -m medusa`
- **macOS/Linux**:开箱即用
### 扫描任意 GitHub 仓库```bash
# Scan a remote repo for AI supply chain attacks
medusa scan --git https://github.com/org/repo
# Shorthand - just user/repo
medusa scan --git org/repo
# Scan a specific branch
medusa scan --git https://github.com/org/repo/tree/main
MEDUSA 可自动检测 28+ 个已知作为攻击向量的 AI 编辑器配置文件:
| 风险等级 | 检测到的文件 |
|---|---|
| 严重(RCE) | .cursorrules, .cursor/mcp.json, .clinerules/, .windsurfrules, .codex/config.toml, .kiro/settings/mcp.json, .vscode/settings.json, mcp.json |
| 高 | CLAUDE.md, GEMINI.md, AGENTS.md, AGENT.md, SKILL.md, .github/copilot-instructions.md, CONVENTIONS.md, .amazonq/rules/, .roo/rules/, .augment/rules/ |
已检测到的已知攻击:Clinejection、CurXecute (CVE-2025-54135)、IDEsaster (CVE-2025-64660)、ToxicSkills、CamoLeak、RoguePilot、AIShellJack、Cacheract
medusa install --ai-tools
### 可选:外部 Linter
MEDUSA 会自动检测是否安装了外部 Linter(如 bandit、eslint、shellcheck 等),并自动使用它们来增强扫描覆盖率。
**[查看安装指南 →](https://github.com/pantheon-security/medusa/blob/main/docs/OPTIONAL_TOOLS.md)** 以获取特定平台的说明。
> **注意:** 外部 Linter 是可选的。MEDUSA 内置的 40,000+ 条规则无需它们也能正常工作。如需安装支持,请参阅各工具供应商的文档。
### 演示
<div align="center">

</div>
### 📊 报告格式
MEDUSA 会生成多种格式的精美报告:
**JSON** - 机器可读,适合 CI/CD 集成```bash
medusa scan . --format json
HTML - 惊艳的玻璃拟态UI与交互式图表```bash medusa scan . --format html
**Markdown** - 适合 GitHub/wikis 的文档友好格式```bash
medusa scan . --format markdown
所有格式 - 一次生成所有内容```bash medusa scan . --format all
---
## 📚 语言支持
MEDUSA 支持 **79 种扫描器类型**,涵盖 AI/ML 安全、所有主流编程语言和文件格式:
### 后端语言(9 种)
| 语言 | 扫描器 | 扩展名 |
|----------|---------|------------|
| Python | Bandit | `.py` |
| JavaScript/TypeScript | ESLint | `.js`, `.jsx`, `.ts`, `.tsx` |
| Go | golangci-lint | `.go` |
| Ruby | RuboCop | `.rb`, `.rake`, `.gemspec` |
| PHP | Native rules (+ PHPStan optional) | `.php` |
| Rust | Native rules (+ Clippy optional) | `.rs` |
| Java | Checkstyle | `.java` |
| C/C++ | cppcheck | `.c`, `.cpp`, `.cc`, `.cxx`, `.h`, `.hpp` |
| C# | Roslynator | `.cs` |
### JVM 语言(3 种)
| 语言 | 扫描器 | 扩展名 |
|----------|---------|------------|
| Kotlin | ktlint | `.kt`, `.kts` |
| Scala | Scalastyle | `.scala` |
| Groovy | CodeNarc | `.groovy`, `.gradle` |
### 函数式语言(5 种)
| 语言 | 扫描器 | 扩展名 |
|----------|---------|------------|
| Haskell | HLint | `.hs`, `.lhs` |
| Elixir | Credo | `.ex`, `.exs` |
| Erlang | Elvis | `.erl`, `.hrl` |
| F# | FSharpLint | `.fs`, `.fsx` |
| Clojure | clj-kondo | `.clj`, `.cljs`, `.cljc` |
### 移动开发(2 种)
| 语言 | 扫描器 | 扩展名 |
|----------|---------|------------|
| Swift | SwiftLint | `.swift` |
| Objective-C | OCLint | `.m`, `.mm` |
### 前端与样式(3 种)
| 语言 | 扫描器 | 扩展名 |
|----------|---------|------------|
| CSS/SCSS/Sass/Less | Stylelint | `.css`, `.scss`, `.sass`, `.less` |
| HTML | HTMLHint | `.html`, `.htm` |
| Vue.js | ESLint | `.vue` |
### 基础设施即代码(4 种)
| 语言 | 扫描器 | 扩展名 |
|----------|---------|------------|
| Terraform | tflint | `.tf`, `.tfvars` |
| Ansible | ansible-lint | `.yml` (playbooks) |
| Kubernetes | kubeval | `.yml`, `.yaml` (manifests) |
| CloudFormation | cfn-lint | `.yml`, `.yaml`, `.json` (templates) |
### 配置文件(4 种)
| 语言 | 扫描器 | 扩展名 |
|----------|---------|------------|
| JSON | built-in | `.json` |
| TOML | taplo | `.toml` |
| XML | xmllint | `.xml` |
| Protobuf | buf lint | `.proto` |
### Shell 与脚本(4 种)
| 语言 | 扫描器 | 扩展名 |
|----------|---------|------------|
| Bash/Shell | ShellCheck | `.sh`, `.bash` |
| PowerShell | PSScriptAnalyzer | `.ps1`, `.psm1` |
| Lua | luacheck | `.lua` |
| Perl | perlcritic | `.pl`, `.pm` |
### 文档(2 种)
| 语言 | 扫描器 | 扩展名 |
|----------|---------|------------|
| Markdown | markdownlint | `.md` |
| reStructuredText | rst-lint | `.rst` |
### 其他语言(5 种)
| 语言 | 扫描器 | 扩展名 |
|----------|---------|------------|
| SQL | SQLFluff | `.sql` |
| R | lintr | `.r`, `.R` |
| Dart | dart analyze | `.dart` |
| Solidity | solhint | `.sol` |
| Docker | hadolint | `Dockerfile*` |
**总计:79 种扫描器类型 — 41 种语言/工具扫描器 + 38 种 AI/ML 安全扫描器 — 覆盖 100+ 种文件扩展名**
---
## 🚨 React2Shell CVE 检测(v2025.8 新增)
MEDUSA 现在可检测 **CVE-2025-55182 "React2Shell"** —— 一个影响 React Server Components 和 Next.js 的 CVSS 10.0 RCE 漏洞。```bash
# Check if your project is vulnerable
medusa scan .
# Vulnerable versions detected:
# - React 19.0.0 - 19.2.0 (Server Components)
# - Next.js 15.0.0 - 15.0.4 (App Router)
# - Various canary/rc releases
扫描范围:package.json、package-lock.json、yarn.lock、pnpm-lock.yaml
修复:升级至 React 19.0.1+ 和 Next.js 15.0.5+
MEDUSA 提供业界领先的 AI 安全扫描,配备 40,000+ 检测模式,面向智能体 AI 时代。已针对 OWASP Top 10 for LLM Applications 2025 更新,并涵盖 AI 编程编辑器与 MCP 服务器中 200+ 个 CVE 的检测。
| 类别 | 模式数量 | 检测内容 |
|---|---|---|
| 提示注入 | 800+ | 直接/间接注入、越狱、角色操纵 |
| MCP 服务器安全 | 400+ | 工具投毒、Schema 投毒、ATPA、采样注入、rug-pull |
| 仓库投毒 | 150+ | 武器化的 AI 编辑器配置、Clinejection、CurXecute、IDEsaster、CamoLeak |
| RAG 安全 | 300+ | 向量注入、文档投毒、租户隔离 |
| 智能体安全 | 500+ | 过度自主权、记忆投毒、HITL 绕过 |
| 模型安全 | 400+ | 不安全加载、检查点暴露、对抗性攻击 |
| 供应链 | 350+ | 依赖混淆、拼写仿冒、锁文件后门 |
| 传统 SAST | 1,400+ | SQL 注入、XSS、命令注入、密钥泄露 |
|
上下文与输入攻击
记忆与状态攻击
工具与操作攻击
|
工作流与路由攻击
RAG 与知识攻击
高级攻击
|
.cursorrules # Cursor AI (CVE-2025-54135) .cursor/rules/.mdc # Cursor rules directory .cursor/mcp.json # Cursor MCP (CurXecute RCE) .clinerules/.md # Cline (Clinejection) .windsurfrules # Windsurf (CVE-2025-36730) .windsurf/rules/* # Windsurf workspace rules .codex/config.toml # Codex CLI (CVE-2025-61260) .kiro/settings/mcp.json # Kiro (CVE-2026-0830) .vscode/settings.json # VS Code (IDEsaster) *.code-workspace # VS Code workspace mcp.json / .mcp.json # MCP server configs
CLAUDE.md # Claude Code GEMINI.md # Gemini CLI AGENTS.md # OpenAI Codex AGENT.md # Roo Code SKILL.md # ClawHub/ToxicSkills CONVENTIONS.md # Aider .github/copilot-instructions.md # GitHub Copilot .amazonq/rules/.md # Amazon Q Developer .augment/rules/ # Augment Code .roo/rules/.md # Roo Code .tabnine/guidelines/.md # Tabnine .continue/config.yaml # Continue.dev .cody.yml # Sourcegraph Cody
### 快速 AI 安全扫描```bash
# Scan AI configuration files
medusa scan . --ai-only
# Example output:
# 🔍 AI Security Scan Results
# ├── .cursorrules: 3 issues (1 CRITICAL, 2 HIGH)
# │ └── AIC001: Prompt injection - ignore previous instructions (line 15)
# │ └── AIC011: Tool shadowing - override default tools (line 23)
# ├── mcp-config.json: 2 issues (2 HIGH)
# │ └── MCP003: Dangerous path - home directory access (line 8)
# └── rag_config.json: 1 issue (1 CRITICAL)
# └── AIR010: Knowledge base injection pattern detected (line 45)
medusa init
medusa scan .
medusa scan /path/to/project
medusa scan . --quick
medusa scan . --force
medusa scan . --workers 4
medusa scan . --fail-on high
medusa scan . -o /tmp/reports
### 安装命令```bash
# Check tool status
medusa install --check
# Install AI tools (modelscan for ML model scanning)
medusa install --ai-tools
# Show detailed output
medusa install --ai-tools --debug
注意:MEDUSA v2026.2+ 不再安装外部 linter。如有需要,请通过你的包管理器(apt、brew、npm、pip)安装它们。MEDUSA 会自动检测并使用任何已安装的 linter。
medusa init
medusa init --ide claude-code
medusa init --ide claude-code --ide gemini-cli --ide cursor
medusa init --ide all
medusa init --force
medusa init --install
### 附加命令```bash
# Uninstall modelscan
medusa uninstall modelscan
# Check for updates
medusa version --check-updates
# Show current configuration
medusa config
# Override scanner for specific file
medusa override path/to/file.yaml YAMLScanner
# List available scanners
medusa override --list
# Show current overrides
medusa override --show
# Remove override
medusa override path/to/file.yaml --remove
| Option | Description |
|---|---|
TARGET | 要扫描的目录或文件(默认:.) |
-g, --git URL | 克隆并扫描远程 git 仓库(GitHub URL 或 user/repo 简写) |
-w, --workers N | 并行工作进程数(默认:自动检测) |
--quick | 快速扫描(仅扫描已更改的文件,需要 git) |
--force | 强制完整扫描(忽略缓存) |
--no-cache | 禁用结果缓存 |
--fail-on LEVEL | 在以下严重级别时以错误退出:critical、high、medium、low |
-o, --output PATH | 报告的自定义输出目录 |
--format FORMAT | 输出格式:json、html、sarif、junit、text(可指定多个) |
--no-report | 跳过生成 HTML 报告 |
| Option | Description |
|---|---|
--check | 检查工具状态 |
--ai-tools | 安装 AI 安全工具(modelscan) |
--debug | 显示详细的调试输出 |
v2026.2+ 变更:MEDUSA 不再管理外部 linter 的安装。
--all标志已弃用。如有需要,请通过系统包管理器安装外部 linter。
.medusa.ymlMEDUSA 使用 YAML 配置文件进行项目特定设置:```yaml
version: 2026.5.5
scanners: enabled: [] # Empty = all scanners enabled disabled: [] # List scanners to disable
fail_on: high # critical | high | medium | low
exclude: paths: - node_modules/ - venv/ - .venv/ - .git/ - pycache/ - dist/ - build/ files: - ".min.js" - ".min.css"
ide: claude_code: enabled: true auto_scan: true cursor: enabled: false vscode: enabled: false
workers: null # null = auto-detect CPU cores cache_enabled: true # Enable file caching for speed
### 生成默认配置```bash
medusa init
This creates .medusa.yml with sensible defaults and auto-detects your IDE.
MEDUSA 通过原生集成支持 5 大主流 AI 编程助手。使用 medusa init --ide all 初始化,或选择特定平台。
| IDE | 上下文文件 | 命令 | 状态 |
|---|---|---|---|
| Claude Code | CLAUDE.md | /medusa-scan, /medusa-install | ✅ 完全支持 |
| Gemini CLI | GEMINI.md | /scan, /install | ✅ 完全支持 |
| OpenAI Codex | AGENTS.md | 原生斜杠命令 | ✅ 完全支持 |
| GitHub Copilot | .github/copilot-instructions.md | 代码建议 | ✅ 完全支持 |
| Cursor | 复用 CLAUDE.md | MCP + Claude 命令 | ✅ 完全支持 |
medusa init --ide all
medusa init --ide claude-code --ide gemini-cli
### Claude Code
**它会创建:**
- `CLAUDE.md` - 项目上下文文件
- `.claude/agents/medusa/agent.json` - Agent 配置
- `.claude/commands/medusa-scan.md` - 扫描斜杠命令
- `.claude/commands/medusa-install.md` - 安装斜杠命令
**用法:**```
Type: /medusa-scan
Claude: *runs security scan*
Results: Displayed in terminal + chat
它创建的内容:
GEMINI.md - 项目上下文文件.gemini/commands/scan.toml - 扫描命令配置.gemini/commands/install.toml - 安装命令配置用法:```bash gemini /scan # Full scan gemini /scan --quick # Quick scan gemini /install --check # Check tools
### OpenAI Codex
**它创建的内容:**
- `AGENTS.md` - 项目上下文(根级别)
**用法:**```
Ask: "Run a security scan"
Codex: *executes medusa scan .*
它创建的内容:
.github/copilot-instructions.md - 安全标准和最佳实践它的帮助方式:
它创建的内容:
.cursor/mcp-config.json - MCP 服务器配置.claude/ 结构(Cursor 是 VS Code 的分支)用法:
MEDUSA 会自动监控系统负载并调整工作进程数量:```python
⚠️ High CPU usage: 85.3% Using 2 workers (reduced due to system load)
### 智能缓存
基于哈希的缓存会跳过未更改的文件:```bash
# First scan
📂 Files scanned: 145
⏱️ Total time: 47.28s
# Second scan (no changes)
📂 Files scanned: 0
⚡ Files cached: 145
⏱️ Total time: 2.15s # 22× faster!
多核扫描以实现巨大加速:``` Single-threaded: 417.5 seconds 6 workers: 47.3 seconds # 8.8× faster 24 workers: ~18 seconds # 23× faster
---
## 📊 示例工作流
### 新项目设置```bash
# 1. Initialize
cd my-awesome-project
medusa init
🐍 MEDUSA Initialization Wizard
✅ Step 1: Project Analysis
Found 15 language types
Primary: PythonScanner (44 files)
✅ Step 2: Scanner Availability
Available: 6/79 scanners
Missing: 73 tools
✅ Step 3: Configuration
Created .medusa.yml
Auto-detected IDE: Claude Code
✅ Step 4: IDE Integration
Created .claude/agents/medusa/agent.json
Created .claude/commands/medusa-scan.md
✅ MEDUSA Initialized Successfully!
# 2. First scan
medusa scan .
🔍 Issues found: 23
CRITICAL: 0
HIGH: 2
MEDIUM: 18
LOW: 3
# 3. Fix issues and rescan
medusa scan . --quick
⚡ Files cached: 142
🔍 Issues found: 12 # Progress!
name: Security Scan
on: [push, pull_request]
jobs: medusa: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install MEDUSA
run: pip install medusa-security
- name: Run security scan
run: medusa scan . --fail-on high
> **注意**:无需工具安装步骤 - MEDUSA 的 40,000+ 条内置规则可立即生效。
---
## 🏗️ 架构
### 扫描器模式
所有扫描器都遵循一致的模式:```python
class PythonScanner(BaseScanner):
"""Scanner for Python files using Bandit"""
def get_tool_name(self) -> str:
return "bandit"
def get_file_extensions(self) -> List[str]:
return [".py"]
def scan_file(self, file_path: Path) -> ScannerResult:
# Run bandit on file
# Parse JSON output
# Map severity levels
# Return structured issues
return ScannerResult(...)
扫描器会自动注册自身:```python
registry = ScannerRegistry() registry.register(PythonScanner()) registry.register(JavaScriptScanner())
### 严重性映射
所有工具统一使用的严重性级别:
- **CRITICAL** - 安全漏洞、致命错误
- **HIGH** - 错误、安全警告
- **MEDIUM** - 警告、代码质量问题
- **LOW** - 风格问题、约定
- **INFO** - 建议、重构机会
---
## 🧪 测试与质量
### 自用测试结果
MEDUSA 会扫描自身——以及实际项目:```
Self-scan (473 files):
✅ Issues found: 114 (pre-filter) → 0 (post-filter)
✅ FP reduction: 100% on own codebase
⏱️ Time: 8.2s
OpenClaw benchmark (4,124 files, 751K LOC):
🔍 Issues found: 825 (post-filter)
✅ FPs filtered: 11,436 (93.9% reduction)
⏱️ Time: 3.3 hours (79 scanners)
| 项目规模 | 文件数 | 时间 | 速度 |
|---|---|---|---|
| 小型(MEDUSA 自扫描) | 473 | ~8秒 | 59 文件/秒 |
| 中型 | 1,000 | ~45秒 | 22 文件/秒 |
| 大型(OpenClaw) | 4,124 | ~3.3小时 | 0.34 文件/秒* |
*大型项目的时间主要被外部工具子进程(Semgrep、Trivy、GitLeaks)占用。内置模式扫描几乎是即时的。
medusa scan --git <URL> - 扫描任意 GitHub 仓库中的 AI 供应链攻击我们欢迎贡献!以下是入门方法:```bash
git clone https://github.com/yourusername/medusa.git cd medusa
python -m venv .venv
source .venv/bin/activate # or .venv\Scripts\activate on Windows
pip install -e ".[dev]"
pytest
git checkout -b feature/my-awesome-feature
medusa scan . # Dogfood your changes!
git push origin feature/my-awesome-feature
### 添加新扫描器
请参阅 `docs/development/adding-scanners.md`,了解添加新语言支持的指南。
---
## 📜 许可证
AGPL-3.0-or-later - 参见 [LICENSE](https://github.com/pantheon-security/medusa/blob/main/LICENSE) 文件
MEDUSA 是免费开源软件。您可以自由使用、修改和分发它,但任何修改或衍生作品(包括 SaaS 部署)也必须以 AGPL-3.0 许可证发布。
如需商业许可选项,请联系:[email protected]
---
## 即将推出
MEDUSA Professional 为生产环境中的 LLM 应用新增了**运行时保护**功能,可在提示注入、越狱和数据外泄尝试到达您的模型之前实时拦截。
| 功能 | 开源版 | 专业版 | 企业版 |
|---------|-------------|--------------|------------|
| 静态扫描(40,000+ 模式) | 是 | 是 | 是 |
| 运行时代理过滤器(1,100+) | - | 是 | 是 |
| REST API 与 Webhooks | - | 是 | 是 |
| 自定义规则与 SSO | - | - | 是 |
| **价格** | 免费 | $99/开发者/月 | $499/50 开发者/月 |
运行时代理目前处于内测阶段。如果您正在保护生产环境中的 LLM 应用并希望获得提前访问权限,请联系 **[email protected]**。
---
## 🙏 致谢
**开发:**
- Pantheon Security
- Claude AI(Anthropic)- AI 辅助开发
**技术栈:**
- Python 3.10+
- Click - CLI 框架
- Rich - 终端格式化
- Bandit、ESLint、ShellCheck 及其他 39+ 开源安全工具
**灵感来源:**
- Bandit(Python 安全)
- SonarQube(多语言分析)
- Semgrep(基于模式的安全)
- Mega-Linter(全面 linting)
---
## 📖 指南
- **[快速入门](https://github.com/pantheon-security/medusa/blob/main/docs/guides/quick-start.md)** - 5 分钟内开始使用
- **[AI 安全扫描](https://github.com/pantheon-security/medusa/blob/main/docs/AI_SECURITY.md)** - AI/LLM 安全完整指南(OWASP 2025、MCP、RAG)
- **[处理误报](https://github.com/pantheon-security/medusa/blob/main/docs/guides/handling-false-positives.md)** - 减少噪音,发现真正的问题
- **[IDE 集成](https://github.com/pantheon-security/medusa/blob/main/docs/guides/ide-integration.md)** - 配置 Claude Code、Gemini、Copilot
---
## 📞 支持
- **GitHub Issues**:[报告 Bug 或请求功能](https://github.com/Pantheon-Security/medusa/issues)
- **邮箱**:[email protected]
- **文档**:https://docs.pantheonsecurity.io
- **Discord**:https://discord.gg/medusa(即将上线)
---
## 📈 统计数据
**版本**:2026.5.5
**发布日期**:2026-04-03
**检测模式**:40,000+ AI 安全规则
**分析器**:79 个专业扫描器
**误报过滤模式**:514 个智能过滤器(误报率降低 96.8%)
**CVE 覆盖**:200 个严重漏洞(37+ AI 编辑器 CVE)
**仓库投毒**:可检测 28+ 种 AI 编辑器配置文件类型
**语言覆盖**:46+ 种文件类型
**平台支持**:Linux、macOS、Windows
**AI 集成**:Claude Code、Gemini CLI、GitHub Copilot、Cursor、OpenAI Codex
**标准**:OWASP Top 10 for LLM 2025、MITRE ATLAS
**下载量**:PyPI 上 11,500+
---
## 🌟 为什么选择 MEDUSA?
### 与 Bandit 对比
- ✅ 40,000+ 模式(不仅仅是 Python 安全)
- ✅ AI/ML 安全覆盖
- ✅ 零配置要求
- ✅ IDE 集成
### 与 SonarQube 对比
- ✅ 更简单的安装(`pip install && scan`)
- ✅ 无需服务器
- ✅ AI 优先的安全重点
- ✅ 免费且开源
### 与 Semgrep 对比
- ✅ 内置 AI/ML 专用规则
- ✅ MCP、RAG、Agent 安全
- ✅ 更优秀的 IDE 集成
- ✅ 无需规则配置
### 与传统 SAST 对比
- ✅ 立即可用(无需安装工具)
- ✅ 包含 AI 安全模式
- ✅ 并行处理
- ✅ 智能缓存
---
**🐍🐍🐍 MEDUSA - 多语言安全扫描器 🐍🐍🐍**
**一条命令。全面安全。**```bash
medusa init && medusa scan .
最后更新:2026-04-03 状态:生产就绪 当前版本:v2026.5.5 - 安全加固