Sistema RAG della Guida OWASP per i Test di Sicurezza Web con ChromaDB, MCP per Claude Code
Un sistema Retrieval-Augmented Generation (RAG) che indicizza la OWASP Web Security Testing Guide (WSTG) in un database vettoriale, fornendo accesso immediato alle metodologie di test di sicurezza tramite API REST e MCP (Model Context Protocol) per l'integrazione con Claude Code.
WSTG-INPV-05)| Categoria | ID WSTG | Descrizione |
|---|
| Raccolta di informazioni | WSTG-INFO | Fingerprinting, enumerazione, mappatura |
| Configurazione | WSTG-CONF | Test di configurazione di server/piattaforma |
| Gestione delle identità | WSTG-IDNT | Registrazione utente, provisioning degli account |
| Autenticazione | WSTG-ATHN | Test di login, policy delle password, MFA |
| Autorizzazione | WSTG-ATHZ | Escalation dei privilegi, IDOR, controllo degli accessi |
| Gestione delle sessioni | WSTG-SESS | Token di sessione, cookie, fixation |
| Validazione degli input | WSTG-INPV | SQLi, XSS, command injection, SSTI |
| Gestione degli errori | WSTG-ERRH | Messaggi di errore, stack trace |
| Crittografia | WSTG-CRYP | TLS, crittografia, hashing |
| Logica di business | WSTG-BUSL | Bypass del flusso di lavoro, caricamento di file |
| Lato client | WSTG-CLNT | DOM XSS, clickjacking, WebSockets |
| Test API | WSTG-APIT | REST, GraphQL, sicurezza delle API |
cd RAG_runner
pip install -r requirements.txt
python3 build_database.py
Questa operazione:
python3 -m server.http_server
Il server gira su 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
| Endpoint | Method | Descrizione |
|---|---|---|
/health | GET | Controllo di integrità |
/info | GET | Statistiche del database |
/list | GET | Elenca tutti i documenti |
/categories | GET | Elenca categorie e ID WSTG |
/doc/{id} | GET | Recupera il documento tramite ID |
/wstg/{id} | GET | Recupera tutti i chunk per ID WSTG |
/search | POST | Ricerca semantica |
{
"query": "SQL injection testing",
"n_results": 5,
"category": "input_validation",
"wstg_id": "WSTG-INPV-05"
}
Aggiungi a ~/.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"
}
}
}
}
| Tool | Descrizione |
|---|---|
search_wstg | Cerca in WSTG metodologie di test |
search_test_methodology | Cerca guide pratiche su come eseguire i test |
search_test_objectives | Cerca obiettivi di test |
get_wstg_test_case | Recupera il caso di test completo tramite ID WSTG |
get_wstg_document | Recupera il documento tramite ID |
list_wstg_categories | Elenca tutte le categorie e gli ID WSTG |
wstg_health | Controllo di integrità |
wstg_info | Statistiche del database |
# 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() │
└──────────────────────────┘ └──────────────────────────┘
Integra con Claude Code per ottenere accesso immediato alle metodologie di test OWASP durante le valutazioni di sicurezza:
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
Usa l'API REST per integrare le metodologie WSTG in pipeline di sicurezza automatizzate:
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']
Riferimento rapido per le metodologie di test di sicurezza durante corsi di formazione o sfide CTF.
Questo progetto utilizza contenuti della OWASP Web Security Testing Guide, che è distribuita sotto licenza Creative Commons Attribution-ShareAlike 4.0.