OWASP Web Security Testing Guide RAG系统,带有ChromaDB和用于Claude Code的MCP
| 类别 | WSTG ID | 描述 |
|---|
| 信息收集 | WSTG-INFO | 指纹识别、枚举、映射 |
| 配置 | WSTG-CONF | 服务器/平台配置测试 |
| 身份管理 | WSTG-IDNT | 用户注册、账户配置 |
| 认证 | WSTG-ATHN | 登录、密码策略、多因素认证测试 |
| 授权 | WSTG-ATHZ | 权限提升、IDOR、访问控制 |
| 会话管理 | WSTG-SESS | 会话令牌、Cookie、会话固定测试 |
| 输入验证 | WSTG-INPV | SQL注入、XSS、命令注入、SSTI |
| 错误处理 | WSTG-ERRH | 错误消息、堆栈跟踪 |
| 密码学 | WSTG-CRYP | TLS、加密、哈希 |
| 业务逻辑 | WSTG-BUSL | 工作流绕过、文件上传 |
| 客户端 | WSTG-CLNT | DOM XSS、点击劫持、WebSocket |
| API测试 | WSTG-APIT | REST、GraphQL、API安全 |
cd RAG_runner
pip install -r requirements.txt
python3 build_database.py
此操作将:
python3 -m server.http_server
服务器运行在 http://localhost:5004
# 健康检查
curl http://localhost:5004/health
# 搜索SQL注入测试
curl -X POST http://localhost:5004/search \
-H "Content-Type: application/json" \
-d '{"query": "SQL injection testing methodology"}'
# 获取特定WSTG测试用例
curl http://localhost:5004/wstg/WSTG-INPV-05
| 端点 | 方法 | 描述 |
|---|---|---|
/health | GET | 健康检查 |
/info | GET | 数据库统计 |
/list | GET | 列出所有文档 |
/categories | GET | 列出类别及WSTG ID |
/doc/{id} | GET | 按ID获取文档 |
/wstg/{id} | GET | 获取WSTG ID的所有块 |
/search | POST | 语义搜索 |
{
"query": "SQL injection testing",
"n_results": 5,
"category": "input_validation",
"wstg_id": "WSTG-INPV-05"
}
添加到 ~/.claude.json:
{
"mcpServers": {
"owasp-wstg-rag": {
"command": "python3",
"args": ["/path/to/OWASP_WSTG_Rag/RAG_runner/server/mcp_client.py"],
"env": {
"WSTG_RAG_URL": "http://localhost:5004"
}
}
}
}
| 工具 | 描述 |
|---|---|
search_wstg | 搜索WSTG获取测试方法 |
search_test_methodology | 搜索如何测试的指南 |
search_test_objectives | 搜索测试目标 |
get_wstg_test_case | 按WSTG ID获取完整测试用例 |
get_wstg_document | 按ID获取文档 |
list_wstg_categories | 列出所有类别及WSTG ID |
wstg_health | 健康检查 |
wstg_info | 数据库统计 |
# 搜索SQL注入测试方法
search_wstg("SQL injection testing methodology")
# 获取特定测试用例
get_wstg_test_case("WSTG-INPV-05")
# 按类别搜索
search_wstg("authentication bypass", category_filter="authentication")
# 获取IDOR的测试目标
search_test_objectives("IDOR insecure direct object reference")
OWASP_WSTG_Rag/
├── README.md
├── CLAUDE.md # Claude Code项目指南
├── raw_data/ # OWASP WSTG HTML源文件
│ ├── 01-Information_Gathering/
│ ├── 02-Configuration_and_Deployment_Management_Testing/
│ ├── 03-Identity_Management_Testing/
│ ├── 04-Authentication_Testing/
│ ├── 05-Authorization_Testing/
│ ├── 06-Session_Management_Testing/
│ ├── 07-Input_Validation_Testing/
│ ├── 08-Testing_for_Error_Handling/
│ ├── 09-Testing_for_Weak_Cryptography/
│ ├── 10-Business_Logic_Testing/
│ ├── 11-Client-side_Testing/
│ └── 12-API_Testing/
└── RAG_runner/
├── build_database.py # 主构建流水线
├── requirements.txt
├── parsers/
│ └── wstg_parser.py # WSTG的HTML解析器
├── chunking/
│ └── chunker.py # 语义分块
├── server/
│ ├── vector_store.py # ChromaDB封装器
│ ├── http_server.py # REST API服务器
│ └── mcp_client.py # 用于Claude Code的MCP工具
└── data/
├── processed/ # 中间JSON文件
└── chroma_db/ # 向量数据库
┌─────────────────────────────────────────────────────────────────┐
│ OWASP WSTG HTML Files │
│ (raw_data/*.html) │
└────────────────────────────┬────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ wstg_parser.py │
│ Parse HTML → Structured JSON │
└────────────────────────────┬────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ chunker.py │
│ Create Semantic Chunks for RAG │
└────────────────────────────┬────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ ChromaDB Vector Store │
│ (data/chroma_db/) │
└────────────────────────────┬────────────────────────────────────┘
│
┌──────────────┴──────────────┐
▼ ▼
┌──────────────────────────┐ ┌──────────────────────────┐
│ http_server.py │ │ mcp_client.py │
│ REST API :5004 │ │ MCP for Claude Code │
│ │ │ │
│ GET /health │ │ search_wstg() │
│ GET /info │ │ get_wstg_test_case() │
│ GET /wstg/{id} │ │ search_test_methodology │
│ POST /search │ │ list_wstg_categories() │
└──────────────────────────┘ └──────────────────────────┘
集成Claude Code,在安全评估期间即时获取OWASP测试方法:
用户: "如何测试SQL注入?"
Claude: [查询WSTG RAG]
→ 返回WSTG-INPV-05方法,包含:
- 测试目标
- 分步测试流程
- 示例载荷
- 推荐工具
使用REST API将WSTG方法集成到自动化安全流水线中:
import requests
# 获取当前测试的测试方法
response = requests.post('http://localhost:5004/search', json={
'query': 'session fixation testing',
'n_results': 3
})
methodology = response.json()['results']
培训或CTF挑战期间快速参考安全测试方法。
本项目使用了OWASP Web安全测试指南的内容,该指南采用知识共享署名-相同方式共享4.0许可。