Sistema RAG do OWASP Web Security Testing Guide com ChromaDB, MCP para Claude Code
Um sistema de Geração Aumentada por Recuperação (RAG) que indexa o Guia de Testes de Segurança Web da OWASP (WSTG) em um banco de dados vetorial, fornecendo acesso instantâneo a metodologias de testes de segurança via API REST e MCP (Model Context Protocol) para integração com Claude Code.
WSTG-INPV-05)| Categoria | ID WSTG | Descrição |
|---|
| Coleta de Informações | WSTG-INFO | Fingerprinting, enumeração, mapeamento |
| Configuração | WSTG-CONF | Testes de configuração do servidor/plataforma |
| Gerenciamento de Identidade | WSTG-IDNT | Registro de usuários, provisionamento de contas |
| Autenticação | WSTG-ATHN | Testes de login, política de senhas, MFA |
| Autorização | WSTG-ATHZ | Escalação de privilégios, IDOR, controle de acesso |
| Gerenciamento de Sessão | WSTG-SESS | Tokens de sessão, cookies, fixação |
| Validação de Entrada | WSTG-INPV | SQLi, XSS, injeção de comandos, SSTI |
| Tratamento de Erros | WSTG-ERRH | Mensagens de erro, stack traces |
| Criptografia | WSTG-CRYP | TLS, criptografia, hashing |
| Lógica de Negócio | WSTG-BUSL | Bypass de fluxo de trabalho, upload de arquivos |
| Lado do Cliente | WSTG-CLNT | DOM XSS, clickjacking, WebSockets |
| Testes de API | WSTG-APIT | REST, GraphQL, segurança de APIs |
cd RAG_runner
pip install -r requirements.txt
python3 build_database.py
Isso irá:
python3 -m server.http_server
O servidor roda em 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 | Método | Descrição |
|---|---|---|
/health | GET | Verificação de saúde |
/info | GET | Estatísticas do banco de dados |
/list | GET | Listar todos os documentos |
/categories | GET | Listar categorias e IDs WSTG |
/doc/{id} | GET | Obter documento por ID |
/wstg/{id} | GET | Obter todos os chunks para o ID WSTG |
/search | POST | Busca semântica |
{
"query": "SQL injection testing",
"n_results": 5,
"category": "input_validation",
"wstg_id": "WSTG-INPV-05"
}
Adicione ao ~/.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"
}
}
}
}
| Ferramenta | Descrição |
|---|---|
search_wstg | Pesquisar no WSTG por metodologias de testes |
search_test_methodology | Pesquisar por guias práticos de testes |
search_test_objectives | Pesquisar por objetivos de testes |
get_wstg_test_case | Obter caso de teste completo por ID WSTG |
get_wstg_document | Obter documento por ID |
list_wstg_categories | Listar todas as categorias e IDs WSTG |
wstg_health | Verificação de saúde |
wstg_info | Estatísticas do banco de dados |
# 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() │
└──────────────────────────┘ └──────────────────────────┘
Integre com o Claude Code para obter acesso instantâneo às metodologias de testes da OWASP durante avaliações de segurança:
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
Use a API REST para integrar metodologias do WSTG em pipelines de segurança automatizados:
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']
Referência rápida para metodologias de testes de segurança durante treinamentos ou desafios CTF.
Este projeto utiliza conteúdo do Guia de Testes de Segurança Web da OWASP, licenciado sob Creative Commons Atribuição-CompartilhaIgual 4.0.