@fabioforest/openclaw 3.5.0 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -2
- package/package.json +1 -1
- package/templates/.agent/skills/ai-provider-setup/SKILL.md +244 -0
- package/templates/.agent/skills/code-quality/SKILL.md +93 -0
- package/templates/.agent/skills/devops-toolkit/SKILL.md +110 -0
- package/templates/.agent/skills/legacy-cleanup/SKILL.md +67 -0
- package/templates/.agent/skills/mlops-pipeline/SKILL.md +113 -0
- package/templates/.agent/skills/security-scanner/SKILL.md +121 -0
- package/templates/.agent/skills/smoke-tester/SKILL.md +160 -0
- package/templates/.agent/skills/test-engineer/SKILL.md +129 -0
- package/templates/.agent/skills/vpn-networking/SKILL.md +200 -0
- package/templates/.agent/skills/vps-cloud-infra/SKILL.md +140 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: security-scanner
|
|
3
|
+
description: Análise de segurança de código e infraestrutura — SAST, DAST, dependency audit, secrets scanning, OWASP Top 10 e hardening.
|
|
4
|
+
triggers:
|
|
5
|
+
- segurança
|
|
6
|
+
- security
|
|
7
|
+
- vulnerabilidade
|
|
8
|
+
- cve
|
|
9
|
+
- owasp
|
|
10
|
+
- pentest
|
|
11
|
+
- scan
|
|
12
|
+
- auditoria de segurança
|
|
13
|
+
- secrets
|
|
14
|
+
- injection
|
|
15
|
+
- xss
|
|
16
|
+
- csrf
|
|
17
|
+
- sql injection
|
|
18
|
+
- hardening
|
|
19
|
+
- sast
|
|
20
|
+
- dast
|
|
21
|
+
- dependências vulneráveis
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
# Security Scanner
|
|
25
|
+
|
|
26
|
+
## Objetivo
|
|
27
|
+
Identificar vulnerabilidades de segurança no código, dependências e infraestrutura, seguindo OWASP Top 10 e boas práticas de AppSec.
|
|
28
|
+
|
|
29
|
+
## Contexto necessário
|
|
30
|
+
- Linguagem/framework do projeto
|
|
31
|
+
- Tipo de aplicação (web, API, mobile, CLI)
|
|
32
|
+
- Ambiente (dev, staging, prod)
|
|
33
|
+
- Requisitos de compliance (SOC2, LGPD, PCI-DSS, HIPAA)
|
|
34
|
+
|
|
35
|
+
## Fluxo (inspect → plan → consent → apply → verify → audit)
|
|
36
|
+
|
|
37
|
+
1. **INSPECT** (read-only):
|
|
38
|
+
- Scan de dependências (CVEs conhecidos)
|
|
39
|
+
- Busca de secrets no código (API keys, senhas, tokens)
|
|
40
|
+
- Análise estática (SAST): injection, XSS, CSRF
|
|
41
|
+
- Verificação de configuração (CORS, headers, CSP)
|
|
42
|
+
- Análise de Dockerfile/compose (imagem base, root, ports)
|
|
43
|
+
|
|
44
|
+
2. **PLAN** — Relatório de vulnerabilidades por severidade:
|
|
45
|
+
|
|
46
|
+
| Severidade | Exemplo | Ação |
|
|
47
|
+
|-----------|---------|------|
|
|
48
|
+
| 🔴 Crítica | SQL injection, secret exposto | Fix imediato |
|
|
49
|
+
| 🟠 Alta | Dependência com CVE alto | Update urgente |
|
|
50
|
+
| 🟡 Média | CORS permissivo, headers faltando | Planejar fix |
|
|
51
|
+
| 🟢 Baixa | Versão desatualizada sem CVE | Monitorar |
|
|
52
|
+
|
|
53
|
+
3. **CONSENT**: Confirmar correções propostas
|
|
54
|
+
4. **APPLY**: Aplicar fixes + atualizar dependências
|
|
55
|
+
5. **VERIFY**: Re-scan para confirmar correção
|
|
56
|
+
6. **AUDIT**: Relatório de segurança antes/depois
|
|
57
|
+
|
|
58
|
+
## Capacidades
|
|
59
|
+
|
|
60
|
+
### 🔍 SAST (Static Application Security Testing)
|
|
61
|
+
- Análise de código sem executar
|
|
62
|
+
- Detecção de injection (SQL, NoSQL, command, LDAP)
|
|
63
|
+
- Cross-Site Scripting (XSS) e Cross-Site Request Forgery (CSRF)
|
|
64
|
+
- Insecure deserialization
|
|
65
|
+
- Path traversal e file inclusion
|
|
66
|
+
|
|
67
|
+
### 📦 Dependency Audit
|
|
68
|
+
- `npm audit` / `yarn audit` (JavaScript)
|
|
69
|
+
- `pip-audit` / `safety` (Python)
|
|
70
|
+
- `cargo audit` (Rust)
|
|
71
|
+
- `go vuln check` (Go)
|
|
72
|
+
- Snyk, Dependabot, Renovate para automação
|
|
73
|
+
|
|
74
|
+
### 🔑 Secrets Scanning
|
|
75
|
+
- Busca de: API keys, passwords, tokens, private keys, connection strings
|
|
76
|
+
- Ferramentas: gitleaks, truffleHog, detect-secrets
|
|
77
|
+
- Verificação em histórico do Git (commits antigos)
|
|
78
|
+
- Pre-commit hooks para prevenir novos leaks
|
|
79
|
+
|
|
80
|
+
### 🌐 DAST (Dynamic Application Security Testing)
|
|
81
|
+
- Scan de endpoint em runtime
|
|
82
|
+
- Ferramentas: OWASP ZAP, Nuclei, Burp Suite
|
|
83
|
+
- Verificação de headers de segurança (CSP, HSTS, X-Frame-Options)
|
|
84
|
+
- Teste de rate limiting e brute force
|
|
85
|
+
|
|
86
|
+
### 🏗️ Infrastructure Security
|
|
87
|
+
- Scan de imagens Docker (Trivy, Grype)
|
|
88
|
+
- Verificação de configuração cloud (Checkov, ScoutSuite)
|
|
89
|
+
- Network security (ports expostas, firewall rules)
|
|
90
|
+
- TLS/SSL assessment (testssl.sh, SSL Labs)
|
|
91
|
+
|
|
92
|
+
## OWASP Top 10 — Checklist
|
|
93
|
+
|
|
94
|
+
- [ ] **A01 Broken Access Control**: Verificar RBAC, IDOR, path traversal
|
|
95
|
+
- [ ] **A02 Cryptographic Failures**: TLS, hashing de senhas (bcrypt/argon2), encryption at rest
|
|
96
|
+
- [ ] **A03 Injection**: SQL, NoSQL, OS command, LDAP, XSS
|
|
97
|
+
- [ ] **A04 Insecure Design**: Threat modeling, abuse cases
|
|
98
|
+
- [ ] **A05 Security Misconfiguration**: Default configs, debug mode em prod, headers
|
|
99
|
+
- [ ] **A06 Vulnerable Components**: Dependencies com CVEs, EOL libraries
|
|
100
|
+
- [ ] **A07 Authentication Failures**: MFA, session management, brute force protection
|
|
101
|
+
- [ ] **A08 Data Integrity Failures**: CI/CD security, deserialization, updates sem verificação
|
|
102
|
+
- [ ] **A09 Logging Failures**: Logs sem dados sensíveis, monitoramento de atividade suspeita
|
|
103
|
+
- [ ] **A10 SSRF**: Validação de URLs, allowlists de destinos
|
|
104
|
+
|
|
105
|
+
## Ferramentas recomendadas
|
|
106
|
+
|
|
107
|
+
| Categoria | Ferramenta | Linguagem |
|
|
108
|
+
|-----------|-----------|-----------|
|
|
109
|
+
| SAST | Semgrep, CodeQL, SonarQube | Multi-linguagem |
|
|
110
|
+
| Deps | npm audit, pip-audit, Snyk | JS, Python, multi |
|
|
111
|
+
| Secrets | gitleaks, truffleHog | Qualquer |
|
|
112
|
+
| DAST | OWASP ZAP, Nuclei | Web apps |
|
|
113
|
+
| Docker | Trivy, Grype | Containers |
|
|
114
|
+
| Infra | Checkov, tfsec | Terraform, Cloud |
|
|
115
|
+
|
|
116
|
+
## Regras de segurança
|
|
117
|
+
- ✅ Scan de segurança deve rodar no CI/CD em cada PR
|
|
118
|
+
- ✅ Vulnerabilidades críticas bloqueiam merge
|
|
119
|
+
- ✅ Secrets encontrados devem ser revogados IMEDIATAMENTE
|
|
120
|
+
- ❌ Nunca ignorar CVEs críticos sem justificativa documentada
|
|
121
|
+
- ❌ Nunca publicar relatório de segurança detalhado em canal público
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: smoke-tester
|
|
3
|
+
description: Validação automática pós-alteração. Testa se mudanças funcionam como esperado usando testes automatizados, browser testing (quando disponível) ou verificações programáticas.
|
|
4
|
+
triggers:
|
|
5
|
+
- testar alteração
|
|
6
|
+
- verificar se funciona
|
|
7
|
+
- smoke test
|
|
8
|
+
- validar
|
|
9
|
+
- testar se funciona
|
|
10
|
+
- funciona?
|
|
11
|
+
- está funcionando
|
|
12
|
+
- conferir
|
|
13
|
+
- healthcheck pós-deploy
|
|
14
|
+
- verificação
|
|
15
|
+
- pós-alteração
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# Smoke Tester (Validação Pós-Alteração)
|
|
19
|
+
|
|
20
|
+
## Objetivo
|
|
21
|
+
Após **qualquer alteração** no projeto (novo agente, config, deploy, código), executar automaticamente uma bateria de testes para confirmar que tudo funciona como esperado.
|
|
22
|
+
|
|
23
|
+
> **Princípio**: Nenhuma alteração é considerada completa sem validação. O agente DEVE testar após aplicar.
|
|
24
|
+
|
|
25
|
+
## Contexto necessário
|
|
26
|
+
- O que foi alterado (config, código, agente, infra)
|
|
27
|
+
- Ambiente (local, Docker, VPS, IDE)
|
|
28
|
+
- Ferramentas disponíveis (browser tool, terminal, API)
|
|
29
|
+
|
|
30
|
+
## Fluxo automático pós-alteração
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
ALTERAÇÃO → DETECTAR TIPO → ESCOLHER TESTE → EXECUTAR → REPORTAR
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### 1. Detectar tipo de alteração
|
|
37
|
+
|
|
38
|
+
| Tipo | Exemplos | Teste adequado |
|
|
39
|
+
|------|----------|---------------|
|
|
40
|
+
| Config de agente | Novo agente, modelo, fallback | Health ping + resposta de teste |
|
|
41
|
+
| Config de gateway | Porta, bind, auth, CORS | Curl/HTTP request + status check |
|
|
42
|
+
| Config de canal | Telegram, Discord, Slack | Enviar mensagem de teste + verificar status |
|
|
43
|
+
| Código (backend) | API, lógica, módulo | Unit tests + integration tests |
|
|
44
|
+
| Código (frontend) | UI, componente, página | Browser testing (screenshot + assertions) |
|
|
45
|
+
| Infraestrutura | Docker, VPN, firewall | Connectivity check + healthcheck |
|
|
46
|
+
| Dependências | npm install, pip install | Build + test suite |
|
|
47
|
+
|
|
48
|
+
### 2. Métodos de teste por ambiente
|
|
49
|
+
|
|
50
|
+
#### Terminal/CLI (sempre disponível)
|
|
51
|
+
```bash
|
|
52
|
+
# Verificar se processo está rodando
|
|
53
|
+
docker ps | grep <container>
|
|
54
|
+
systemctl status <service>
|
|
55
|
+
|
|
56
|
+
# Testar endpoint HTTP
|
|
57
|
+
curl -s -o /dev/null -w "%{http_code}" http://localhost:PORT/health
|
|
58
|
+
|
|
59
|
+
# Verificar conectividade
|
|
60
|
+
ping -c 1 <host>
|
|
61
|
+
ssh -o ConnectTimeout=5 <host> echo "OK"
|
|
62
|
+
|
|
63
|
+
# Rodar suite de testes
|
|
64
|
+
npm test
|
|
65
|
+
pytest
|
|
66
|
+
go test ./...
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
#### Browser Testing (Antigravity, Cursor com browser tool)
|
|
70
|
+
Quando o agente tem acesso ao browser tool:
|
|
71
|
+
```
|
|
72
|
+
1. Abrir URL alvo no navegador
|
|
73
|
+
2. Verificar se a página carrega (screenshot)
|
|
74
|
+
3. Verificar elementos esperados na DOM
|
|
75
|
+
4. Clicar em elementos interativos
|
|
76
|
+
5. Verificar console do navegador (sem erros)
|
|
77
|
+
6. Capturar screenshot final como prova
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**Cenários de browser testing:**
|
|
81
|
+
- Dashboard do OpenClaw: verificar se carrega, dropdown de agentes presente
|
|
82
|
+
- Site/App: verificar homepage, navegação, formulários
|
|
83
|
+
- Página de login: testar fluxo completo
|
|
84
|
+
- API docs: verificar se Swagger/OpenAPI renderiza
|
|
85
|
+
|
|
86
|
+
#### API Testing (programático)
|
|
87
|
+
```bash
|
|
88
|
+
# Testar agente do OpenClaw
|
|
89
|
+
curl -X POST http://localhost:18789/api/chat \
|
|
90
|
+
-H "Authorization: Bearer <token>" \
|
|
91
|
+
-d '{"message": "ping"}' \
|
|
92
|
+
| jq '.response'
|
|
93
|
+
|
|
94
|
+
# Verificar status de agentes
|
|
95
|
+
curl http://localhost:18789/api/status --json | jq '.agents'
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### 3. Checklists por tipo de alteração
|
|
99
|
+
|
|
100
|
+
#### Novo Agente Adicionado
|
|
101
|
+
- [ ] Config válida no `openclaw.json` (id, model, workspace)
|
|
102
|
+
- [ ] Reiniciar gateway/container
|
|
103
|
+
- [ ] Verificar que o agente aparece no status (`/api/status`)
|
|
104
|
+
- [ ] Enviar mensagem de teste e confirmar resposta
|
|
105
|
+
- [ ] Se tem browser: verificar dropdown no dashboard
|
|
106
|
+
- [ ] Verificar logs do container (sem erros)
|
|
107
|
+
|
|
108
|
+
#### Novo Modelo/Provedor de IA
|
|
109
|
+
- [ ] API Key configurada (env var ou config)
|
|
110
|
+
- [ ] Modelo acessível (fazer request de teste)
|
|
111
|
+
- [ ] Fallback funcionando (simular falha do primário)
|
|
112
|
+
- [ ] Rate limits conhecidos e documentados
|
|
113
|
+
- [ ] Custo estimado por request documentado
|
|
114
|
+
|
|
115
|
+
#### Configuração Multi-Agente
|
|
116
|
+
- [ ] Cada agente tem workspace separado
|
|
117
|
+
- [ ] Cada agente responde individualmente
|
|
118
|
+
- [ ] Sessões não se misturam entre agentes
|
|
119
|
+
- [ ] Fallback de modelo funciona para cada agente
|
|
120
|
+
- [ ] Dashboard mostra todos os agentes no dropdown
|
|
121
|
+
|
|
122
|
+
#### Alteração de VPN/Rede
|
|
123
|
+
- [ ] Pingar IP da VPN (`ping 10.66.0.X`)
|
|
124
|
+
- [ ] SSH via VPN funciona
|
|
125
|
+
- [ ] Portas esperadas acessíveis (curl healthcheck)
|
|
126
|
+
- [ ] Firewall não bloqueia tráfego esperado
|
|
127
|
+
- [ ] DNS resolve corretamente
|
|
128
|
+
|
|
129
|
+
#### Alteração de Código
|
|
130
|
+
- [ ] Build passa sem erros
|
|
131
|
+
- [ ] Testes unitários passam
|
|
132
|
+
- [ ] Testes de integração passam (se existirem)
|
|
133
|
+
- [ ] Sem erros no console do navegador (se frontend)
|
|
134
|
+
- [ ] Screenshot de referência comparado (se UI)
|
|
135
|
+
|
|
136
|
+
### 4. Relatório de validação
|
|
137
|
+
|
|
138
|
+
Após cada teste, gerar relatório em `.agent/audit/`:
|
|
139
|
+
|
|
140
|
+
```markdown
|
|
141
|
+
# Validação Pós-Alteração
|
|
142
|
+
- **Data**: 2026-02-19T11:24:00
|
|
143
|
+
- **Alteração**: Adicionado agente "browser" com modelo Gemini 3 Flash
|
|
144
|
+
- **Testes executados**: 5
|
|
145
|
+
- **Resultados**:
|
|
146
|
+
- ✅ Config válida
|
|
147
|
+
- ✅ Gateway reiniciado
|
|
148
|
+
- ✅ Agente aparece no status
|
|
149
|
+
- ✅ Resposta de teste recebida
|
|
150
|
+
- ⚠️ Dropdown no dashboard: não verificado (sem browser tool)
|
|
151
|
+
- **Status**: PASS (4/5 OK, 1 não aplicável)
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Regras
|
|
155
|
+
- ✅ SEMPRE testar após qualquer alteração. Sem exceção
|
|
156
|
+
- ✅ Se o browser tool está disponível, USAR para verificação visual
|
|
157
|
+
- ✅ Capturar screenshots como prova de validação
|
|
158
|
+
- ✅ Se um teste falha, reportar imediatamente e propor correção
|
|
159
|
+
- ❌ Nunca considerar uma alteração "pronta" sem pelo menos 1 teste de verificação
|
|
160
|
+
- ❌ Nunca pular validação em produção
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: test-engineer
|
|
3
|
+
description: Criação e melhoria de testes (unitários, integração, E2E, performance). Cobertura, TDD, mocking, fixtures e estratégias de teste.
|
|
4
|
+
triggers:
|
|
5
|
+
- teste
|
|
6
|
+
- test
|
|
7
|
+
- tdd
|
|
8
|
+
- unitário
|
|
9
|
+
- integração
|
|
10
|
+
- e2e
|
|
11
|
+
- end-to-end
|
|
12
|
+
- cobertura
|
|
13
|
+
- coverage
|
|
14
|
+
- mock
|
|
15
|
+
- fixture
|
|
16
|
+
- pytest
|
|
17
|
+
- jest
|
|
18
|
+
- vitest
|
|
19
|
+
- playwright
|
|
20
|
+
- cypress
|
|
21
|
+
- benchmark
|
|
22
|
+
- performance test
|
|
23
|
+
- load test
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
# Test Engineer
|
|
27
|
+
|
|
28
|
+
## Objetivo
|
|
29
|
+
Criar, melhorar e manter testes robustos (unitários, integração, E2E, performance), garantindo cobertura adequada e confiança no deploy.
|
|
30
|
+
|
|
31
|
+
## Contexto necessário
|
|
32
|
+
- Linguagem/framework do projeto
|
|
33
|
+
- Framework de teste existente (Jest, Vitest, Pytest, Go test)
|
|
34
|
+
- Cobertura atual (se disponível)
|
|
35
|
+
- Áreas prioritárias ou código novo
|
|
36
|
+
|
|
37
|
+
## Fluxo (inspect → plan → consent → apply → verify → audit)
|
|
38
|
+
|
|
39
|
+
1. **INSPECT** (read-only):
|
|
40
|
+
- Verificar framework de teste configurado
|
|
41
|
+
- Medir cobertura atual por módulo
|
|
42
|
+
- Identificar áreas sem testes (módulos críticos)
|
|
43
|
+
- Listar funcionalidades sem cobertura E2E
|
|
44
|
+
|
|
45
|
+
2. **PLAN** — Estratégia de testes por camada:
|
|
46
|
+
|
|
47
|
+
| Camada | Proporção (Pirâmide) | Framework sugerido |
|
|
48
|
+
|--------|---------------------|-------------------|
|
|
49
|
+
| Unitários | ~70% | Jest, Vitest, Pytest, Go test |
|
|
50
|
+
| Integração | ~20% | Supertest, httpx, testcontainers |
|
|
51
|
+
| E2E | ~10% | Playwright, Cypress |
|
|
52
|
+
|
|
53
|
+
3. **CONSENT**: Confirmar escopo dos testes a criar
|
|
54
|
+
4. **APPLY**: Gerar testes + fixtures + mocks
|
|
55
|
+
5. **VERIFY**: Rodar testes, verificar cobertura
|
|
56
|
+
6. **AUDIT**: Registrar métricas de cobertura antes/depois
|
|
57
|
+
|
|
58
|
+
## Capacidades
|
|
59
|
+
|
|
60
|
+
### 🧪 Testes Unitários
|
|
61
|
+
- Testes isolados de funções/classes
|
|
62
|
+
- Mocking de dependências externas (APIs, DB, FS)
|
|
63
|
+
- Parametrização para múltiplos cenários
|
|
64
|
+
- Edge cases: null, undefined, empty, overflow, unicode
|
|
65
|
+
- Padrão AAA: Arrange → Act → Assert
|
|
66
|
+
|
|
67
|
+
### 🔗 Testes de Integração
|
|
68
|
+
- Testes de endpoints API (request → response)
|
|
69
|
+
- Testes com banco de dados real (testcontainers)
|
|
70
|
+
- Testes de filas/eventos (pub/sub, webhooks)
|
|
71
|
+
- Testes de contratos (consumer-driven contracts)
|
|
72
|
+
|
|
73
|
+
### 🌐 Testes E2E (End-to-End)
|
|
74
|
+
- Fluxos críticos de usuário (login, checkout, signup)
|
|
75
|
+
- Testes visuais (screenshot comparison)
|
|
76
|
+
- Testes cross-browser (Chrome, Firefox, Safari)
|
|
77
|
+
- Testes de acessibilidade (axe-core)
|
|
78
|
+
|
|
79
|
+
### ⚡ Testes de Performance
|
|
80
|
+
- Load testing (k6, Artillery, Locust)
|
|
81
|
+
- Benchmark de funções críticas
|
|
82
|
+
- Testes de latência e throughput
|
|
83
|
+
- Stress testing e limites de escalabilidade
|
|
84
|
+
|
|
85
|
+
### 📊 Cobertura e Métricas
|
|
86
|
+
- Cobertura de linhas, branches, funções
|
|
87
|
+
- Mutation testing (Stryker, mutmut) para medir qualidade dos testes
|
|
88
|
+
- Relatórios de tendência (cobertura ao longo do tempo)
|
|
89
|
+
|
|
90
|
+
## Checklists
|
|
91
|
+
|
|
92
|
+
### Escrevendo testes unitários
|
|
93
|
+
- [ ] Nome descritivo: `should_return_error_when_input_is_empty`
|
|
94
|
+
- [ ] Um assert por teste (preferencialmente)
|
|
95
|
+
- [ ] Sem dependência de estado externo (DB, rede, FS)
|
|
96
|
+
- [ ] Mocks com reset/cleanup entre testes
|
|
97
|
+
- [ ] Cobrir happy path + edge cases + error cases
|
|
98
|
+
- [ ] Sem sleep/wait — usar async assertions
|
|
99
|
+
|
|
100
|
+
### Escrevendo testes E2E
|
|
101
|
+
- [ ] Testar fluxo completo, não fragmentos
|
|
102
|
+
- [ ] Usar page objects / fixtures reutilizáveis
|
|
103
|
+
- [ ] Screenshots em caso de falha
|
|
104
|
+
- [ ] Retry para flakiness controlado
|
|
105
|
+
- [ ] Dados de teste isolados (seed + cleanup)
|
|
106
|
+
|
|
107
|
+
### Antes de deploy
|
|
108
|
+
- [ ] Todos os testes passam
|
|
109
|
+
- [ ] Cobertura mínima atendida (ex: 80%+)
|
|
110
|
+
- [ ] Nenhum teste flaky (intermitente)
|
|
111
|
+
- [ ] Testes de regressão validam fix de bugs anteriores
|
|
112
|
+
- [ ] Performance baseline mantida
|
|
113
|
+
|
|
114
|
+
## Ferramentas recomendadas
|
|
115
|
+
|
|
116
|
+
| Tipo | JavaScript/TS | Python | Go |
|
|
117
|
+
|------|--------------|--------|-----|
|
|
118
|
+
| Unitário | Jest, Vitest | Pytest | testing |
|
|
119
|
+
| API | Supertest | httpx, pytest-httpx | net/http/httptest |
|
|
120
|
+
| E2E | Playwright, Cypress | Playwright | chromedp |
|
|
121
|
+
| Performance | k6, Artillery | Locust | go-wrk |
|
|
122
|
+
| Cobertura | c8, istanbul | coverage.py | go test -cover |
|
|
123
|
+
| Mutation | Stryker | mutmut | go-mutesting |
|
|
124
|
+
|
|
125
|
+
## Regras de segurança
|
|
126
|
+
- ✅ Testes nunca devem conter dados reais de produção
|
|
127
|
+
- ✅ Fixtures devem usar dados sintéticos (faker, factory)
|
|
128
|
+
- ❌ Nunca desabilitar testes que falham — investigar e corrigir
|
|
129
|
+
- ❌ Nunca testar contra APIs de produção (usar mocks ou staging)
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: vpn-networking
|
|
3
|
+
description: Setup e gerenciamento de VPNs (WireGuard, Tailscale, OpenVPN, Cloudflare Tunnel, ZeroTier, Headscale) e networking seguro entre VPS, Mac, Docker e cloud.
|
|
4
|
+
triggers:
|
|
5
|
+
- vpn
|
|
6
|
+
- wireguard
|
|
7
|
+
- tailscale
|
|
8
|
+
- openvpn
|
|
9
|
+
- cloudflare tunnel
|
|
10
|
+
- zerotier
|
|
11
|
+
- headscale
|
|
12
|
+
- rede
|
|
13
|
+
- network
|
|
14
|
+
- tunel
|
|
15
|
+
- tunnel
|
|
16
|
+
- peer
|
|
17
|
+
- mesh
|
|
18
|
+
- overlay
|
|
19
|
+
- site-to-site
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
# VPN & Networking
|
|
23
|
+
|
|
24
|
+
## Objetivo
|
|
25
|
+
Configurar redes privadas seguras entre VPS, dispositivos locais e containers, usando a solução de VPN mais adequada para cada cenário.
|
|
26
|
+
|
|
27
|
+
## Soluções VPN — Comparativo
|
|
28
|
+
|
|
29
|
+
| VPN | Tipo | Setup | Performance | Self-hosted | Free | Melhor para |
|
|
30
|
+
|-----|------|-------|------------|------------|------|------------|
|
|
31
|
+
| **WireGuard** | Kernel VPN | Médio | ⚡⚡⚡ Excelente | ✅ Total | ✅ | Site-to-site, alta performance |
|
|
32
|
+
| **Tailscale** | Mesh overlay | ⚡ Fácil | ⚡⚡ Boa | ⚠️ Parcial | ✅ (3 users) | Zero-config, multi-device |
|
|
33
|
+
| **Headscale** | Mesh overlay | Médio | ⚡⚡ Boa | ✅ Total | ✅ | Tailscale self-hosted |
|
|
34
|
+
| **OpenVPN** | TLS VPN | Complexo | ⚡ OK | ✅ Total | ✅ | Legacy, compatibilidade |
|
|
35
|
+
| **Cloudflare Tunnel** | Reverse tunnel | ⚡ Fácil | ⚡⚡ Boa | ❌ Cloudflare | ✅ | Expor serviços sem IP público |
|
|
36
|
+
| **ZeroTier** | Mesh overlay | ⚡ Fácil | ⚡⚡ Boa | ✅ Total | ✅ (25 devices) | IoT, redes grandes |
|
|
37
|
+
| **Nebula** | Mesh overlay | Médio | ⚡⚡⚡ Excelente | ✅ Total | ✅ | Escala enterprise (Slack) |
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## WireGuard — Setup Completo
|
|
42
|
+
|
|
43
|
+
### Cenário: VPS → Mac (ponto a ponto)
|
|
44
|
+
|
|
45
|
+
**No servidor (VPS):**
|
|
46
|
+
```bash
|
|
47
|
+
# Instalar
|
|
48
|
+
apt install wireguard
|
|
49
|
+
|
|
50
|
+
# Gerar chaves
|
|
51
|
+
wg genkey | tee /etc/wireguard/private.key | wg pubkey > /etc/wireguard/public.key
|
|
52
|
+
chmod 600 /etc/wireguard/private.key
|
|
53
|
+
|
|
54
|
+
# Configurar /etc/wireguard/wg0.conf
|
|
55
|
+
[Interface]
|
|
56
|
+
PrivateKey = <CHAVE_PRIVADA_VPS>
|
|
57
|
+
Address = 10.66.0.1/24
|
|
58
|
+
ListenPort = 51820
|
|
59
|
+
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
|
|
60
|
+
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
|
|
61
|
+
|
|
62
|
+
[Peer]
|
|
63
|
+
PublicKey = <CHAVE_PUBLICA_MAC>
|
|
64
|
+
AllowedIPs = 10.66.0.2/32
|
|
65
|
+
|
|
66
|
+
# Ativar
|
|
67
|
+
wg-quick up wg0
|
|
68
|
+
systemctl enable wg-quick@wg0
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**No Mac (peer):**
|
|
72
|
+
```bash
|
|
73
|
+
# Instalar via Homebrew ou App Store
|
|
74
|
+
brew install wireguard-tools
|
|
75
|
+
|
|
76
|
+
# Configurar /etc/wireguard/wg0.conf
|
|
77
|
+
[Interface]
|
|
78
|
+
PrivateKey = <CHAVE_PRIVADA_MAC>
|
|
79
|
+
Address = 10.66.0.2/24
|
|
80
|
+
|
|
81
|
+
[Peer]
|
|
82
|
+
PublicKey = <CHAVE_PUBLICA_VPS>
|
|
83
|
+
Endpoint = <IP_PUBLICO_VPS>:51820
|
|
84
|
+
AllowedIPs = 10.66.0.0/24
|
|
85
|
+
PersistentKeepalive = 25
|
|
86
|
+
|
|
87
|
+
# Conectar
|
|
88
|
+
wg-quick up wg0
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Dashboard (WGDashboard — Docker)
|
|
92
|
+
```yaml
|
|
93
|
+
# docker-compose.yml
|
|
94
|
+
services:
|
|
95
|
+
wgdashboard:
|
|
96
|
+
image: donaldzou/wgdashboard:latest
|
|
97
|
+
cap_add: [NET_ADMIN, SYS_MODULE]
|
|
98
|
+
ports:
|
|
99
|
+
- "10086:10086"
|
|
100
|
+
- "51820:51820/udp"
|
|
101
|
+
volumes:
|
|
102
|
+
- ./wg-data:/etc/wireguard
|
|
103
|
+
sysctls:
|
|
104
|
+
net.ipv4.ip_forward: 1
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## Tailscale — Zero-Config
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
# VPS
|
|
113
|
+
curl -fsSL https://tailscale.com/install.sh | sh
|
|
114
|
+
tailscale up --ssh
|
|
115
|
+
|
|
116
|
+
# Mac
|
|
117
|
+
brew install tailscale
|
|
118
|
+
tailscale up
|
|
119
|
+
|
|
120
|
+
# Verificar rede
|
|
121
|
+
tailscale status
|
|
122
|
+
# Dispositivos se encontram automaticamente (MagicDNS)
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**Vantagens:** Zero-config, NAT traversal automático, MagicDNS, SSH integrado, ACLs
|
|
126
|
+
**Limitações:** Depende de coord server (Tailscale Inc.), free até 3 users
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Headscale — Tailscale Self-Hosted
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
# No servidor (control plane)
|
|
134
|
+
wget https://github.com/juanfont/headscale/releases/latest/download/headscale_linux_amd64
|
|
135
|
+
chmod +x headscale_linux_amd64
|
|
136
|
+
mv headscale_linux_amd64 /usr/local/bin/headscale
|
|
137
|
+
|
|
138
|
+
# Configurar /etc/headscale/config.yaml
|
|
139
|
+
# Registrar namespace e nodes
|
|
140
|
+
headscale namespaces create minha-rede
|
|
141
|
+
headscale nodes register --namespace minha-rede --key <node-key>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## Cloudflare Tunnel — Sem IP Público
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
# Instalar cloudflared
|
|
150
|
+
curl -fsSL https://pkg.cloudflare.com/cloudflare-main.gpg | sudo tee /usr/share/keyrings/cloudflare-main.gpg
|
|
151
|
+
apt install cloudflared
|
|
152
|
+
|
|
153
|
+
# Autenticar
|
|
154
|
+
cloudflared tunnel login
|
|
155
|
+
|
|
156
|
+
# Criar túnel
|
|
157
|
+
cloudflared tunnel create meu-tunel
|
|
158
|
+
cloudflared tunnel route dns meu-tunel app.meudominio.com
|
|
159
|
+
|
|
160
|
+
# Configurar ~/.cloudflared/config.yml
|
|
161
|
+
tunnel: <TUNNEL_ID>
|
|
162
|
+
ingress:
|
|
163
|
+
- hostname: app.meudominio.com
|
|
164
|
+
service: http://localhost:3000
|
|
165
|
+
- service: http_status:404
|
|
166
|
+
|
|
167
|
+
# Rodar
|
|
168
|
+
cloudflared tunnel run meu-tunel
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Cenários comuns e recomendação
|
|
174
|
+
|
|
175
|
+
| Cenário | VPN recomendada | Motivo |
|
|
176
|
+
|---------|----------------|--------|
|
|
177
|
+
| VPS pessoal + Mac | WireGuard | Performance, controle total |
|
|
178
|
+
| Múltiplos dispositivos pessoais | Tailscale | Zero-config, fácil |
|
|
179
|
+
| Empresa/Team | Headscale ou Tailscale Pro | ACLs, controle |
|
|
180
|
+
| Expor serviço sem IP fixo | Cloudflare Tunnel | Sem porta aberta |
|
|
181
|
+
| IoT / muitos devices | ZeroTier | Escalável, simples |
|
|
182
|
+
| Legacy / compatibilidade | OpenVPN | Suporte universal |
|
|
183
|
+
| Alta performance + escala | Nebula | Kernel-level, mesh |
|
|
184
|
+
|
|
185
|
+
## Troubleshooting comum
|
|
186
|
+
|
|
187
|
+
| Problema | Diagnóstico | Solução |
|
|
188
|
+
|---------|------------|---------|
|
|
189
|
+
| Peer não conecta | `wg show` (handshake?) | Verificar endpoint, firewall, chaves |
|
|
190
|
+
| Tráfego não passa | `ping 10.66.0.X` falha | Verificar AllowedIPs, ip_forward |
|
|
191
|
+
| DNS não resolve | `dig @10.66.0.1` | Configurar DNS no wg0.conf |
|
|
192
|
+
| Conexão cai | Sem keepalive | Adicionar `PersistentKeepalive = 25` |
|
|
193
|
+
| Performance ruim | `iperf3` entre peers | Verificar MTU (1420 para WG) |
|
|
194
|
+
|
|
195
|
+
## Regras de segurança
|
|
196
|
+
- ✅ Chaves WireGuard devem ter permissão 600
|
|
197
|
+
- ✅ Firewall deve permitir apenas porta da VPN publicamente
|
|
198
|
+
- ✅ SSH deve ser acessível SOMENTE via VPN quando possível
|
|
199
|
+
- ❌ Nunca compartilhar chaves privadas entre peers
|
|
200
|
+
- ❌ Nunca usar AllowedIPs = 0.0.0.0/0 sem entender as implicações
|