ChromaDB と Claude Code 用 MCP を使用した OWASP Web Security Testing Guide の RAG システム
**OWASP Web Security Testing Guide(WSTG)**をベクトルデータベースにインデックス化し、REST APIとClaude Code統合のためのMCP(Model Context Protocol)を介して、セキュリティテスト手法への即時アクセスを提供する検索拡張生成(RAG)システムです。
WSTG-INPV-05)で完全なテストケースを取得| カテゴリ | WSTG ID | 説明 |
|---|
| 情報収集 | WSTG-INFO | フィンガープリンティング、列挙、マッピング |
| 構成 | WSTG-CONF | サーバー/プラットフォーム構成のテスト |
| アイデンティティ管理 | WSTG-IDNT | ユーザー登録、アカウントプロビジョニング |
| 認証 | WSTG-ATHN | ログイン、パスワードポリシー、MFAのテスト |
| 認可 | WSTG-ATHZ | 権限昇格、IDOR、アクセス制御 |
| セッション管理 | WSTG-SESS | セッショントークン、クッキー、フィクセーション |
| 入力検証 | WSTG-INPV | SQLi、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 で実行されます
# Health check
curl http://localhost:5004/health
# Search for SQL injection testing
curl -X POST http://localhost:5004/search \
-H "Content-Type: application/json" \
-d '{"query": "SQL injection testing methodology"}'
# Get specific WSTG test case
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 | データベース統計 |
# Search for SQL injection testing methodology
search_wstg("SQL injection testing methodology")
# Get specific test case
get_wstg_test_case("WSTG-INPV-05")
# Search within a category
search_wstg("authentication bypass", category_filter="authentication")
# Get test objectives for IDOR
search_test_objectives("IDOR insecure direct object reference")
OWASP_WSTG_Rag/
├── README.md
├── CLAUDE.md # Claude Code project guide
├── raw_data/ # OWASP WSTG HTML source files
│ ├── 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 # Main build pipeline
├── requirements.txt
├── parsers/
│ └── wstg_parser.py # HTML parser for WSTG
├── chunking/
│ └── chunker.py # Semantic chunking
├── server/
│ ├── vector_store.py # ChromaDB wrapper
│ ├── http_server.py # REST API server
│ └── mcp_client.py # MCP tools for Claude Code
└── data/
├── processed/ # Intermediate JSON files
└── chroma_db/ # Vector database
┌─────────────────────────────────────────────────────────────────┐
│ 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テスト手法へ即座にアクセスできます:
User: "How do I test for SQL injection?"
Claude: [Queries WSTG RAG]
→ Returns WSTG-INPV-05 methodology with:
- Test objectives
- Step-by-step testing procedures
- Example payloads
- Tools to use
REST APIを使用して、WSTG手法を自動セキュリティパイプラインに統合します:
import requests
# Get testing methodology for current test
response = requests.post('http://localhost:5004/search', json={
'query': 'session fixation testing',
'n_results': 3
})
methodology = response.json()['results']
トレーニングやCTFチャレンジ中に、セキュリティテスト手法をすぐに参照できます。
このプロジェクトは、Creative Commons Attribution-ShareAlike 4.0 の下で提供されている OWASP Web Security Testing Guide のコンテンツを使用しています。