@brunosps00/dev-workflow 1.0.6 → 1.1.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 +2 -2
- package/bin/dev-workflow.js +5 -0
- package/lib/constants.js +2 -2
- package/lib/install-deps.js +88 -3
- package/lib/setup-wsl-browser.js +149 -0
- package/package.json +1 -1
- package/scaffold/en/commands/dw-analyze-project.md +22 -0
- package/scaffold/en/commands/dw-autopilot.md +3 -1
- package/scaffold/en/commands/dw-functional-doc.md +11 -3
- package/scaffold/en/commands/dw-generate-pr.md +2 -2
- package/scaffold/en/commands/dw-qa.md +1 -1
- package/scaffold/en/commands/dw-redesign-ui.md +2 -2
- package/scaffold/en/commands/dw-review.md +7 -5
- package/scaffold/en/commands/dw-secure-audit.md +72 -15
- package/scaffold/en/templates/constitution-template.md +8 -3
- package/scaffold/en/templates/functional-doc/playwright.flow.mjs.tpl +17 -0
- package/scaffold/pt-br/commands/dw-analyze-project.md +22 -0
- package/scaffold/pt-br/commands/dw-autopilot.md +3 -1
- package/scaffold/pt-br/commands/dw-functional-doc.md +11 -3
- package/scaffold/pt-br/commands/dw-generate-pr.md +2 -2
- package/scaffold/pt-br/commands/dw-qa.md +1 -1
- package/scaffold/pt-br/commands/dw-redesign-ui.md +2 -2
- package/scaffold/pt-br/commands/dw-review.md +7 -5
- package/scaffold/pt-br/commands/dw-secure-audit.md +72 -15
- package/scaffold/pt-br/templates/constitution-template.md +8 -3
- package/scaffold/pt-br/templates/functional-doc/playwright.flow.mjs.tpl +17 -0
- package/scaffold/scripts/cdp-relay/Cargo.toml +16 -0
- package/scaffold/scripts/cdp-relay/src/main.rs +49 -0
- package/scaffold/scripts/functional-doc/generate-dossier.mjs +7 -9
- package/scaffold/scripts/functional-doc/run-playwright-flow.mjs +192 -183
- package/scaffold/scripts/lib/capture-screenshots.mjs +133 -0
- package/scaffold/scripts/lib/resolve-browser.mjs +405 -0
- package/scaffold/scripts/lib/ui-slop-detect.mjs +102 -0
- package/scaffold/skills/dw-testing-discipline/references/playwright-recipes.md +50 -0
- package/scaffold/skills/dw-ui-discipline/SKILL.md +5 -0
- package/scaffold/skills/dw-ui-discipline/references/color-oklch.md +60 -0
- package/scaffold/skills/dw-ui-discipline/references/motion.md +52 -0
- package/scaffold/skills/dw-ui-discipline/references/responsive.md +52 -0
- package/scaffold/skills/dw-ui-discipline/references/type-scale.md +48 -0
- package/scaffold/skills/dw-ui-discipline/references/ux-writing.md +52 -0
- package/scaffold/skills/security-review/SKILL.md +19 -0
- package/scaffold/skills/security-review/references/sast.md +67 -0
- package/scaffold/skills/security-review/references/secrets.md +46 -0
- package/scaffold/en/templates/functional-doc/playwright.spec.ts.tpl +0 -19
- package/scaffold/pt-br/templates/functional-doc/playwright.spec.ts.tpl +0 -19
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
<system_instructions>
|
|
2
|
-
You are the security audit orchestrator
|
|
2
|
+
You are the security audit orchestrator — the **Security Gate**. Runs OWASP static review + SAST
|
|
3
|
+
(Semgrep, diff-focused on the generated code) + dedicated secret scanning (gitleaks) + supply-chain
|
|
4
|
+
CVE/secret/IaC scanning (Trivy + native lockfile audit) + supply-chain compromise detection + outdated
|
|
5
|
+
check, in one pass. Hard-gates downstream commands when any blocking finding exists.
|
|
3
6
|
|
|
4
|
-
|
|
7
|
+
It is **auto-invoked by `/dw-review` and `/dw-generate-pr`** (for TS/Python/C#/Rust), runs as an **explicit,
|
|
8
|
+
named phase in `/dw-autopilot`** (after review + QA, before commit/PR), and is **runnable standalone** any
|
|
9
|
+
time. `/dw-generate-pr` re-enforces the verdict as a final hard gate. All three keep gating on security —
|
|
10
|
+
the standalone command and the named phase are additive, not a replacement.
|
|
5
11
|
|
|
6
12
|
## When to Use
|
|
7
13
|
- Auto-invoked: `/dw-review` and `/dw-generate-pr` for supported languages.
|
|
@@ -10,7 +16,7 @@ Auto-invoked by `/dw-review` and `/dw-generate-pr` for TS/Python/C#/Rust project
|
|
|
10
16
|
- Do NOT use as a substitute for human security review on high-stakes auth/payment code (use `security-review` skill PLUS this).
|
|
11
17
|
|
|
12
18
|
## Pipeline Position
|
|
13
|
-
**Predecessor:**
|
|
19
|
+
**Predecessor:** `/dw-review` + `/dw-qa` (the Security Gate runs after they pass) | **Successor:** `/dw-commit` / `/dw-generate-pr` if APPROVED, or `/dw-bugfix` to address findings. Can also run standalone any time.
|
|
14
20
|
|
|
15
21
|
## Modes
|
|
16
22
|
|
|
@@ -33,10 +39,20 @@ Auto-invoked by `/dw-review` and `/dw-generate-pr` for TS/Python/C#/Rust project
|
|
|
33
39
|
|
|
34
40
|
## Required Dependencies
|
|
35
41
|
|
|
36
|
-
- **Trivy** —
|
|
42
|
+
- **Trivy** — SCA / secrets / IaC (via `npx @brunosps00/dev-workflow install-deps`).
|
|
43
|
+
- **Semgrep** — SAST layer (optional but recommended). If absent, the SAST layer is skipped and noted.
|
|
44
|
+
- **gitleaks** — dedicated secret scan (optional but recommended). If absent, falls back to Trivy secrets.
|
|
37
45
|
- **Context7 MCP** — for framework-version-specific security best practices.
|
|
38
46
|
|
|
39
|
-
|
|
47
|
+
All scanners are optional individually: a missing tool degrades that layer and is **reported** in the
|
|
48
|
+
summary (the gate never crashes for a missing scanner), but the missing coverage is visible. Install via
|
|
49
|
+
`npx @brunosps00/dev-workflow install-deps`.
|
|
50
|
+
|
|
51
|
+
## Detection Layers
|
|
52
|
+
|
|
53
|
+
**Diff focus (the generated code):** layers that support it scope to the diff against the PR base
|
|
54
|
+
(`git merge-base HEAD origin/main`) so the gate concentrates on the code just written, without noise from
|
|
55
|
+
pre-existing code. A `--full` periodic pass scans the whole tree.
|
|
40
56
|
|
|
41
57
|
### Layer 1: OWASP Static Review (via `security-review` skill)
|
|
42
58
|
|
|
@@ -72,6 +88,23 @@ Cross-references the dependency tree against:
|
|
|
72
88
|
|
|
73
89
|
Output: `.dw/secure-audit/compromise-findings.md` per affected package: COMPROMISED / suspicious / clean.
|
|
74
90
|
|
|
91
|
+
### Layer 4: SAST — Semgrep (semantic analysis of generated code)
|
|
92
|
+
|
|
93
|
+
Deterministic, semantic static analysis of the **diff** (`--baseline-commit`), complementing the human-style
|
|
94
|
+
Layer 1. Pinned rulesets: `p/security-audit`, `p/owasp-top-ten`, `p/secrets` (+ language packs as detected).
|
|
95
|
+
Map Semgrep `ERROR`→HIGH (or CRITICAL for RCE/authn-bypass/SQLi CWEs), `WARNING`→MEDIUM, `INFO`→LOW. Apply
|
|
96
|
+
the **fp-check** reachability discipline before a finding blocks (see `security-review/references/sast.md`).
|
|
97
|
+
|
|
98
|
+
Output: `.dw/secure-audit/sast-findings.md`. If `semgrep` is absent: skipped + noted in the summary.
|
|
99
|
+
|
|
100
|
+
### Layer 5: Dedicated secret scan — gitleaks
|
|
101
|
+
|
|
102
|
+
`gitleaks protect --staged` (uncommitted) or `gitleaks detect --log-opts <base>..HEAD` (branch), `--redact`.
|
|
103
|
+
Authoritative for the diff; complements Trivy secrets (dedupe by `file:line`). **Any hit = REJECTED, no ADR
|
|
104
|
+
exception** — secrets are removed and rotated, not justified. See `security-review/references/secrets.md`.
|
|
105
|
+
|
|
106
|
+
Output: `.dw/secure-audit/secret-findings.md`. If `gitleaks` is absent: falls back to Trivy secrets + noted.
|
|
107
|
+
|
|
75
108
|
### Plus: outdated check
|
|
76
109
|
|
|
77
110
|
`npm outdated` / `pip list --outdated` / `dotnet list outdated` / `cargo outdated` to identify packages behind by minor or major versions.
|
|
@@ -84,9 +117,11 @@ All findings are classified into one of these tiers in `.dw/secure-audit/audit-s
|
|
|
84
117
|
|
|
85
118
|
| Tier | Criteria | Block | Suggested Action |
|
|
86
119
|
|------|----------|-------|------------------|
|
|
120
|
+
| **SECRET** | Hardcoded credential/key/token (gitleaks or Trivy), survives allowlist | YES — **no ADR exception** | Remove from code + history, rotate, move to a secret store |
|
|
87
121
|
| **COMPROMISED** | Package known to be malicious in this version range | YES | Immediate remove / pin to safe version |
|
|
88
|
-
| **CRITICAL** | CVE CVSS ≥9.0 OR exploits in the wild OR auth bypass | YES | Update or
|
|
89
|
-
| **HIGH** | CVE CVSS 7.0–8.9 OR exploitable in
|
|
122
|
+
| **CRITICAL** | CVE CVSS ≥9.0 OR exploits in the wild OR auth bypass; OR SAST high-impact CWE (SQLi/RCE/authn-bypass/SSRF/deserialization) reachable | YES | Update/replace or fix within 24h |
|
|
123
|
+
| **HIGH** | CVE CVSS 7.0–8.9 OR exploitable in context; OR Semgrep `ERROR` reachable (fp-check passed) | YES | Update/replace or fix within 1 week |
|
|
124
|
+
| **MEDIUM / LOW** | CVE CVSS <7.0; OR Semgrep `WARNING`/`INFO`; OR unreachable finding downgraded by fp-check | NO (advisory) | Track and fix routinely |
|
|
90
125
|
| **OUTDATED-MAJOR** | ≥1 major version behind (e.g., React 17 → 19) | NO | Plan migration in next quarter |
|
|
91
126
|
| **OUTDATED-MINOR** | Minor/patch behind | NO | Update routinely |
|
|
92
127
|
| **CLEAN** | No findings | NO | — |
|
|
@@ -94,19 +129,26 @@ All findings are classified into one of these tiers in `.dw/secure-audit/audit-s
|
|
|
94
129
|
## Hard Gates
|
|
95
130
|
|
|
96
131
|
The verdict is one of:
|
|
97
|
-
- **APPROVED** — no CRITICAL or HIGH
|
|
98
|
-
- **REJECTED** — ≥1
|
|
132
|
+
- **APPROVED** — no SECRET, COMPROMISED, CRITICAL, or HIGH findings. Verdict file `.dw/secure-audit/audit-summary.md` status: APPROVED. (MEDIUM/LOW/outdated may be present as advisory.)
|
|
133
|
+
- **REJECTED** — ≥1 SECRET (always), or ≥1 COMPROMISED/CRITICAL/HIGH without explicit ADR or remediation in flight. Verdict file status: REJECTED.
|
|
134
|
+
|
|
135
|
+
**Rigoroso threshold:** SECRET and COMPROMISED always block. CRITICAL/HIGH (CVE or reachable SAST) block unless an ADR justifies acceptance. MEDIUM/LOW and outdated are advisory. A SECRET is the one tier with **no ADR escape** — rotate, don't justify.
|
|
99
136
|
|
|
100
137
|
**`/dw-review` and `/dw-generate-pr` enforce:** if the project's language is supported AND the most recent `.dw/secure-audit/audit-summary.md` is missing OR REJECTED, those commands themselves return REJECTED. No exception. No bypass flag.
|
|
101
138
|
|
|
102
139
|
## Mode 1: Default (`/dw-secure-audit`)
|
|
103
140
|
|
|
104
141
|
1. **Detect stack**: check for package.json / requirements.txt / *.csproj / Cargo.toml.
|
|
105
|
-
2. **Run all
|
|
106
|
-
- OWASP static (via `security-review` skill).
|
|
142
|
+
2. **Run all detection layers in parallel** (where possible):
|
|
143
|
+
- OWASP static (via `security-review` skill) — diff-focused.
|
|
144
|
+
- SAST — Semgrep on the diff (`--baseline-commit`).
|
|
145
|
+
- Dedicated secret scan — gitleaks on the diff.
|
|
107
146
|
- Trivy + lockfile audit.
|
|
108
147
|
- Supply-chain compromise check.
|
|
109
148
|
3. **Run outdated check.**
|
|
149
|
+
**fp-check:** before finalizing, run reachability validation on each blocking SAST/OWASP finding
|
|
150
|
+
(see `security-review` SKILL.md); downgrade provably-unreachable ones to advisory with a logged reason.
|
|
151
|
+
Secrets are exempt from downgrade.
|
|
110
152
|
4. **Aggregate findings** per classification tier.
|
|
111
153
|
5. **Write summary** at `.dw/secure-audit/audit-summary.md`:
|
|
112
154
|
|
|
@@ -118,14 +160,26 @@ The verdict is one of:
|
|
|
118
160
|
## Tier Summary
|
|
119
161
|
| Tier | Count | Detail |
|
|
120
162
|
|------|-------|--------|
|
|
163
|
+
| SECRET | N | <list> |
|
|
121
164
|
| COMPROMISED | N | <list> |
|
|
122
165
|
| CRITICAL | N | <list> |
|
|
123
166
|
| HIGH | N | <list> |
|
|
167
|
+
| MEDIUM/LOW (advisory) | N | <list> |
|
|
124
168
|
| OUTDATED-MAJOR | N | <list> |
|
|
125
169
|
| OUTDATED-MINOR | N | <list> |
|
|
126
170
|
|
|
171
|
+
## Scanners
|
|
172
|
+
| Layer | Tool | Status |
|
|
173
|
+
|-------|------|--------|
|
|
174
|
+
| OWASP | security-review | run |
|
|
175
|
+
| SAST | semgrep | run / skipped (not installed) |
|
|
176
|
+
| Secrets | gitleaks | run / fallback to trivy (not installed) |
|
|
177
|
+
| SCA/IaC | trivy | run |
|
|
178
|
+
|
|
127
179
|
## Layer reports
|
|
128
180
|
- OWASP findings: `owasp-findings.md`
|
|
181
|
+
- SAST findings: `sast-findings.md`
|
|
182
|
+
- Secret findings: `secret-findings.md`
|
|
129
183
|
- Trivy findings: `trivy-findings.md`
|
|
130
184
|
- Lockfile findings: `lockfile-findings.md`
|
|
131
185
|
- Compromise findings: `compromise-findings.md`
|
|
@@ -164,7 +218,7 @@ For each user-approved remediation:
|
|
|
164
218
|
## Mode 4: CI mode (`/dw-secure-audit --scan-only`)
|
|
165
219
|
|
|
166
220
|
Minimal output:
|
|
167
|
-
- Runs all
|
|
221
|
+
- Runs all detection layers.
|
|
168
222
|
- Writes findings to disk.
|
|
169
223
|
- Exits with code 0 if APPROVED, 1 if REJECTED.
|
|
170
224
|
- No remediation planning.
|
|
@@ -182,8 +236,9 @@ For pre-merge CI gates.
|
|
|
182
236
|
## Constitution Gate
|
|
183
237
|
|
|
184
238
|
<critical>
|
|
185
|
-
- A
|
|
186
|
-
-
|
|
239
|
+
- A SECRET finding → verdict cannot be APPROVED, EVER (no ADR escape). Rotate and remove.
|
|
240
|
+
- A CRITICAL/HIGH/COMPROMISED finding (CVE or reachable SAST) without an ADR justifying explicit acceptance → verdict cannot be APPROVED.
|
|
241
|
+
- Constitution principle violations (security principles like P-009 server-side auth, P-010 secrets-in-repo, P-011 no high-severity SAST) escalate findings — a `severity: info` principle violation surfaced here becomes a HIGH classification.
|
|
187
242
|
</critical>
|
|
188
243
|
|
|
189
244
|
## Anti-patterns
|
|
@@ -198,8 +253,10 @@ For pre-merge CI gates.
|
|
|
198
253
|
|
|
199
254
|
```
|
|
200
255
|
.dw/secure-audit/
|
|
201
|
-
├── audit-summary.md # verdict + tier summary
|
|
256
|
+
├── audit-summary.md # verdict + tier summary + scanner status
|
|
202
257
|
├── owasp-findings.md # Layer 1
|
|
258
|
+
├── sast-findings.md # Layer 4 (Semgrep)
|
|
259
|
+
├── secret-findings.md # Layer 5 (gitleaks, redacted)
|
|
203
260
|
├── trivy-findings.md # Layer 2 (SCA + secrets + IaC)
|
|
204
261
|
├── lockfile-findings.md # Layer 2 (native auditor)
|
|
205
262
|
├── compromise-findings.md # Layer 3
|
|
@@ -80,12 +80,17 @@ mode: defaults | custom
|
|
|
80
80
|
**P-009 — Server-side authorization on every state-changing endpoint** (severity: info)
|
|
81
81
|
**Rule:** Any endpoint that creates, updates, or deletes data must verify caller authorization on the server. UI-level gating (hidden buttons, disabled forms) is not security.
|
|
82
82
|
**Why:** Browsers are untrusted (see `dw-testing-discipline/references/security-boundary.md`). UI gating is convenience; only server checks protect data.
|
|
83
|
-
**Enforcement:** `dw-
|
|
83
|
+
**Enforcement:** `dw-review` and the `dw-secure-audit` Security Gate require an explicit auth check (decorator, middleware, or in-handler assertion) on POST/PUT/PATCH/DELETE routes.
|
|
84
84
|
|
|
85
|
-
**P-010 — Secrets never enter the repository** (severity:
|
|
85
|
+
**P-010 — Secrets never enter the repository** (severity: high)
|
|
86
86
|
**Rule:** No API keys, passwords, signing keys, tokens, or production endpoints checked into source. `.env.example` documents shape only.
|
|
87
87
|
**Why:** Repository history is permanent. A secret committed once is leaked even if reverted next commit.
|
|
88
|
-
**Enforcement:** `dw-
|
|
88
|
+
**Enforcement:** the `dw-secure-audit` Security Gate runs gitleaks + Trivy secret scanners on the diff. Any hit blocks — with **no ADR exception** (rotate, don't justify).
|
|
89
|
+
|
|
90
|
+
**P-011 — No high-severity SAST finding ships unreviewed** (severity: high)
|
|
91
|
+
**Rule:** Generated/changed code must pass the SAST layer (Semgrep) of the Security Gate. A reachable high-severity finding (SQLi, command/code injection, SSRF, insecure deserialization, authn bypass) blocks unless an ADR justifies acceptance.
|
|
92
|
+
**Why:** AI-generated code reproduces insecure patterns at scale; deterministic SAST on the diff catches what review by reading misses.
|
|
93
|
+
**Enforcement:** `dw-secure-audit` runs Semgrep on the diff (`--baseline-commit`); findings survive an fp-check reachability validation before blocking.
|
|
89
94
|
|
|
90
95
|
---
|
|
91
96
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Functional-doc flow module. Driven by .dw/scripts/functional-doc/run-playwright-flow.mjs
|
|
2
|
+
// through the Playwright Node API, so video is captured with page.screencast (works both
|
|
3
|
+
// for a launched browser and over connectOverCDP). No imports are needed here — the runner
|
|
4
|
+
// injects page, context, expect, baseURL and the step()/shot() helpers.
|
|
5
|
+
|
|
6
|
+
export default async function flow({ page, expect, baseURL, step, shot }) {
|
|
7
|
+
await step("Open target route", async () => {
|
|
8
|
+
await page.goto(`${baseURL}{{routePath}}`);
|
|
9
|
+
await expect(page).toHaveURL(new RegExp("{{routeRegex}}"));
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
{{testSteps}}
|
|
13
|
+
|
|
14
|
+
await step("Record final context", async () => {
|
|
15
|
+
await expect(page.locator("body")).toBeVisible();
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -767,6 +767,27 @@ Se após as heurísticas nada cruzar a barra (codebase pequeno, churn baixo, sem
|
|
|
767
767
|
|
|
768
768
|
**Cadência de refresh:** usuários re-rodam `/dw-analyze-project` quando rules ficam desatualizadas. O Passo 9 atualiza seções auto mantendo entradas preservadas. Não existe comando separado só de refresh.
|
|
769
769
|
|
|
770
|
+
### Passo 10: Autoridade de design (DESIGN.md) — só projetos frontend
|
|
771
|
+
|
|
772
|
+
Rode quando um frontend for detectado (React/Vue/Angular/Svelte/Tailwind/CSS), para que a grounding
|
|
773
|
+
question 1 do `dw-ui-discipline` ("de onde vêm as decisões de design?") tenha uma autoridade do projeto
|
|
774
|
+
para seguir. Isso fecha o loop que hoje a grounding apenas *lê*.
|
|
775
|
+
|
|
776
|
+
1. **Cheque uma autoridade existente primeiro.** Se `DESIGN.md`, `BRAND.md` ou `STYLE_GUIDE.md` já existe
|
|
777
|
+
na raiz do projeto (ou do módulo frontend), NÃO sobrescreva — registre a localização e pare.
|
|
778
|
+
2. **Detecte design tokens** em ordem de prioridade: `theme`/`@theme` do Tailwind (cores, fontFamily,
|
|
779
|
+
spacing, radius), CSS custom properties em `globals.css`/`theme.css`/`tokens.css`, theme exports de
|
|
780
|
+
MUI/Chakra, `components.json` do shadcn, theme do Storybook. Leia os valores reais — não invente.
|
|
781
|
+
3. **Se houver tokens:** sintetize `DESIGN.md` na raiz do frontend capturando o que o projeto JÁ usa —
|
|
782
|
+
paleta (com os valores hex/oklch reais e nomes dos tokens), tipografia (famílias, escala, pesos),
|
|
783
|
+
escala de spacing/radius e convenções de componente observadas. Inicie com:
|
|
784
|
+
`> Gerado por /dw-analyze-project a partir de tokens existentes em <data>. Cure antes de tratar como canon.`
|
|
785
|
+
4. **Se não houver tokens:** NÃO fabrique paleta. Recomende bootstrap a partir de
|
|
786
|
+
`dw-ui-discipline/references/curated-defaults.md` e registre essa recomendação no índice de rules.
|
|
787
|
+
5. Referencie o novo `DESIGN.md` a partir de `.dw/rules/<módulo-frontend>.md` para os comandos downstream acharem.
|
|
788
|
+
|
|
789
|
+
Este passo é aditivo e reversível; nunca edita código de componente, só documenta o que existe.
|
|
790
|
+
|
|
770
791
|
## Checklist de Qualidade
|
|
771
792
|
|
|
772
793
|
- [ ] Estrutura do repositório escaneada
|
|
@@ -797,6 +818,7 @@ Se após as heurísticas nada cruzar a barra (codebase pequeno, churn baixo, sem
|
|
|
797
818
|
- [ ] Convenções de teste documentadas (framework, padrões, cobertura)
|
|
798
819
|
- [ ] Step 8 (constitution) oferecido e resolvido (A/B/C)
|
|
799
820
|
- [ ] Step 9 (mapa de concerns) apresentou candidatos, aguardou aprovação, escreveu `.dw/rules/concerns.md` (ou anotou que não há sinais)
|
|
821
|
+
- [ ] Passo 10 (autoridade de design) rodou para projetos frontend: autoridade existente respeitada, ou `DESIGN.md` gerado a partir de tokens reais, ou bootstrap via curated-defaults recomendado
|
|
800
822
|
- [ ] Blocos com marker preserved em concerns.md mantidos verbatim no refresh
|
|
801
823
|
|
|
802
824
|
## Exemplo de Uso
|
|
@@ -152,10 +152,11 @@ Quando `autopilot-state.json status=plan_complete`, invoque formalmente:
|
|
|
152
152
|
O goal e dono desta sequencia:
|
|
153
153
|
|
|
154
154
|
1. `/dw-run <prd-path>`
|
|
155
|
-
2. `/dw-review <prd-path>` (review completo: cobertura, qualidade, convencoes,
|
|
155
|
+
2. `/dw-review <prd-path>` (review completo: cobertura, qualidade, convencoes, constitution, verify)
|
|
156
156
|
3. `/dw-qa <prd-path>`
|
|
157
157
|
4. `/dw-qa --fix <prd-path>` se QA encontrou bugs Open
|
|
158
158
|
5. `/dw-review <prd-path>` novamente apos QA/fixes
|
|
159
|
+
6. **Security Gate** — o `/dw-review` pós-QA (passo 5) aciona o `/dw-secure-audit`, produzindo um `.dw/secure-audit/audit-summary.md` fresco. Este passo **garante** que o verdict é APROVADO: se ausente/desatualizado/REPROVADO, rode `/dw-secure-audit <prd-path>` standalone, depois volte pro `/dw-bugfix` por finding e re-cheque. Findings SECRET sempre bloqueiam (sem escape de ADR). Não force um segundo scan completo quando já existe um summary APROVADO fresco.
|
|
159
160
|
|
|
160
161
|
<critical>Nao substitua os reviews do goal por `/dw-review --coverage-only`. O goal de qualidade do autopilot exige `/dw-review` completo antes do QA e depois dos fixes de QA.</critical>
|
|
161
162
|
|
|
@@ -175,6 +176,7 @@ Antes de `/dw-commit`, verifique:
|
|
|
175
176
|
- `.dw/goals/autopilot-<prd-slug>/status.json` esta completo.
|
|
176
177
|
- `<prd-path>/QA/review-consolidated.md` existe a partir do review final pos-QA.
|
|
177
178
|
- `<prd-path>/QA/qa-report.md` e `<prd-path>/QA/bugs.md` existem.
|
|
179
|
+
- **Security Gate passou:** `.dw/secure-audit/audit-summary.md` existe, esta fresco (pos-ultima-edicao) e status APROVADO. Se ausente/desatualizado/REPROVADO → PARE (nao commite).
|
|
178
180
|
- `autopilot-state.json` registra artefatos de planejamento e o goal completo.
|
|
179
181
|
|
|
180
182
|
Se algo estiver faltando, PARE e re-execute o comando formal ausente. Nao faca commit parcial.
|
|
@@ -114,7 +114,7 @@ Arquivos mínimos:
|
|
|
114
114
|
- `case-matrix.md`
|
|
115
115
|
- `e2e-runbook.md`
|
|
116
116
|
- `manifest.json`
|
|
117
|
-
- `scripts/*.
|
|
117
|
+
- `scripts/*.flow.mjs`
|
|
118
118
|
- `captions/*.srt`
|
|
119
119
|
|
|
120
120
|
Se houver execução:
|
|
@@ -291,8 +291,16 @@ Se já existir no workspace um script de shell funcional (ex: `record-human-tour
|
|
|
291
291
|
## Scripts utilitários
|
|
292
292
|
|
|
293
293
|
Use os utilitários do workspace quando fizer sentido:
|
|
294
|
-
- `node .dw/scripts/
|
|
295
|
-
- `node .dw/scripts/
|
|
294
|
+
- `node .dw/scripts/functional-doc/generate-dossier.mjs --target <URL> [--lang en|pt-br] [--project <nome>] [--base-url <url>]`
|
|
295
|
+
- `node .dw/scripts/functional-doc/run-playwright-flow.mjs --flow-dir <caminho> [--video-resolution fullhd|1920x1080] [--list-only]`
|
|
296
|
+
|
|
297
|
+
O runner dirige o Playwright pela API Node e grava vídeo com `page.screencast` (único mecanismo que
|
|
298
|
+
funciona via CDP). Ele gera `scripts/<slug>.flow.mjs` — um módulo ESM simples que exporta
|
|
299
|
+
`async function flow({ page, context, expect, baseURL, step, shot })`, não um spec `@playwright/test`,
|
|
300
|
+
então dispensa o `playwright.config.*` do projeto. O browser é escolhido por `.dw/scripts/lib/resolve-browser.mjs`
|
|
301
|
+
(resiliente no WSL: Chromium headless full por padrão; defina `BROWSER_TEST` com o caminho do exe do browser do Windows para dirigi-lo via CDP — em NAT rode `npx @brunosps00/dev-workflow setup-wsl-browser` uma vez para o cdp-relay.exe + regra Hyper-V, em mirrored funciona direto);
|
|
302
|
+
veja a seção "Browser on WSL" de `dw-testing-discipline/references/playwright-recipes.md`. Só Chromium —
|
|
303
|
+
`screencast`/CDP não suportam Firefox/WebKit.
|
|
296
304
|
|
|
297
305
|
## Critérios de completude
|
|
298
306
|
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
|-------|---------|
|
|
16
16
|
| `dw-verify` | **SEMPRE** — invocada antes do `git push`. Sem VERIFICATION REPORT PASS na sessão após a última edição de código, o PR **NÃO** pode ser criado. |
|
|
17
17
|
| `dw-git-discipline` | **SEMPRE** — valida naming de branch (`<tipo>/<escopo>` kebab-case), histórico atomic-commit (cada commit single-intent, mensagem conventional), tempo de vida da branch (flag se >7 dias) e escopo da PR (sugere split se diff > ~400 linhas). Descrição da PR segue summary + test plan, não dump de `git log`. |
|
|
18
|
-
| `/dw-secure-audit` | **SEMPRE para projetos TS/Python/C#/Rust** —
|
|
18
|
+
| `/dw-secure-audit` | **SEMPRE para projetos TS/Python/C#/Rust** — um `.dw/secure-audit/audit-summary.md` fresco com status ≠ REJECTED é obrigatório para projetos em linguagem suportada. |
|
|
19
19
|
|
|
20
20
|
<critical>Hard gate 1 (verify): se a sessão atual não tem um VERIFICATION REPORT PASS de `dw-verify` produzido APÓS a última edição/commit, PARAR e invocar `dw-verify` antes de prosseguir. PR é um artefato permanente — exige o maior rigor de verificação.</critical>
|
|
21
21
|
|
|
22
|
-
<critical>Hard gate 2 (security): para projetos TS/Python/C#/Rust, se
|
|
22
|
+
<critical>Hard gate 2 (security): para projetos TS/Python/C#/Rust, se `.dw/secure-audit/audit-summary.md` não existir, estiver desatualizado (anterior à última edição) OU tiver status REJECTED, PARAR e invocar `/dw-secure-audit` antes de prosseguir. Findings SECRET e vulnerabilidades HIGH/CRITICAL NÃO podem chegar ao PR. Para outras linguagens (Go, Java, etc.), este gate é pulado com nota.</critical>
|
|
23
23
|
|
|
24
24
|
## Uso
|
|
25
25
|
|
|
@@ -83,7 +83,7 @@ Quando disponíveis em `./.agents/skills/`, invocadas operacionalmente:
|
|
|
83
83
|
|
|
84
84
|
1. **Pre-flight**: confirmar que dev server do projeto pode rodar. Confirmar `.dw/spec/<prd>/` tem PRD + TechSpec + tasks.
|
|
85
85
|
2. **Mapear FRs para test plan**: pra cada FR, identificar fluxo user-facing que exercita.
|
|
86
|
-
3. **Dirigir Playwright MCP** (ou
|
|
86
|
+
3. **Dirigir Playwright MCP** (se indisponível ou bloqueado — comum no WSL — use o fallback local resiliente `node .dw/scripts/lib/capture-screenshots.mjs`, que escolhe o browser via `.dw/scripts/lib/resolve-browser.mjs`; veja a seção "Browser on WSL" de `dw-testing-discipline/references/playwright-recipes.md`):
|
|
87
87
|
- Happy paths pra cada FR.
|
|
88
88
|
- Edge cases (boundary inputs, falha de rede, erros de validação).
|
|
89
89
|
- Fluxos negativos (ações não autorizadas, input malformado).
|
|
@@ -56,12 +56,12 @@ Utilize ferramentas de diagnóstico conforme o framework do projeto:
|
|
|
56
56
|
## Comportamento Obrigatório
|
|
57
57
|
|
|
58
58
|
1. Identifique o alvo: página, componente ou rota que será redesenhada.
|
|
59
|
-
2. **AUDITAR**: leia a implementação atual, identifique stack CSS (Tailwind, CSS Modules, styled-components, etc.), capture screenshot
|
|
59
|
+
2. **AUDITAR**: leia a implementação atual, identifique stack CSS (Tailwind, CSS Modules, styled-components, etc.), capture o screenshot do estado-antes (Playwright MCP, ou `node .dw/scripts/lib/capture-screenshots.mjs` como fallback resiliente no WSL), rode react-doctor se projeto React.
|
|
60
60
|
3. Faça 3 a 5 perguntas sobre objetivos do redesign: direção de estilo, constraints de marca, inspirações, público-alvo, dispositivos prioritários.
|
|
61
61
|
4. **PROPOR**: apresente 2 a 3 direções de design depois de passar pelo hard-gate de `dw-ui-discipline` (brand authorities ou curated defaults; surface job sentence; state matrix enumerada; scene sentence). Cada direção lista paleta de cores, par tipográfico, estilo de layout e racional. Self-check de cada direção contra os 14 anti-slop patterns. Para CADA direção, descreva explicitamente o layout mobile (<=768px) e o layout desktop (>=1024px), incluindo como os elementos se reorganizam, empilham ou escondem entre breakpoints.
|
|
62
62
|
5. Espere aprovação explícita do usuário antes de implementar.
|
|
63
63
|
6. **IMPLEMENTAR**: aplique o design escolhido com abordagem mobile-first — implemente primeiro o layout mobile e depois adicione media queries/breakpoints para tablet e desktop. Respeite a stack existente. Use `vercel-react-best-practices` para React/Next.js. Mantenha a metodologia CSS do projeto.
|
|
64
|
-
7. **VALIDAR**: capture estado depois em AMBAS as resoluções (mobile e desktop), compare antes/depois, verifique acessibilidade contra `dw-ui-discipline/references/accessibility-floor.md` (WCAG 2.2 AA — não-negociável: contraste, focus-visible, keyboard nav, ARIA, sem traps), rode react-doctor `--diff` se React.
|
|
64
|
+
7. **VALIDAR**: capture estado depois em AMBAS as resoluções (mobile e desktop), compare antes/depois, verifique acessibilidade contra `dw-ui-discipline/references/accessibility-floor.md` (WCAG 2.2 AA — não-negociável: contraste, focus-visible, keyboard nav, ARIA, sem traps), rode react-doctor `--diff` se React. Capture screenshots em 375px (mobile) e 1440px (desktop) — `node .dw/scripts/lib/capture-screenshots.mjs --url <url> --widths 375,1440` é o caminho resiliente no WSL; veja a seção "Browser on WSL" de `dw-testing-discipline/references/playwright-recipes.md`.
|
|
65
65
|
8. **PERSISTIR CONTRATO**: se o usuário aprovou uma direção, gere `design-contract.md` no diretório do PRD (`.dw/spec/prd-[nome]/design-contract.md`) com: direção aprovada, paleta de cores, par tipográfico, regras de layout, regras de acessibilidade e regras de componentes. Este contrato será lido por `dw-run-task` e `dw-run-plan` para garantir consistência visual.
|
|
66
66
|
|
|
67
67
|
## Inteligência do Codebase
|
|
@@ -44,9 +44,10 @@ Quando disponíveis em `./.agents/skills/`, são invocadas como apoio analítico
|
|
|
44
44
|
|
|
45
45
|
- `dw-review-rigor`: **SEMPRE** — aplica de-duplication (mesmo pattern em N arquivos = 1 finding), severity ordering (critical → high → medium → low), verify-before-flag, skip-what-linter-catches, signal-over-volume. A tabela "Problemas Encontrados" segue essa disciplina.
|
|
46
46
|
- `dw-verify`: **SEMPRE** — invocada antes de emitir `APROVADO` ou `APROVADO COM RESSALVAS`. Sem VERIFICATION REPORT PASS (test + lint + build), verdict não pode ser APROVADO.
|
|
47
|
-
- `dw-secure-audit
|
|
47
|
+
- `dw-secure-audit` (**Security Gate**): **SEMPRE para projetos TS/Python/C#/Rust** — acionado aqui e o verdict é enforced. Se a linguagem é suportada e `.dw/secure-audit/audit-summary.md` fresco está ausente OU REPROVADO, o verdict do review é **REPROVADO** — sem exceção. O mesmo gate também é comando standalone (`/dw-secure-audit`) e fase explícita no `/dw-autopilot`. Agora soma Semgrep SAST (diff) + gitleaks secrets sobre OWASP/Trivy/SCA.
|
|
48
|
+
- `security-review`: a skill OWASP nível-diff que o gate usa (injection, authz, secrets, SSRF, crypto — só HIGH CONFIDENCE).
|
|
48
49
|
- `dw-simplification`: use quando diff toca código denso — aplica Chesterton's Fence, protocolo de refactor preservando comportamento, métricas de complexidade.
|
|
49
|
-
- `dw-ui-discipline`: use quando diff toca UI — roda os 14 visual-slop patterns + accessibility floor.
|
|
50
|
+
- `dw-ui-discipline`: use quando diff toca UI — roda os 14 visual-slop patterns + accessibility floor. Para um gate determinístico, rode também `node .dw/scripts/lib/ui-slop-detect.mjs <paths-ui-alterados> --fail-on error` (wrapper sobre o detector do impeccable); trate findings bloqueantes como **REJECTED** e reporte os warnings.
|
|
50
51
|
- `dw-testing-discipline`: use quando diff toca testes — aplica catálogo de 25 anti-patterns + 6 agent guardrails (quando testes foram agent-authored).
|
|
51
52
|
- `dw-llm-eval`: **OBRIGATÓRIO quando diff toca código de feature AI/LLM**. Reference dataset + ≥2 oracle rungs + judge calibration (se rung 4 usado) + eval run results DEVEM estar no PR. Faltando → REPROVADO.
|
|
52
53
|
- `security-review`: use quando diff toca auth, autorização, input externo, upload, SQL, secrets, SSRF, XSS ou superfícies sensíveis.
|
|
@@ -161,9 +162,10 @@ Se FALTANDO > 0, o veredicto sugere revisitar `/dw-plan tasks` pra escopar ou `/
|
|
|
161
162
|
- Rodar dw-verify pra produzir VERIFICATION REPORT (test + lint + build GREEN).
|
|
162
163
|
- Sem PASS, verdict não pode ser APROVADO.
|
|
163
164
|
|
|
164
|
-
8. **Security
|
|
165
|
-
-
|
|
166
|
-
- Se linguagem suportada e audit
|
|
165
|
+
8. **Security Gate (`dw-secure-audit` para TS/Python/C#/Rust):**
|
|
166
|
+
- Acione `/dw-secure-audit` contra o diff (OWASP + Semgrep SAST + gitleaks + Trivy/SCA + supply-chain). Ele produz/atualiza `.dw/secure-audit/audit-summary.md`.
|
|
167
|
+
- Scan mais recente deve estar presente, fresco (pós-última-edição) e não REPROVADO. Se linguagem suportada e audit ausente OU REPROVADO → verdict do review **REPROVADO**. Findings SECRET sempre bloqueiam (sem escape de ADR).
|
|
168
|
+
- O mesmo gate também roda standalone (`/dw-secure-audit`) e é fase explícita no `/dw-autopilot`; `/dw-generate-pr` re-enforça o verdict antes do PR.
|
|
167
169
|
|
|
168
170
|
### Output
|
|
169
171
|
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
<system_instructions>
|
|
2
|
-
Você é o orquestrador de security audit
|
|
2
|
+
Você é o orquestrador de security audit — o **Security Gate**. Roda OWASP static review + SAST (Semgrep,
|
|
3
|
+
focado no diff do código gerado) + secret scan dedicado (gitleaks) + supply-chain CVE/secret/IaC (Trivy +
|
|
4
|
+
native lockfile audit) + supply-chain compromise detection + outdated check, em uma passada. Hard-gates
|
|
5
|
+
comandos downstream quando há qualquer finding bloqueante.
|
|
3
6
|
|
|
4
|
-
|
|
7
|
+
É **auto-invocado por `/dw-review` e `/dw-generate-pr`** (em TS/Python/C#/Rust), roda como **fase explícita e
|
|
8
|
+
nomeada no `/dw-autopilot`** (após review + QA, antes de commit/PR), e é **executável standalone** a qualquer
|
|
9
|
+
momento. O `/dw-generate-pr` re-enforça o verdict como hard gate final. Os três continuam gating em segurança
|
|
10
|
+
— o comando standalone e a fase nomeada são aditivos, não substituem.
|
|
5
11
|
|
|
6
12
|
## Quando Usar
|
|
7
13
|
- Auto-invocado: `/dw-review` e `/dw-generate-pr` em linguagens suportadas.
|
|
@@ -10,7 +16,7 @@ Auto-invocado por `/dw-review` e `/dw-generate-pr` em projetos TS/Python/C#/Rust
|
|
|
10
16
|
- NÃO use como substituto pra review humano em código auth/payment de alto risco (use skill `security-review` JUNTO com este).
|
|
11
17
|
|
|
12
18
|
## Posição no Pipeline
|
|
13
|
-
**Antecessor:**
|
|
19
|
+
**Antecessor:** `/dw-review` + `/dw-qa` (o Security Gate roda depois deles passarem) | **Sucessor:** `/dw-commit` / `/dw-generate-pr` se APROVADO, ou `/dw-bugfix` pra atacar findings. Também roda standalone a qualquer momento.
|
|
14
20
|
|
|
15
21
|
## Modos
|
|
16
22
|
|
|
@@ -33,10 +39,20 @@ Auto-invocado por `/dw-review` e `/dw-generate-pr` em projetos TS/Python/C#/Rust
|
|
|
33
39
|
|
|
34
40
|
## Dependências Necessárias
|
|
35
41
|
|
|
36
|
-
- **Trivy** —
|
|
42
|
+
- **Trivy** — SCA / secrets / IaC (via `npx @brunosps00/dev-workflow install-deps`).
|
|
43
|
+
- **Semgrep** — camada SAST (opcional mas recomendado). Se ausente, a camada SAST é pulada e anotada.
|
|
44
|
+
- **gitleaks** — secret scan dedicado (opcional mas recomendado). Se ausente, cai pro Trivy secrets.
|
|
37
45
|
- **Context7 MCP** — pra best practices específicas de versão.
|
|
38
46
|
|
|
39
|
-
|
|
47
|
+
Todos os scanners são opcionais individualmente: uma tool ausente degrada aquela camada e é **reportada**
|
|
48
|
+
no summary (o gate nunca quebra por falta de scanner), mas a cobertura faltante fica visível. Instale via
|
|
49
|
+
`npx @brunosps00/dev-workflow install-deps`.
|
|
50
|
+
|
|
51
|
+
## Camadas de Detecção
|
|
52
|
+
|
|
53
|
+
**Foco no diff (código gerado):** camadas que suportam isso focam no diff contra a base do PR
|
|
54
|
+
(`git merge-base HEAD origin/main`), concentrando o gate no código recém-escrito, sem ruído do código
|
|
55
|
+
pré-existente. Um pass periódico `--full` varre a árvore inteira.
|
|
40
56
|
|
|
41
57
|
### Camada 1: OWASP Static Review (via skill `security-review`)
|
|
42
58
|
|
|
@@ -72,6 +88,23 @@ Cruza dependency tree contra:
|
|
|
72
88
|
|
|
73
89
|
Output: `.dw/secure-audit/compromise-findings.md` por pacote afetado: COMPROMISED / suspicious / clean.
|
|
74
90
|
|
|
91
|
+
### Camada 4: SAST — Semgrep (análise semântica do código gerado)
|
|
92
|
+
|
|
93
|
+
Análise estática semântica e determinística do **diff** (`--baseline-commit`), complementando a Camada 1.
|
|
94
|
+
Rulesets fixados: `p/security-audit`, `p/owasp-top-ten`, `p/secrets` (+ packs de linguagem detectados).
|
|
95
|
+
Mapeie Semgrep `ERROR`→HIGH (ou CRITICAL pra CWEs RCE/authn-bypass/SQLi), `WARNING`→MEDIUM, `INFO`→LOW.
|
|
96
|
+
Aplique a disciplina **fp-check** (reachability) antes de um finding bloquear (ver `security-review/references/sast.md`).
|
|
97
|
+
|
|
98
|
+
Output: `.dw/secure-audit/sast-findings.md`. Se `semgrep` ausente: pulado + anotado no summary.
|
|
99
|
+
|
|
100
|
+
### Camada 5: Secret scan dedicado — gitleaks
|
|
101
|
+
|
|
102
|
+
`gitleaks protect --staged` (não-commitado) ou `gitleaks detect --log-opts <base>..HEAD` (branch), `--redact`.
|
|
103
|
+
Autoritativo no diff; complementa Trivy secrets (dedupe por `file:line`). **Qualquer hit = REPROVADO, sem
|
|
104
|
+
exceção de ADR** — secrets são removidos e rotacionados, não justificados. Ver `security-review/references/secrets.md`.
|
|
105
|
+
|
|
106
|
+
Output: `.dw/secure-audit/secret-findings.md`. Se `gitleaks` ausente: cai pro Trivy secrets + anotado.
|
|
107
|
+
|
|
75
108
|
### Plus: outdated check
|
|
76
109
|
|
|
77
110
|
`npm outdated` / `pip list --outdated` / `dotnet list outdated` / `cargo outdated` pra identificar pacotes atrás em minor ou major.
|
|
@@ -84,9 +117,11 @@ Todos os findings são classificados num desses tiers em `.dw/secure-audit/audit
|
|
|
84
117
|
|
|
85
118
|
| Tier | Critério | Bloqueia | Ação Sugerida |
|
|
86
119
|
|------|----------|----------|---------------|
|
|
120
|
+
| **SECRET** | Credencial/chave/token hardcoded (gitleaks ou Trivy), sobrevive ao allowlist | SIM — **sem exceção de ADR** | Remover do código + histórico, rotacionar, mover pra secret store |
|
|
87
121
|
| **COMPROMISED** | Pacote conhecido como malicioso nessa faixa de versão | SIM | Remover imediato / pin pra versão segura |
|
|
88
|
-
| **CRITICAL** | CVE CVSS ≥9.0 OU exploit ativo OU auth bypass | SIM | Update ou
|
|
89
|
-
| **HIGH** | CVE CVSS 7.0–8.9 OU exploitável no contexto
|
|
122
|
+
| **CRITICAL** | CVE CVSS ≥9.0 OU exploit ativo OU auth bypass; OU SAST de CWE alto-impacto (SQLi/RCE/authn-bypass/SSRF/deserialization) alcançável | SIM | Update/substituir ou corrigir em 24h |
|
|
123
|
+
| **HIGH** | CVE CVSS 7.0–8.9 OU exploitável no contexto; OU Semgrep `ERROR` alcançável (fp-check passou) | SIM | Update/substituir ou corrigir em 1 semana |
|
|
124
|
+
| **MEDIUM / LOW** | CVE CVSS <7.0; OU Semgrep `WARNING`/`INFO`; OU finding inalcançável rebaixado pelo fp-check | NÃO (advisory) | Rastrear e corrigir rotineiramente |
|
|
90
125
|
| **OUTDATED-MAJOR** | ≥1 major version atrás (ex: React 17 → 19) | NÃO | Planejar migração próximo trimestre |
|
|
91
126
|
| **OUTDATED-MINOR** | Minor/patch atrás | NÃO | Update rotineiro |
|
|
92
127
|
| **CLEAN** | Sem findings | NÃO | — |
|
|
@@ -94,19 +129,26 @@ Todos os findings são classificados num desses tiers em `.dw/secure-audit/audit
|
|
|
94
129
|
## Hard Gates
|
|
95
130
|
|
|
96
131
|
Verdict é um de:
|
|
97
|
-
- **APROVADO** — sem
|
|
98
|
-
- **REPROVADO** — ≥1
|
|
132
|
+
- **APROVADO** — sem SECRET, COMPROMISED, CRITICAL ou HIGH. Arquivo verdict `.dw/secure-audit/audit-summary.md` status: APROVADO. (MEDIUM/LOW/outdated podem aparecer como advisory.)
|
|
133
|
+
- **REPROVADO** — ≥1 SECRET (sempre), ou ≥1 COMPROMISED/CRITICAL/HIGH sem ADR explícito ou remediação em andamento. Status: REPROVADO.
|
|
134
|
+
|
|
135
|
+
**Limiar Rigoroso:** SECRET e COMPROMISED sempre bloqueiam. CRITICAL/HIGH (CVE ou SAST alcançável) bloqueiam salvo ADR justificando aceitação. MEDIUM/LOW e outdated são advisory. SECRET é o único tier **sem escape via ADR** — rotacione, não justifique.
|
|
99
136
|
|
|
100
137
|
**`/dw-review` e `/dw-generate-pr` enforçam:** se linguagem do projeto é suportada E `.dw/secure-audit/audit-summary.md` mais recente está faltando OU REPROVADO, esses comandos retornam REPROVADO. Sem exceção. Sem flag bypass.
|
|
101
138
|
|
|
102
139
|
## Modo 1: Default (`/dw-secure-audit`)
|
|
103
140
|
|
|
104
141
|
1. **Detectar stack**: checar package.json / requirements.txt / *.csproj / Cargo.toml.
|
|
105
|
-
2. **Rodar todas as
|
|
106
|
-
- OWASP static (via skill `security-review`).
|
|
142
|
+
2. **Rodar todas as camadas de detecção em paralelo** (onde possível):
|
|
143
|
+
- OWASP static (via skill `security-review`) — focado no diff.
|
|
144
|
+
- SAST — Semgrep no diff (`--baseline-commit`).
|
|
145
|
+
- Secret scan dedicado — gitleaks no diff.
|
|
107
146
|
- Trivy + lockfile audit.
|
|
108
147
|
- Supply-chain compromise check.
|
|
109
148
|
3. **Rodar outdated check.**
|
|
149
|
+
**fp-check:** antes de finalizar, rode validação de reachability em cada finding SAST/OWASP bloqueante
|
|
150
|
+
(ver `security-review` SKILL.md); rebaixe os comprovadamente inalcançáveis pra advisory com razão logada.
|
|
151
|
+
Secrets são isentos de rebaixamento.
|
|
110
152
|
4. **Agregar findings** por tier.
|
|
111
153
|
5. **Escrever summary** em `.dw/secure-audit/audit-summary.md`:
|
|
112
154
|
|
|
@@ -118,14 +160,26 @@ Verdict é um de:
|
|
|
118
160
|
## Resumo por Tier
|
|
119
161
|
| Tier | Contagem | Detalhe |
|
|
120
162
|
|------|----------|---------|
|
|
163
|
+
| SECRET | N | <lista> |
|
|
121
164
|
| COMPROMISED | N | <lista> |
|
|
122
165
|
| CRITICAL | N | <lista> |
|
|
123
166
|
| HIGH | N | <lista> |
|
|
167
|
+
| MEDIUM/LOW (advisory) | N | <lista> |
|
|
124
168
|
| OUTDATED-MAJOR | N | <lista> |
|
|
125
169
|
| OUTDATED-MINOR | N | <lista> |
|
|
126
170
|
|
|
171
|
+
## Scanners
|
|
172
|
+
| Camada | Tool | Status |
|
|
173
|
+
|--------|------|--------|
|
|
174
|
+
| OWASP | security-review | rodou |
|
|
175
|
+
| SAST | semgrep | rodou / pulado (não instalado) |
|
|
176
|
+
| Secrets | gitleaks | rodou / fallback trivy (não instalado) |
|
|
177
|
+
| SCA/IaC | trivy | rodou |
|
|
178
|
+
|
|
127
179
|
## Relatórios das camadas
|
|
128
180
|
- OWASP: `owasp-findings.md`
|
|
181
|
+
- SAST: `sast-findings.md`
|
|
182
|
+
- Secrets: `secret-findings.md`
|
|
129
183
|
- Trivy: `trivy-findings.md`
|
|
130
184
|
- Lockfile: `lockfile-findings.md`
|
|
131
185
|
- Compromise: `compromise-findings.md`
|
|
@@ -164,7 +218,7 @@ Pra cada remediação aprovada:
|
|
|
164
218
|
## Modo 4: CI (`/dw-secure-audit --scan-only`)
|
|
165
219
|
|
|
166
220
|
Output mínimo:
|
|
167
|
-
- Roda todas as
|
|
221
|
+
- Roda todas as camadas de detecção.
|
|
168
222
|
- Escreve findings em disco.
|
|
169
223
|
- Exit code 0 se APROVADO, 1 se REPROVADO.
|
|
170
224
|
- Sem planejamento.
|
|
@@ -182,8 +236,9 @@ Pra gates pre-merge em CI.
|
|
|
182
236
|
## Constitution Gate
|
|
183
237
|
|
|
184
238
|
<critical>
|
|
185
|
-
-
|
|
186
|
-
-
|
|
239
|
+
- Finding SECRET → verdict NUNCA pode ser APROVADO (sem escape via ADR). Rotacione e remova.
|
|
240
|
+
- Finding CRITICAL/HIGH/COMPROMISED (CVE ou SAST alcançável) sem ADR justificando aceitação explícita → verdict não pode ser APROVADO.
|
|
241
|
+
- Violações de princípios de constitution security-related (P-009 server-side auth, P-010 secrets-in-repo, P-011 sem SAST high-severity) escalonam findings — violação de princípio `severity: info` surface aqui vira HIGH.
|
|
187
242
|
</critical>
|
|
188
243
|
|
|
189
244
|
## Anti-patterns
|
|
@@ -198,8 +253,10 @@ Pra gates pre-merge em CI.
|
|
|
198
253
|
|
|
199
254
|
```
|
|
200
255
|
.dw/secure-audit/
|
|
201
|
-
├── audit-summary.md # verdict + resumo de tiers
|
|
256
|
+
├── audit-summary.md # verdict + resumo de tiers + status dos scanners
|
|
202
257
|
├── owasp-findings.md # Camada 1
|
|
258
|
+
├── sast-findings.md # Camada 4 (Semgrep)
|
|
259
|
+
├── secret-findings.md # Camada 5 (gitleaks, redacted)
|
|
203
260
|
├── trivy-findings.md # Camada 2 (SCA + secrets + IaC)
|
|
204
261
|
├── lockfile-findings.md # Camada 2 (native auditor)
|
|
205
262
|
├── compromise-findings.md # Camada 3
|
|
@@ -80,12 +80,17 @@ mode: defaults | custom
|
|
|
80
80
|
**P-009 — Authorization server-side em todo endpoint que altera estado** (severity: info)
|
|
81
81
|
**Regra:** Endpoint que cria, atualiza ou deleta dado deve verificar autorização do caller no servidor. Gating em UI (botões escondidos, formulários disabled) não é segurança.
|
|
82
82
|
**Why:** Browsers são untrusted (ver `dw-testing-discipline/references/security-boundary.md`). Gating em UI é conveniência; só checks server-side protegem dado.
|
|
83
|
-
**Enforcement:** `dw-
|
|
83
|
+
**Enforcement:** `dw-review` e o Security Gate `dw-secure-audit` exigem check de auth explícito (decorator, middleware ou assertion in-handler) em rotas POST/PUT/PATCH/DELETE.
|
|
84
84
|
|
|
85
|
-
**P-010 — Secrets nunca entram no repositório** (severity:
|
|
85
|
+
**P-010 — Secrets nunca entram no repositório** (severity: high)
|
|
86
86
|
**Regra:** Nenhuma API key, password, signing key, token ou endpoint de produção commitado em source. `.env.example` documenta forma apenas.
|
|
87
87
|
**Why:** Histórico de repositório é permanente. Um secret commitado uma vez está vazado mesmo que revertido no commit seguinte.
|
|
88
|
-
**Enforcement:** `dw-
|
|
88
|
+
**Enforcement:** o Security Gate `dw-secure-audit` roda gitleaks + Trivy no diff. Qualquer hit bloqueia — **sem exceção de ADR** (rotacione, não justifique).
|
|
89
|
+
|
|
90
|
+
**P-011 — Nenhum finding SAST high-severity passa sem revisão** (severity: high)
|
|
91
|
+
**Regra:** Código gerado/alterado deve passar na camada SAST (Semgrep) do Security Gate. Um finding high-severity alcançável (SQLi, command/code injection, SSRF, deserialization insegura, authn bypass) bloqueia salvo ADR justificando aceitação.
|
|
92
|
+
**Why:** Código gerado por IA reproduz padrões inseguros em escala; SAST determinístico no diff pega o que o review por leitura perde.
|
|
93
|
+
**Enforcement:** `dw-secure-audit` roda Semgrep no diff (`--baseline-commit`); findings sobrevivem a uma validação fp-check de reachability antes de bloquear.
|
|
89
94
|
|
|
90
95
|
---
|
|
91
96
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Módulo de fluxo do functional-doc. Executado por .dw/scripts/functional-doc/run-playwright-flow.mjs
|
|
2
|
+
// através da API Node do Playwright, para que o vídeo seja gravado com page.screencast (funciona tanto
|
|
3
|
+
// com browser lançado quanto via connectOverCDP). Não precisa de imports aqui — o runner injeta
|
|
4
|
+
// page, context, expect, baseURL e os helpers step()/shot().
|
|
5
|
+
|
|
6
|
+
export default async function flow({ page, expect, baseURL, step, shot }) {
|
|
7
|
+
await step("Abrir rota alvo", async () => {
|
|
8
|
+
await page.goto(`${baseURL}{{routePath}}`);
|
|
9
|
+
await expect(page).toHaveURL(new RegExp("{{routeRegex}}"));
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
{{testSteps}}
|
|
13
|
+
|
|
14
|
+
await step("Registrar contexto final", async () => {
|
|
15
|
+
await expect(page.locator("body")).toBeVisible();
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "cdp-relay"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
edition = "2021"
|
|
5
|
+
description = "Tiny TCP forwarder so WSL can reach a Windows browser's CDP debug port in NAT mode. Built on Windows by dev-workflow; no runtime dependency."
|
|
6
|
+
|
|
7
|
+
[[bin]]
|
|
8
|
+
name = "cdp-relay"
|
|
9
|
+
path = "src/main.rs"
|
|
10
|
+
|
|
11
|
+
[profile.release]
|
|
12
|
+
opt-level = "z"
|
|
13
|
+
lto = true
|
|
14
|
+
strip = true
|
|
15
|
+
panic = "abort"
|
|
16
|
+
codegen-units = 1
|