jarvis-ai-framework 2.0.0 → 2.1.1
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/AGENTS.md +12 -9
- package/agents/AGENTS.md +9 -1
- package/agents/README.md +2 -2
- package/agents/engineering/data/eng.data-engineer.agent.md +2 -2
- package/agents/engineering/eng.agent.md +4 -6
- package/agents/engineering/eng.bug-hunter.md +10 -5
- package/agents/engineering/eng.cybersecurity.agent.md +2 -4
- package/agents/engineering/eng.dev-code-reviewer.md +4 -0
- package/agents/engineering/eng.docs-writer.md +3 -3
- package/agents/engineering/eng.frontend.agent.md +17 -8
- package/agents/engineering/eng.rpa.agent.md +3 -5
- package/agents/engineering/eng.ux-designer.agent.md +4 -0
- package/agents/engineering/qa/eng.qa.cypress-specialist.md +8 -5
- package/agents/engineering/qa/eng.qa.quality-champion-task-agent.md +4 -0
- package/agents/engineering/qa/eng.qa.quality-strategist.md +18 -8
- package/agents/engineering/qa/eng.qa.test-architect.md +17 -6
- package/agents/engineering/qa/eng.qa.test-planner.md +17 -8
- package/agents/engineering/qa/eng.qa.testing-engineer.md +26 -9
- package/agents/product/prod.discovery-interviewer.md +22 -3
- package/agents/product/prod.pm-checker.md +4 -0
- package/bin/commands/map.js +43 -0
- package/bin/commands/tokens.js +93 -0
- package/bin/jarvis.js +10 -0
- package/bin/lib/config/constants.js +11 -0
- package/bin/lib/core/profile-filter.js +113 -0
- package/bin/lib/core/scanner.js +2 -2
- package/bin/lib/core/token-report.js +90 -0
- package/bin/lib/flow-map/index.js +65 -0
- package/bin/lib/flow-map/parse.js +217 -0
- package/bin/lib/flow-map/render.js +86 -0
- package/bin/lib/flow-map/tree.js +199 -0
- package/members.md +1 -1
- package/package.json +4 -2
- package/rules/AGENTS.md +18 -7
- package/rules/engineering/eng-rules.md +2 -12
- package/rules/engineering/eng-security-rules.md +1 -2
- package/rules/engineering/eng.integrations-rules.md +0 -4
- package/rules/engineering/eng.skills-rules.md +0 -4
- package/rules/engineering/eng.specializations-rules.md +0 -4
- package/rules/product/README.md +1 -0
- package/rules/product/prod-rules.md +1 -4
- package/rules/product/prod.spec-rules.md +0 -4
- package/rules/rtk-rules.md +0 -1
- package/{rules → rules-on-demand}/engineering/eng.breakdown-subtasks-rules.md +0 -4
- package/{rules → rules-on-demand}/engineering/eng.plan-rules.md +0 -4
- package/{rules → rules-on-demand}/engineering/eng.pr-rules.md +0 -4
- package/{rules → rules-on-demand}/engineering/eng.pre-pr-rules.md +0 -4
- package/{rules → rules-on-demand}/engineering/eng.start-rules.md +0 -4
- package/{rules → rules-on-demand}/engineering/eng.tech-spec-rules.md +1 -2
- package/{rules → rules-on-demand}/engineering/eng.work-rules.md +0 -4
- package/skills/AGENTS.md +22 -21
- package/skills/SKILLS-ROADMAP.md +0 -4
- package/skills/eng-ai-engineer/SKILL.md +6 -0
- package/skills/eng-backend/SKILL.md +6 -0
- package/skills/eng-backend-arch-c4/SKILL.md +10 -4
- package/skills/eng-backend-microservices-trace/SKILL.md +6 -0
- package/skills/eng-backend-nestjs/SKILL.md +16 -461
- package/skills/eng-backend-nestjs/references/1-arquitetura-modulos.md +54 -0
- package/skills/eng-backend-nestjs/references/2-guards-autenticacao.md +118 -0
- package/skills/eng-backend-nestjs/references/3-interceptors-pipes-filters.md +113 -0
- package/skills/eng-backend-nestjs/references/4-config-logging.md +61 -0
- package/skills/eng-backend-nestjs/references/5-testes.md +83 -0
- package/skills/eng-backend-nestjs/references/6-problemas-comuns.md +53 -0
- package/skills/eng-backend-rabbitmq/SKILL.md +15 -298
- package/skills/eng-backend-rabbitmq/references/1-referencia-endpoints.md +28 -0
- package/skills/eng-backend-rabbitmq/references/2-codigo-consumer-producer.md +90 -0
- package/skills/eng-backend-rabbitmq/references/3-arquiteturas-comuns.md +101 -0
- package/skills/eng-backend-rabbitmq/references/4-troubleshooting.md +93 -0
- package/skills/eng-data-bi/SKILL.md +6 -0
- package/skills/eng-data-debug/SKILL.md +6 -0
- package/skills/eng-data-engineer/SKILL.md +16 -7
- package/skills/eng-data-onboard/SKILL.md +6 -0
- package/skills/eng-data-orchestrator/SKILL.md +6 -0
- package/skills/eng-devops-performance-engineer/SKILL.md +6 -0
- package/skills/eng-frontend/SKILL.md +6 -0
- package/skills/eng-frontend-design-system/SKILL.md +13 -479
- package/skills/eng-frontend-design-system/references/1-estrutura-pacote.md +57 -0
- package/skills/eng-frontend-design-system/references/2-tokens.md +116 -0
- package/skills/eng-frontend-design-system/references/3-componentes.md +165 -0
- package/skills/eng-frontend-design-system/references/4-storybook.md +85 -0
- package/skills/eng-frontend-design-system/references/5-auditoria-versionamento.md +76 -0
- package/skills/eng-frontend-microfrontend/SKILL.md +17 -457
- package/skills/eng-frontend-microfrontend/references/1-criando-remote.md +109 -0
- package/skills/eng-frontend-microfrontend/references/2-configurando-shell.md +70 -0
- package/skills/eng-frontend-microfrontend/references/3-contratos-interface.md +73 -0
- package/skills/eng-frontend-microfrontend/references/4-shared-dependencies.md +48 -0
- package/skills/eng-frontend-microfrontend/references/5-event-bus.md +59 -0
- package/skills/eng-frontend-microfrontend/references/6-monorepo-deploy.md +77 -0
- package/skills/eng-frontend-microfrontend/references/7-troubleshooting.md +45 -0
- package/skills/eng-global-browser-extension-builder/SKILL.md +6 -0
- package/skills/eng-global-docs-write/SKILL.md +10 -5
- package/skills/eng-global-jira-comment/SKILL.md +6 -0
- package/skills/eng-global-pr/SKILL.md +7 -1
- package/skills/eng-global-task-comment/SKILL.md +6 -0
- package/skills/eng-qa-a11y-audit/SKILL.md +10 -4
- package/skills/eng-qa-bug-report/SKILL.md +18 -230
- package/skills/eng-qa-bug-report/references/1-integracao-task-managers.md +148 -0
- package/skills/eng-qa-bug-report/references/2-exemplos-de-uso.md +46 -0
- package/skills/eng-qa-bug-report/references/3-bug-to-test.md +45 -0
- package/skills/eng-qa-cypress-e2e/SKILL.md +6 -0
- package/skills/eng-qa-dev-guide/SKILL.md +9 -1
- package/skills/eng-qa-e2e/SKILL.md +9 -3
- package/skills/eng-qa-e2e-spec-writer/SKILL.md +15 -9
- package/skills/eng-qa-exploratory/SKILL.md +16 -9
- package/skills/eng-qa-gate/SKILL.md +11 -5
- package/skills/eng-qa-gate/assets/checklist-validacao.md +1 -1
- package/skills/eng-qa-graphql-contract/SKILL.md +9 -3
- package/skills/eng-qa-quality-report/SKILL.md +9 -3
- package/skills/eng-qa-test-plan/SKILL.md +6 -0
- package/skills/eng-qa-testsprite/SKILL.md +10 -4
- package/skills/eng-qa-unit-test/SKILL.md +7 -1
- package/skills/eng-scraper/SKILL.md +12 -436
- package/skills/eng-scraper/references/1-puppeteer.md +140 -0
- package/skills/eng-scraper/references/2-playwright-cheerio-pdf.md +82 -0
- package/skills/eng-scraper/references/3-anti-bot.md +94 -0
- package/skills/eng-scraper/references/4-resiliencia-etl-monitoramento.md +137 -0
- package/skills/eng-scraper-robot-builder/SKILL.md +6 -0
- package/skills/eng-security-cybersecurity/SKILL.md +13 -409
- package/skills/eng-security-cybersecurity/references/1-owasp-top-10.md +331 -0
- package/skills/eng-security-cybersecurity/references/2-secrets-management.md +31 -0
- package/skills/eng-security-cybersecurity/references/3-input-validation.md +43 -0
- package/skills/eng-security-cybersecurity/references/4-compliance.md +20 -0
- package/skills/eng-security-patch/SKILL.md +6 -0
- package/skills/eng-security-threat-model/SKILL.md +6 -0
- package/skills/eng-security-triage/SKILL.md +6 -0
- package/skills/jarvis-context-detect/SKILL.md +6 -0
- package/skills/jarvis-create-specialization/SKILL.md +6 -0
- package/skills/jarvis-docs-central/SKILL.md +6 -0
- package/skills/jarvis-docs-index/SKILL.md +10 -2
- package/skills/jarvis-evolution-architect/SKILL.md +439 -0
- package/skills/jarvis-evolution-architect/references/exemplos.md +297 -0
- package/skills/jarvis-evolution-architect/references/guia-de-uso.md +355 -0
- package/skills/jarvis-evolution-architect/references/lentes-e-conceitos.md +292 -0
- package/skills/jarvis-evolution-architect/references/visao-geral.md +272 -0
- package/skills/jarvis-init/SKILL.md +14 -7
- package/skills/jarvis-list-specializations/SKILL.md +6 -0
- package/skills/jarvis-report-issue/SKILL.md +6 -0
- package/skills/product-roadmap-report/SKILL.md +8 -0
- package/skills/product-specs/SKILL.md +9 -0
- package/skills/product-specs-update/SKILL.md +6 -0
- package/taxonomy.md +12 -12
- package/templates/AGENTS.md +2 -0
- package/templates/engineering/tech-spec-delivery-template.md +179 -0
- package/workflows/AGENTS.md +12 -2
- package/workflows/README.md +18 -16
- package/workflows/all-tools.md +7 -1
- package/workflows/engineering/data/data.contract.md +8 -0
- package/workflows/engineering/data/data.new-pipeline.md +10 -0
- package/workflows/engineering/eng.breakdown-subtasks.md +9 -0
- package/workflows/engineering/eng.bug-audit.md +9 -2
- package/workflows/engineering/eng.build-tech-spec.md +17 -146
- package/workflows/engineering/eng.create-ard-from-code.md +8 -0
- package/workflows/engineering/eng.create-ard.md +8 -0
- package/workflows/engineering/eng.create-rfc.md +7 -0
- package/workflows/engineering/eng.debug.md +3 -3
- package/workflows/engineering/eng.docs.md +9 -0
- package/workflows/engineering/eng.light-arch.md +7 -0
- package/workflows/engineering/eng.plan.md +15 -2
- package/workflows/engineering/eng.pr.md +19 -7
- package/workflows/engineering/eng.pre-pr.md +27 -1
- package/workflows/engineering/eng.review.md +13 -0
- package/workflows/engineering/eng.rpa.robot.md +16 -0
- package/workflows/engineering/eng.security-audit.md +7 -0
- package/workflows/engineering/eng.security-incident.md +6 -0
- package/workflows/engineering/eng.security-pipeline.md +9 -0
- package/workflows/engineering/eng.security-review.md +6 -0
- package/workflows/engineering/eng.start.md +22 -6
- package/workflows/engineering/eng.work.md +18 -2
- package/workflows/engineering/frontend/eng.frontend-component.md +7 -0
- package/workflows/engineering/frontend/eng.frontend-perf-audit.md +8 -0
- package/workflows/engineering/frontend/eng.frontend-review.md +8 -0
- package/workflows/engineering/qa/eng.qa-dev-quality-guide.md +6 -0
- package/workflows/engineering/qa/eng.qa-e2e-test-generation.md +6 -0
- package/workflows/engineering/qa/eng.qa-exploratory-session.md +8 -0
- package/workflows/engineering/qa/eng.qa-quality-gate-validation.md +7 -0
- package/workflows/engineering/qa/eng.qa-quality-report.md +7 -0
- package/workflows/engineering/qa/eng.qa-refinement-entry.md +7 -0
- package/workflows/engineering/qa/eng.qa-release-signoff.md +6 -0
- package/workflows/engineering/qa/eng.qa-sprint-planning.md +6 -0
- package/workflows/product/prod.roadmap.preview.md +9 -0
- package/workflows/product/prod.spec.ard.md +97 -0
- package/workflows/product/prod.spec.breakdown.md +10 -0
- package/workflows/product/prod.spec.clarify.md +8 -2
- package/workflows/product/prod.spec.discovery.md +10 -0
- package/workflows/product/prod.spec.epic.md +8 -0
- package/workflows/product/prod.spec.frd.md +7 -0
- package/workflows/product/prod.spec.issue.md +6 -0
- package/workflows/product/prod.spec.md +15 -1
- package/workflows/product/prod.spec.prd.md +7 -0
- package/workflows/taxonomy.md +58 -6
- package/workflows/warm-up.md +24 -9
- package/rules/engineering/eng.downstream-flow-rules.md +0 -297
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# Técnicas Anti-Bot
|
|
2
|
+
|
|
3
|
+
> Parte do skill `eng-scraper`. Leia este arquivo quando o site bloquear requests (403/429, captcha, fingerprint).
|
|
4
|
+
|
|
5
|
+
### Técnicas Anti-Bot
|
|
6
|
+
|
|
7
|
+
#### Headers realistas
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
// ✅ Headers que imitam browser real
|
|
11
|
+
const realisticHeaders = {
|
|
12
|
+
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
|
|
13
|
+
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8',
|
|
14
|
+
'Accept-Language': 'pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7',
|
|
15
|
+
'Accept-Encoding': 'gzip, deflate, br',
|
|
16
|
+
'Connection': 'keep-alive',
|
|
17
|
+
'Upgrade-Insecure-Requests': '1',
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
#### Rate limiting e delays aleatórios
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
// ✅ Delay com jitter para comportamento orgânico
|
|
25
|
+
function randomDelay(minMs: number, maxMs: number): Promise<void> {
|
|
26
|
+
const ms = Math.floor(Math.random() * (maxMs - minMs + 1)) + minMs
|
|
27
|
+
return new Promise((resolve) => setTimeout(resolve, ms))
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// ✅ Controle de concorrência (evitar sobrecarga no alvo)
|
|
31
|
+
import PQueue from 'p-queue'
|
|
32
|
+
|
|
33
|
+
const queue = new PQueue({
|
|
34
|
+
concurrency: 2, // máximo 2 requests simultâneos
|
|
35
|
+
intervalCap: 5, // máximo 5 requests
|
|
36
|
+
interval: 10_000, // por 10 segundos
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
async function scrapeUrls(urls: string[]) {
|
|
40
|
+
return Promise.all(
|
|
41
|
+
urls.map((url) => queue.add(async () => {
|
|
42
|
+
await randomDelay(500, 1500)
|
|
43
|
+
return scrapeUrl(url)
|
|
44
|
+
}))
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
#### Puppeteer — reduzir fingerprint de automação
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import puppeteer from 'puppeteer'
|
|
53
|
+
import { executablePath } from 'puppeteer'
|
|
54
|
+
|
|
55
|
+
// ✅ Ocultar sinais de automação via page.evaluateOnNewDocument
|
|
56
|
+
async function createStealthPage(browser: Browser): Promise<Page> {
|
|
57
|
+
const page = await browser.newPage()
|
|
58
|
+
|
|
59
|
+
await page.setUserAgent(
|
|
60
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
await page.setViewport({ width: 1366, height: 768 })
|
|
64
|
+
|
|
65
|
+
// Remover propriedades que identificam automação
|
|
66
|
+
await page.evaluateOnNewDocument(() => {
|
|
67
|
+
Object.defineProperty(navigator, 'webdriver', { get: () => undefined })
|
|
68
|
+
Object.defineProperty(navigator, 'plugins', { get: () => [1, 2, 3] })
|
|
69
|
+
Object.defineProperty(navigator, 'languages', { get: () => ['pt-BR', 'pt', 'en'] })
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
return page
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
#### Rotação de proxies
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
// ✅ Pool de proxies com rotação
|
|
80
|
+
const proxies = [
|
|
81
|
+
'http://user:pass@proxy1:8080',
|
|
82
|
+
'http://user:pass@proxy2:8080',
|
|
83
|
+
'http://user:pass@proxy3:8080',
|
|
84
|
+
]
|
|
85
|
+
|
|
86
|
+
function getRandomProxy(): string {
|
|
87
|
+
return proxies[Math.floor(Math.random() * proxies.length)]
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const browser = await puppeteer.launch({
|
|
91
|
+
headless: true,
|
|
92
|
+
args: [`--proxy-server=${getRandomProxy()}`, '--no-sandbox'],
|
|
93
|
+
})
|
|
94
|
+
```
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# Resiliência, ETL leve e monitoramento de mudanças
|
|
2
|
+
|
|
3
|
+
> Parte do skill `eng-scraper`. Leia este arquivo quando a tarefa precisar de retry, pipeline ETL leve ou monitoramento de mudanças no site.
|
|
4
|
+
|
|
5
|
+
### Resiliência e Retry
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
// ✅ Retry com backoff exponencial
|
|
9
|
+
async function withRetry<T>(
|
|
10
|
+
fn: () => Promise<T>,
|
|
11
|
+
options: { attempts?: number; baseDelay?: number; label?: string } = {}
|
|
12
|
+
): Promise<T> {
|
|
13
|
+
const { attempts = 3, baseDelay = 1000, label = 'operação' } = options
|
|
14
|
+
|
|
15
|
+
for (let attempt = 1; attempt <= attempts; attempt++) {
|
|
16
|
+
try {
|
|
17
|
+
return await fn()
|
|
18
|
+
} catch (error) {
|
|
19
|
+
if (attempt === attempts) throw error
|
|
20
|
+
|
|
21
|
+
const delay = baseDelay * Math.pow(2, attempt - 1)
|
|
22
|
+
console.warn(`${label} falhou (tentativa ${attempt}/${attempts}). Retry em ${delay}ms...`)
|
|
23
|
+
await new Promise((resolve) => setTimeout(resolve, delay))
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
throw new Error('Unreachable')
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Uso
|
|
31
|
+
const data = await withRetry(
|
|
32
|
+
() => scrapePage(url),
|
|
33
|
+
{ attempts: 3, baseDelay: 2000, label: `scrape ${url}` }
|
|
34
|
+
)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
#### Detectar mudanças de estrutura
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
// ✅ Validar que os dados extraídos fazem sentido
|
|
41
|
+
function validateExtractedData(data: unknown[], schema: { field: string; required: boolean }[]) {
|
|
42
|
+
const requiredFields = schema.filter((s) => s.required).map((s) => s.field)
|
|
43
|
+
|
|
44
|
+
const issues = data.filter((item) =>
|
|
45
|
+
requiredFields.some((field) => !item[field as keyof typeof item])
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
if (issues.length > 0) {
|
|
49
|
+
const pct = Math.round((issues.length / data.length) * 100)
|
|
50
|
+
console.warn(`ALERTA: ${issues.length}/${data.length} (${pct}%) itens com campos obrigatórios ausentes`)
|
|
51
|
+
console.warn('Possível mudança de estrutura no site alvo. Verificar seletores.')
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return data.filter((item) => requiredFields.every((f) => item[f as keyof typeof item]))
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Pipelines ETL Leve
|
|
59
|
+
|
|
60
|
+
#### Estrutura básica de pipeline
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
interface PipelineConfig {
|
|
64
|
+
sources: string[] // URLs a processar
|
|
65
|
+
transform: (raw: unknown) => unknown // transformação de dados
|
|
66
|
+
output: string // caminho do arquivo de saída
|
|
67
|
+
concurrency?: number // requests simultâneos
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async function runPipeline(config: PipelineConfig) {
|
|
71
|
+
console.log(`Iniciando pipeline: ${config.sources.length} fontes`)
|
|
72
|
+
|
|
73
|
+
// Extract
|
|
74
|
+
const rawData = await scrapeUrls(config.sources)
|
|
75
|
+
|
|
76
|
+
// Transform
|
|
77
|
+
const transformed = rawData
|
|
78
|
+
.flat()
|
|
79
|
+
.map(config.transform)
|
|
80
|
+
.filter(Boolean)
|
|
81
|
+
|
|
82
|
+
// Deduplicação por URL ou ID
|
|
83
|
+
const deduped = [...new Map(transformed.map((item) => [item.id ?? item.url, item])).values()]
|
|
84
|
+
|
|
85
|
+
// Load
|
|
86
|
+
await saveToFile(config.output, deduped)
|
|
87
|
+
console.log(`Pipeline concluído: ${deduped.length} registros salvos em ${config.output}`)
|
|
88
|
+
|
|
89
|
+
return deduped
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
#### Formatos de saída
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
import { writeFileSync } from 'fs'
|
|
97
|
+
import { stringify } from 'csv-stringify/sync'
|
|
98
|
+
|
|
99
|
+
function saveToFile(path: string, data: unknown[]) {
|
|
100
|
+
if (path.endsWith('.json')) {
|
|
101
|
+
writeFileSync(path, JSON.stringify(data, null, 2), 'utf-8')
|
|
102
|
+
} else if (path.endsWith('.csv')) {
|
|
103
|
+
const csv = stringify(data as object[], { header: true })
|
|
104
|
+
writeFileSync(path, csv, 'utf-8')
|
|
105
|
+
} else if (path.endsWith('.ndjson')) {
|
|
106
|
+
const ndjson = data.map((d) => JSON.stringify(d)).join('\n')
|
|
107
|
+
writeFileSync(path, ndjson, 'utf-8')
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Monitoramento de Mudanças
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
// ✅ Detectar mudanças em páginas monitoradas
|
|
116
|
+
async function checkForChanges(url: string, storePath: string) {
|
|
117
|
+
const current = await scrapeWithCheerio(url)
|
|
118
|
+
const currentHash = crypto.createHash('md5').update(JSON.stringify(current)).digest('hex')
|
|
119
|
+
|
|
120
|
+
let previous: { hash: string; data: unknown; timestamp: string } | null = null
|
|
121
|
+
try {
|
|
122
|
+
previous = JSON.parse(readFileSync(storePath, 'utf-8'))
|
|
123
|
+
} catch {
|
|
124
|
+
// primeira execução
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (previous?.hash === currentHash) {
|
|
128
|
+
console.log('Sem mudanças detectadas.')
|
|
129
|
+
return { changed: false }
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Persistir estado atual
|
|
133
|
+
writeFileSync(storePath, JSON.stringify({ hash: currentHash, data: current, timestamp: new Date().toISOString() }))
|
|
134
|
+
|
|
135
|
+
return { changed: true, current, previous: previous?.data }
|
|
136
|
+
}
|
|
137
|
+
```
|
|
@@ -265,6 +265,12 @@ npx tsx scripts/robots/{nome}.ts
|
|
|
265
265
|
npx playwright test scripts/robots/{nome}.ts
|
|
266
266
|
```
|
|
267
267
|
|
|
268
|
+
### Skills invocados durante a execução do skill
|
|
269
|
+
|
|
270
|
+
| Passo | Skill | Condição |
|
|
271
|
+
|-------|-------|----------|
|
|
272
|
+
| — | Nenhuma — skill autocontida | — |
|
|
273
|
+
|
|
268
274
|
---
|
|
269
275
|
|
|
270
276
|
## Árvore de Decisão
|
|
@@ -155,418 +155,22 @@ Avaliar compliance? → Secao: Compliance
|
|
|
155
155
|
|
|
156
156
|
## Fluxo de Trabalho
|
|
157
157
|
|
|
158
|
-
###
|
|
159
|
-
|
|
160
|
-
#### A01 - Broken Access Control
|
|
161
|
-
|
|
162
|
-
```typescript
|
|
163
|
-
// ❌ IDOR - Insecure Direct Object Reference
|
|
164
|
-
app.get('/api/users/:id', async (req, res) => {
|
|
165
|
-
const user = await db.user.findUnique({ where: { id: req.params.id } })
|
|
166
|
-
return res.json(user) // qualquer usuario acessa qualquer perfil
|
|
167
|
-
})
|
|
168
|
-
|
|
169
|
-
// ✅ Verificar que o usuario so acessa seus proprios dados (ou tem permissao)
|
|
170
|
-
app.get('/api/users/:id', authenticate, async (req, res) => {
|
|
171
|
-
if (req.user.id !== req.params.id && !req.user.roles.includes('admin')) {
|
|
172
|
-
throw new ForbiddenError('Acesso negado')
|
|
173
|
-
}
|
|
174
|
-
const user = await db.user.findUnique({ where: { id: req.params.id } })
|
|
175
|
-
return res.json(user)
|
|
176
|
-
})
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
```typescript
|
|
180
|
-
// ❌ Funcao admin sem guard
|
|
181
|
-
@Controller('admin')
|
|
182
|
-
export class AdminController {
|
|
183
|
-
@Get('users')
|
|
184
|
-
listUsers() { return this.userService.findAll() }
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
// ✅ Guard de role obrigatorio
|
|
188
|
-
@Controller('admin')
|
|
189
|
-
@UseGuards(AuthGuard, RolesGuard)
|
|
190
|
-
@Roles('admin')
|
|
191
|
-
export class AdminController {
|
|
192
|
-
@Get('users')
|
|
193
|
-
listUsers() { return this.userService.findAll() }
|
|
194
|
-
}
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
#### A02 - Cryptographic Failures
|
|
198
|
-
|
|
199
|
-
```typescript
|
|
200
|
-
// ❌ Hash fraco para senhas
|
|
201
|
-
const hash = crypto.createHash('md5').update(password).digest('hex')
|
|
158
|
+
### Referencias (leia so o tema que a tarefa pedir)
|
|
202
159
|
|
|
203
|
-
|
|
204
|
-
import * as bcrypt from 'bcrypt'
|
|
205
|
-
const SALT_ROUNDS = 12
|
|
206
|
-
const hash = await bcrypt.hash(password, SALT_ROUNDS)
|
|
207
|
-
const isValid = await bcrypt.compare(password, hash)
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
```typescript
|
|
211
|
-
// ❌ Dados sensiveis sem criptografia em repouso
|
|
212
|
-
await db.user.create({ data: { cpf: '123.456.789-00' } })
|
|
213
|
-
|
|
214
|
-
// ✅ Criptografar dados sensiveis (PII)
|
|
215
|
-
import { createCipheriv, createDecipheriv, randomBytes } from 'crypto'
|
|
216
|
-
|
|
217
|
-
function encrypt(text: string, key: Buffer): string {
|
|
218
|
-
const iv = randomBytes(16)
|
|
219
|
-
const cipher = createCipheriv('aes-256-gcm', key, iv)
|
|
220
|
-
const encrypted = Buffer.concat([cipher.update(text, 'utf8'), cipher.final()])
|
|
221
|
-
const tag = cipher.getAuthTag()
|
|
222
|
-
return `${iv.toString('hex')}:${tag.toString('hex')}:${encrypted.toString('hex')}`
|
|
223
|
-
}
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
#### A03 - Injection
|
|
227
|
-
|
|
228
|
-
```typescript
|
|
229
|
-
// ❌ SQL injection
|
|
230
|
-
const query = `SELECT * FROM users WHERE email = '${req.body.email}'`
|
|
231
|
-
await db.$queryRawUnsafe(query)
|
|
232
|
-
|
|
233
|
-
// ✅ Queries parametrizadas (sempre)
|
|
234
|
-
const user = await db.$queryRaw`SELECT * FROM users WHERE email = ${req.body.email}`
|
|
235
|
-
// Ou via ORM (Prisma, TypeORM)
|
|
236
|
-
const user = await db.user.findUnique({ where: { email: req.body.email } })
|
|
237
|
-
```
|
|
238
|
-
|
|
239
|
-
```typescript
|
|
240
|
-
// ❌ Command injection
|
|
241
|
-
const result = exec(`ping ${req.query.host}`)
|
|
242
|
-
|
|
243
|
-
// ✅ Validar e sanitizar ou usar APIs seguras
|
|
244
|
-
import { isIP } from 'net'
|
|
245
|
-
if (!isIP(req.query.host)) throw new BadRequestError('Host invalido')
|
|
246
|
-
const result = execFile('ping', ['-c', '1', req.query.host])
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
```typescript
|
|
250
|
-
// ❌ NoSQL injection (MongoDB)
|
|
251
|
-
db.collection('users').find({ email: req.body.email, password: req.body.password })
|
|
252
|
-
// Atacante envia: { "password": { "$ne": "" } }
|
|
253
|
-
|
|
254
|
-
// ✅ Validar tipos explicitamente
|
|
255
|
-
import { z } from 'zod'
|
|
256
|
-
const loginSchema = z.object({
|
|
257
|
-
email: z.string().email(),
|
|
258
|
-
password: z.string().min(8).max(128),
|
|
259
|
-
})
|
|
260
|
-
const { email, password } = loginSchema.parse(req.body)
|
|
261
|
-
const user = await db.collection('users').findOne({ email })
|
|
262
|
-
const isValid = await bcrypt.compare(password, user.passwordHash)
|
|
263
|
-
```
|
|
160
|
+
Leia **só** o arquivo do tema que a tarefa pedir; o restante fica fora do contexto.
|
|
264
161
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
2. Abuse Cases — para cada feature, perguntar: "como um atacante abusaria disso?"
|
|
272
|
-
3. Rate Limiting — toda operacao sensivel deve ter limite
|
|
273
|
-
4. Least Privilege — dar apenas as permissoes necessarias
|
|
274
|
-
5. Fail Secure — em caso de erro, negar acesso (nao permitir)
|
|
275
|
-
6. Input Boundaries — definir limites maximos para todos os inputs
|
|
276
|
-
```
|
|
277
|
-
|
|
278
|
-
#### A05 - Security Misconfiguration
|
|
279
|
-
|
|
280
|
-
```typescript
|
|
281
|
-
// ✅ Headers de seguranca com Helmet (Express/NestJS)
|
|
282
|
-
import helmet from 'helmet'
|
|
283
|
-
|
|
284
|
-
app.use(helmet({
|
|
285
|
-
contentSecurityPolicy: {
|
|
286
|
-
directives: {
|
|
287
|
-
defaultSrc: ["'self'"],
|
|
288
|
-
scriptSrc: ["'self'"],
|
|
289
|
-
styleSrc: ["'self'", "'unsafe-inline'"], // avaliar remover unsafe-inline
|
|
290
|
-
imgSrc: ["'self'", 'data:', 'https:'],
|
|
291
|
-
connectSrc: ["'self'"],
|
|
292
|
-
fontSrc: ["'self'"],
|
|
293
|
-
objectSrc: ["'none'"],
|
|
294
|
-
mediaSrc: ["'self'"],
|
|
295
|
-
frameSrc: ["'none'"],
|
|
296
|
-
},
|
|
297
|
-
},
|
|
298
|
-
crossOriginEmbedderPolicy: true,
|
|
299
|
-
crossOriginOpenerPolicy: true,
|
|
300
|
-
crossOriginResourcePolicy: { policy: 'same-site' },
|
|
301
|
-
dnsPrefetchControl: true,
|
|
302
|
-
frameguard: { action: 'deny' },
|
|
303
|
-
hsts: { maxAge: 31536000, includeSubDomains: true, preload: true },
|
|
304
|
-
ieNoOpen: true,
|
|
305
|
-
noSniff: true,
|
|
306
|
-
referrerPolicy: { policy: 'strict-origin-when-cross-origin' },
|
|
307
|
-
xssFilter: true,
|
|
308
|
-
}))
|
|
309
|
-
```
|
|
310
|
-
|
|
311
|
-
```typescript
|
|
312
|
-
// ✅ CORS restritivo
|
|
313
|
-
app.enableCors({
|
|
314
|
-
origin: process.env.ALLOWED_ORIGINS?.split(',') ?? [],
|
|
315
|
-
methods: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'],
|
|
316
|
-
allowedHeaders: ['Content-Type', 'Authorization'],
|
|
317
|
-
credentials: true,
|
|
318
|
-
maxAge: 86400,
|
|
319
|
-
})
|
|
320
|
-
|
|
321
|
-
// ❌ CORS aberto
|
|
322
|
-
app.enableCors({ origin: '*' }) // nunca em producao
|
|
323
|
-
```
|
|
324
|
-
|
|
325
|
-
```typescript
|
|
326
|
-
// ❌ Debug mode em producao
|
|
327
|
-
app.listen(3000, () => {
|
|
328
|
-
console.log('Stack traces habilitados')
|
|
329
|
-
})
|
|
330
|
-
|
|
331
|
-
// ✅ Error handler que nao vaza detalhes
|
|
332
|
-
app.useGlobalFilters(new HttpExceptionFilter()) // retorna apenas code + message
|
|
333
|
-
```
|
|
334
|
-
|
|
335
|
-
#### A06 - Vulnerable Components
|
|
336
|
-
|
|
337
|
-
```bash
|
|
338
|
-
# ✅ Verificar vulnerabilidades em dependencias
|
|
339
|
-
npm audit # Node.js
|
|
340
|
-
npm audit --audit-level=high # Apenas high e critical
|
|
341
|
-
pip audit # Python
|
|
342
|
-
go vuln check ./... # Go
|
|
343
|
-
cargo audit # Rust
|
|
344
|
-
|
|
345
|
-
# ✅ Verificar lockfile integrity
|
|
346
|
-
# lockfile deve estar commitado e nao ter sido adulterado
|
|
347
|
-
git diff --name-only HEAD | grep -E "package-lock|yarn.lock|pnpm-lock"
|
|
348
|
-
|
|
349
|
-
# ✅ Verificar licencas
|
|
350
|
-
npx license-checker --summary # Node.js
|
|
351
|
-
```
|
|
352
|
-
|
|
353
|
-
```
|
|
354
|
-
Politica de dependencias:
|
|
355
|
-
|
|
356
|
-
1. Lockfile SEMPRE commitado — previne supply chain attacks
|
|
357
|
-
2. npm audit em CI — bloquear deploy com vulnerabilidades HIGH/CRITICAL
|
|
358
|
-
3. Dependencias diretas: preferir pacotes com manutencao ativa
|
|
359
|
-
4. Pinning de versao: usar ranges conservadores (^major.minor)
|
|
360
|
-
5. Revisar changelogs antes de atualizar major versions
|
|
361
|
-
```
|
|
162
|
+
| Tema | Quando ler | Arquivo |
|
|
163
|
+
|------|-----------|---------|
|
|
164
|
+
| Auditoria OWASP Top 10 | A tarefa for uma auditoria de seguranca do codigo (OWASP Top 10) | `references/1-owasp-top-10.md` |
|
|
165
|
+
| Secrets Management | A tarefa envolver segredos, tokens, chaves ou variaveis sensiveis | `references/2-secrets-management.md` |
|
|
166
|
+
| Input Validation e Sanitizacao | A tarefa envolver validacao e sanitizacao de entradas | `references/3-input-validation.md` |
|
|
167
|
+
| Compliance | A tarefa envolver LGPD, GDPR ou outros requisitos de conformidade | `references/4-compliance.md` |
|
|
362
168
|
|
|
363
|
-
|
|
169
|
+
### Skills invocados durante a execução do skill
|
|
364
170
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
const loginLimiter = rateLimit({
|
|
370
|
-
windowMs: 15 * 60 * 1000, // 15 minutos
|
|
371
|
-
max: 5, // 5 tentativas
|
|
372
|
-
message: 'Muitas tentativas de login. Tente novamente em 15 minutos.',
|
|
373
|
-
standardHeaders: true,
|
|
374
|
-
legacyHeaders: false,
|
|
375
|
-
keyGenerator: (req) => req.body.email ?? req.ip, // por email, nao por IP
|
|
376
|
-
})
|
|
377
|
-
|
|
378
|
-
app.post('/auth/login', loginLimiter, loginController)
|
|
379
|
-
```
|
|
380
|
-
|
|
381
|
-
```typescript
|
|
382
|
-
// ✅ Session security
|
|
383
|
-
app.use(session({
|
|
384
|
-
secret: process.env.SESSION_SECRET,
|
|
385
|
-
name: '__session', // nome custom (nao usar 'connect.sid')
|
|
386
|
-
resave: false,
|
|
387
|
-
saveUninitialized: false,
|
|
388
|
-
cookie: {
|
|
389
|
-
secure: true, // HTTPS only
|
|
390
|
-
httpOnly: true, // nao acessivel via JS
|
|
391
|
-
sameSite: 'strict', // prevenir CSRF
|
|
392
|
-
maxAge: 30 * 60 * 1000, // 30 minutos
|
|
393
|
-
domain: process.env.COOKIE_DOMAIN,
|
|
394
|
-
},
|
|
395
|
-
}))
|
|
396
|
-
```
|
|
397
|
-
|
|
398
|
-
#### A08 - Software and Data Integrity Failures
|
|
399
|
-
|
|
400
|
-
```typescript
|
|
401
|
-
// ✅ Verificar assinatura de webhooks
|
|
402
|
-
function verifyWebhookSignature(payload: Buffer, signature: string, secret: string): boolean {
|
|
403
|
-
const expected = crypto
|
|
404
|
-
.createHmac('sha256', secret)
|
|
405
|
-
.update(payload)
|
|
406
|
-
.digest('hex')
|
|
407
|
-
return crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(`sha256=${expected}`))
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
// ✅ Deserialization segura — nunca usar eval() ou Function()
|
|
411
|
-
// ❌ const data = eval(userInput)
|
|
412
|
-
// ❌ const fn = new Function(userInput)
|
|
413
|
-
// ✅ const data = JSON.parse(userInput) // com schema validation depois
|
|
414
|
-
const parsed = safeSchema.parse(JSON.parse(userInput))
|
|
415
|
-
```
|
|
416
|
-
|
|
417
|
-
#### A09 - Security Logging and Monitoring
|
|
418
|
-
|
|
419
|
-
```typescript
|
|
420
|
-
// ✅ Eventos de seguranca que DEVEM ser logados
|
|
421
|
-
const SECURITY_EVENTS = [
|
|
422
|
-
'auth.login.success',
|
|
423
|
-
'auth.login.failure',
|
|
424
|
-
'auth.logout',
|
|
425
|
-
'auth.password.change',
|
|
426
|
-
'auth.password.reset',
|
|
427
|
-
'auth.mfa.enable',
|
|
428
|
-
'auth.mfa.disable',
|
|
429
|
-
'auth.token.refresh',
|
|
430
|
-
'access.denied',
|
|
431
|
-
'access.admin.action',
|
|
432
|
-
'data.export',
|
|
433
|
-
'data.delete',
|
|
434
|
-
'config.change',
|
|
435
|
-
'user.create',
|
|
436
|
-
'user.role.change',
|
|
437
|
-
] as const
|
|
438
|
-
|
|
439
|
-
// ✅ Log de seguranca estruturado
|
|
440
|
-
function logSecurityEvent(event: string, context: {
|
|
441
|
-
userId?: string
|
|
442
|
-
ip: string
|
|
443
|
-
userAgent: string
|
|
444
|
-
resource?: string
|
|
445
|
-
action?: string
|
|
446
|
-
result: 'success' | 'failure'
|
|
447
|
-
reason?: string
|
|
448
|
-
}) {
|
|
449
|
-
logger.info({ ...context, event, type: 'security' }, `Security: ${event}`)
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
// ❌ Nunca logar dados sensiveis
|
|
453
|
-
// logSecurityEvent('auth.login', { password: '...' }) — NUNCA
|
|
454
|
-
```
|
|
455
|
-
|
|
456
|
-
#### A10 - Server-Side Request Forgery (SSRF)
|
|
457
|
-
|
|
458
|
-
```typescript
|
|
459
|
-
// ❌ SSRF — usuario controla URL de fetch
|
|
460
|
-
app.get('/proxy', async (req, res) => {
|
|
461
|
-
const response = await fetch(req.query.url) // atacante pode acessar http://169.254.169.254/
|
|
462
|
-
return res.json(await response.json())
|
|
463
|
-
})
|
|
464
|
-
|
|
465
|
-
// ✅ Allowlist de dominios + validacao
|
|
466
|
-
const ALLOWED_DOMAINS = new Set(process.env.ALLOWED_PROXY_DOMAINS?.split(',') ?? [])
|
|
467
|
-
|
|
468
|
-
function validateUrl(urlString: string): URL {
|
|
469
|
-
const url = new URL(urlString)
|
|
470
|
-
|
|
471
|
-
// Bloquear IPs internos e metadata
|
|
472
|
-
if (url.hostname === 'localhost' || url.hostname === '127.0.0.1' ||
|
|
473
|
-
url.hostname.startsWith('169.254.') || url.hostname.startsWith('10.') ||
|
|
474
|
-
url.hostname.startsWith('192.168.') || url.hostname.startsWith('172.')) {
|
|
475
|
-
throw new BadRequestError('URL interna nao permitida')
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
if (!ALLOWED_DOMAINS.has(url.hostname)) {
|
|
479
|
-
throw new BadRequestError(`Dominio ${url.hostname} nao permitido`)
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
return url
|
|
483
|
-
}
|
|
484
|
-
```
|
|
485
|
-
|
|
486
|
-
### Secrets Management
|
|
487
|
-
|
|
488
|
-
```bash
|
|
489
|
-
# ✅ Escanear secrets no codigo
|
|
490
|
-
# Ferramentas: gitleaks, trufflehog, detect-secrets
|
|
491
|
-
# Executar antes de cada commit (pre-commit hook)
|
|
492
|
-
|
|
493
|
-
# Exemplo com gitleaks (se disponivel)
|
|
494
|
-
gitleaks detect --source . --report-format json --report-path gitleaks-report.json
|
|
495
|
-
|
|
496
|
-
# Verificacao manual de patterns comuns
|
|
497
|
-
grep -rn --include="*.ts" --include="*.js" --include="*.py" --include="*.yml" --include="*.yaml" \
|
|
498
|
-
-E "(password|secret|token|api_key|apikey|private_key|AWS_|STRIPE_SK_)\s*[:=]\s*['\"][^'\"]+['\"]" \
|
|
499
|
-
. 2>/dev/null
|
|
500
|
-
```
|
|
501
|
-
|
|
502
|
-
```
|
|
503
|
-
Regras de secrets:
|
|
504
|
-
|
|
505
|
-
1. NUNCA commitar secrets no codigo — usar variaveis de ambiente
|
|
506
|
-
2. .env NUNCA no git — incluir no .gitignore
|
|
507
|
-
3. Rotacao periodica — secrets tem prazo de validade
|
|
508
|
-
4. Least privilege — cada servico tem suas proprias credenciais
|
|
509
|
-
5. Vault para producao — HashiCorp Vault, AWS Secrets Manager, GCP Secret Manager
|
|
510
|
-
6. Pre-commit hook — bloquear commits com secrets detectados
|
|
511
|
-
7. Historico git — se um secret vazou, rotacionar IMEDIATAMENTE (nao basta remover do codigo)
|
|
512
|
-
```
|
|
513
|
-
|
|
514
|
-
### Input Validation e Sanitizacao
|
|
515
|
-
|
|
516
|
-
```typescript
|
|
517
|
-
// ✅ Schema validation com Zod (recomendado)
|
|
518
|
-
import { z } from 'zod'
|
|
519
|
-
|
|
520
|
-
const createUserSchema = z.object({
|
|
521
|
-
name: z.string().min(2).max(100).trim(),
|
|
522
|
-
email: z.string().email().max(255).toLowerCase(),
|
|
523
|
-
password: z.string().min(8).max(128)
|
|
524
|
-
.regex(/[A-Z]/, 'Deve conter pelo menos uma maiuscula')
|
|
525
|
-
.regex(/[0-9]/, 'Deve conter pelo menos um numero')
|
|
526
|
-
.regex(/[^A-Za-z0-9]/, 'Deve conter pelo menos um caractere especial'),
|
|
527
|
-
age: z.number().int().min(13).max(150).optional(),
|
|
528
|
-
role: z.enum(['user', 'editor']), // nunca aceitar 'admin' via input
|
|
529
|
-
})
|
|
530
|
-
|
|
531
|
-
// ✅ Validar no controller (antes de qualquer processamento)
|
|
532
|
-
@Post()
|
|
533
|
-
async createUser(@Body() body: unknown) {
|
|
534
|
-
const data = createUserSchema.parse(body)
|
|
535
|
-
return this.userService.create(data)
|
|
536
|
-
}
|
|
537
|
-
```
|
|
538
|
-
|
|
539
|
-
```typescript
|
|
540
|
-
// ✅ Sanitizacao de HTML (se aceitar rich text)
|
|
541
|
-
import DOMPurify from 'isomorphic-dompurify'
|
|
542
|
-
|
|
543
|
-
function sanitizeHtml(dirty: string): string {
|
|
544
|
-
return DOMPurify.sanitize(dirty, {
|
|
545
|
-
ALLOWED_TAGS: ['b', 'i', 'em', 'strong', 'a', 'p', 'br', 'ul', 'ol', 'li'],
|
|
546
|
-
ALLOWED_ATTR: ['href', 'target'],
|
|
547
|
-
})
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
// ❌ Renderizar input do usuario sem sanitizar
|
|
551
|
-
element.innerHTML = userInput // XSS
|
|
552
|
-
```
|
|
553
|
-
|
|
554
|
-
### Compliance
|
|
555
|
-
|
|
556
|
-
```
|
|
557
|
-
LGPD/GDPR — checklist minimo:
|
|
558
|
-
|
|
559
|
-
1. Consentimento explicito para coleta de dados pessoais
|
|
560
|
-
2. Direito de acesso — endpoint para exportar dados do usuario
|
|
561
|
-
3. Direito de exclusao — endpoint para deletar dados (ou anonimizar)
|
|
562
|
-
4. Minimizacao — coletar apenas o necessario
|
|
563
|
-
5. Retencao — definir e implementar politica de retencao
|
|
564
|
-
6. Criptografia de PII em repouso e transito
|
|
565
|
-
7. Log de acesso a dados sensiveis (audit trail)
|
|
566
|
-
8. Data Processing Agreement com fornecedores
|
|
567
|
-
9. Notificacao de breach em 72h (GDPR) / prazo razoavel (LGPD)
|
|
568
|
-
10. DPO designado (quando aplicavel)
|
|
569
|
-
```
|
|
171
|
+
| Passo | Skill | Condição |
|
|
172
|
+
|-------|-------|----------|
|
|
173
|
+
| — | Nenhuma — skill autocontida | — |
|
|
570
174
|
|
|
571
175
|
---
|
|
572
176
|
|
|
@@ -643,4 +247,4 @@ Proximo passo: {corrigir criticos / revisar relatorio / rodar SAST no CI}
|
|
|
643
247
|
- **Auth e RBAC**: Ver skill `eng-backend` para implementacao de autenticacao
|
|
644
248
|
- **Guards e pipes NestJS**: Ver skill `eng-backend-nestjs` para middleware de seguranca
|
|
645
249
|
- **Frontend XSS**: Ver skill `eng-frontend` para CSP e sanitizacao no client
|
|
646
|
-
- **Supply chain**:
|
|
250
|
+
- **Supply chain**: hardening de CI/CD segue este skill e as regras do projeto (ainda não há skill específico de infraestrutura)
|