@brunosps00/dev-workflow 0.5.0 → 0.6.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 CHANGED
@@ -10,7 +10,7 @@ npx @brunosps00/dev-workflow init
10
10
 
11
11
  This will:
12
12
  1. Ask you to select a language (English or Portuguese)
13
- 2. Create `.dw/commands/` with 26 workflow commands
13
+ 2. Create `.dw/commands/` with 27 workflow commands
14
14
  3. Create `.dw/templates/` with document templates (PRD, TechSpec, Tasks, ADR, etc.)
15
15
  4. Create `.dw/rules/` (populated by `/dw-analyze-project`)
16
16
  5. Install bundled skills (`dw-verify`, `dw-memory`, `dw-review-rigor`, `ui-ux-pro-max`, `security-review`, etc.) to `.agents/skills/`
@@ -77,6 +77,9 @@ Performs a formal Level 3 code review before PR creation, verifying PRD complian
77
77
  #### `/dw-refactoring-analysis`
78
78
  Audits the codebase for code smells and refactoring opportunities using Martin Fowler's catalog. Detects bloaters, change preventers, dispensables, couplers, conditional complexity, and DRY violations, then maps each to a concrete refactoring technique with before/after code sketches. Includes coupling/cohesion metrics, SOLID analysis, and a prioritized action plan (P0-P3).
79
79
 
80
+ #### `/dw-security-check`
81
+ Rigid multi-layer security check for **TypeScript, Python, C#, and Rust** projects. Combines OWASP static review (language-aware, via the bundled `security-review` skill), Trivy SCA/secret/IaC scanning (`trivy fs` + `trivy config`), and native lockfile audit (`npm audit` / `pip-audit` / `dotnet list package --vulnerable` / `cargo audit`). Consults Context7 MCP for framework-version-specific best practices (Next.js, Django, ASP.NET Core, Actix/Axum/Rocket, etc.). Hard gates: any CRITICAL or HIGH finding produces REJECTED status, blocking `/dw-code-review`, `/dw-review-implementation`, and `/dw-generate-pr`. No bypass flag. Requires Trivy (install via `install-deps`).
82
+
80
83
  ### Git & PR
81
84
 
82
85
  #### `/dw-commit`
@@ -164,7 +167,7 @@ All wrappers point to `.dw/commands/` as the single source of truth.
164
167
  ```
165
168
  your-project/
166
169
  ├── .dw/
167
- │ ├── commands/ # 26 workflow command files
170
+ │ ├── commands/ # 27 workflow command files
168
171
  │ ├── templates/ # Document templates (PRD, TechSpec, etc.)
169
172
  │ ├── rules/ # Project-specific rules (run /dw-analyze-project)
170
173
  │ ├── references/ # Reference documentation
@@ -214,6 +217,7 @@ Installed via `npx @brunosps00/dev-workflow install-deps`:
214
217
  | **Context7 MCP** | Contextual documentation lookup for AI assistants | [upstash/context7-mcp](https://github.com/upstash/context7-mcp) |
215
218
  | **react-doctor** | Health score and diagnostics for React projects | [react.doctor](https://www.react.doctor/) |
216
219
  | **GSD (get-shit-done-cc)** | Optional engine: parallel execution, plan verification, codebase intelligence, cross-session persistence | [gsd-build/get-shit-done](https://github.com/gsd-build/get-shit-done) |
220
+ | **Trivy** | Native binary scanner used by `/dw-security-check` for CVE, secret, and IaC scanning. `install-deps` detects presence and prints OS-specific install instructions (brew / curl script / choco / Docker) — does not install automatically. | [aquasecurity.github.io/trivy](https://aquasecurity.github.io/trivy/) |
217
221
 
218
222
  ## Options
219
223
 
package/lib/constants.js CHANGED
@@ -25,6 +25,7 @@ const COMMANDS = {
25
25
  { name: 'dw-run-plan', description: 'Execute ALL tasks sequentially until the plan is complete' },
26
26
  { name: 'dw-run-qa', description: 'Run visual QA with browser automation, E2E tests, and accessibility' },
27
27
  { name: 'dw-run-task', description: 'Execute a single task with built-in validation and testing' },
28
+ { name: 'dw-security-check', description: 'Run a rigid multi-layer security check (OWASP static + Trivy SCA/IaC + native audit) for TS, Python, C#, or Rust projects' },
28
29
  { name: 'dw-update', description: 'Update dev-workflow to the latest version published on npm without leaving the agent session' },
29
30
  ],
30
31
  'pt-br': [
@@ -53,6 +54,7 @@ const COMMANDS = {
53
54
  { name: 'dw-run-plan', description: 'Executar TODAS as tasks sequencialmente ate completar o plano' },
54
55
  { name: 'dw-run-qa', description: 'Executar QA visual com automacao de browser, testes E2E e acessibilidade' },
55
56
  { name: 'dw-run-task', description: 'Executar uma task com validacao e testes integrados' },
57
+ { name: 'dw-security-check', description: 'Check de seguranca rigido multi-camada (OWASP estatico + Trivy SCA/IaC + audit nativo) para projetos TS, Python, C# ou Rust' },
56
58
  { name: 'dw-update', description: 'Atualizar o dev-workflow para a versao mais recente publicada no npm sem sair da sessao do agente' },
57
59
  ],
58
60
  };
@@ -25,13 +25,47 @@ function run() {
25
25
  check: null,
26
26
  install: 'npx get-shit-done-cc@latest --claude --codex --copilot --opencode --local -y',
27
27
  },
28
+ {
29
+ name: 'Trivy (security scanner)',
30
+ check: 'trivy --version',
31
+ install: null,
32
+ instructions: [
33
+ 'Trivy is a native binary and cannot be installed via npm. Install it using your OS package manager:',
34
+ ' macOS: brew install trivy',
35
+ ' Linux: curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin',
36
+ ' Windows: choco install trivy (or: scoop install trivy)',
37
+ ' Docker: docker pull aquasec/trivy:latest (use via alias or wrapper)',
38
+ '',
39
+ 'Once installed, /dw-security-check will use it for CVE, secret, and IaC scanning.',
40
+ ],
41
+ },
28
42
  ];
29
43
 
30
44
  let installed = 0;
31
45
  let skipped = 0;
32
46
  let failed = 0;
47
+ let missing = 0;
33
48
 
34
49
  for (const dep of deps) {
50
+ // Detect-only dependencies (install === null): check presence, print instructions if missing
51
+ if (dep.install === null) {
52
+ process.stdout.write(` Checking ${dep.name}...`);
53
+ try {
54
+ execSync(dep.check, { stdio: 'pipe', timeout: 10000 });
55
+ console.log(' \x1b[32m✓ already installed\x1b[0m');
56
+ installed++;
57
+ } catch (err) {
58
+ console.log(' \x1b[33m— not found\x1b[0m');
59
+ if (Array.isArray(dep.instructions)) {
60
+ for (const line of dep.instructions) {
61
+ console.log(` ${line}`);
62
+ }
63
+ }
64
+ missing++;
65
+ }
66
+ continue;
67
+ }
68
+
35
69
  process.stdout.write(` Installing ${dep.name}...`);
36
70
  try {
37
71
  execSync(dep.install, { stdio: 'pipe', timeout: 300000 });
@@ -45,7 +79,11 @@ function run() {
45
79
  }
46
80
 
47
81
  console.log(`\n ${'='.repeat(40)}`);
48
- console.log(` Done! ${installed} installed, ${skipped} skipped, ${failed} failed`);
82
+ const parts = [`${installed} installed`];
83
+ if (skipped) parts.push(`${skipped} skipped`);
84
+ if (missing) parts.push(`${missing} require manual install (see instructions above)`);
85
+ if (failed) parts.push(`${failed} failed`);
86
+ console.log(` Done! ${parts.join(', ')}`);
49
87
  console.log();
50
88
  }
51
89
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brunosps00/dev-workflow",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "AI-driven development workflow commands for any project. Scaffolds a complete PRD-to-PR pipeline with multi-platform AI assistant support.",
5
5
  "bin": {
6
6
  "dev-workflow": "./bin/dev-workflow.js"
@@ -23,6 +23,7 @@ When available in the project under `./.agents/skills/`, use these skills as ana
23
23
 
24
24
  - `dw-review-rigor`: **ALWAYS** — applies de-duplication (same pattern in N files = 1 finding), severity ordering (critical → high → medium → low), verify-before-flag, skip-what-linter-catches, and signal-over-volume. The report's "Issues Found" table follows this discipline.
25
25
  - `dw-verify`: **ALWAYS** — invoked before emitting an `APPROVED` or `APPROVED WITH CAVEATS` verdict. Without a VERIFICATION REPORT PASS (test + lint + build), the verdict cannot be APPROVED.
26
+ - `/dw-security-check`: **ALWAYS for TS/Python/C#/Rust projects** — invoked as step 6.7 (Security Layer) before emitting a verdict. If the project uses a supported language and `security-check.md` is missing OR has REJECTED status, the verdict is **REJECTED** — no exception.
26
27
  - `security-review`: use when auth, authorization, external input, upload, SQL, external integration, secrets, SSRF, XSS, or sensitive surfaces are present
27
28
  - `vercel-react-best-practices`: use when the diff touches React/Next.js to review rendering, fetching, bundle, hydration, and performance patterns
28
29
 
@@ -214,6 +215,15 @@ If prior reviews exist in `{{PRD_PATH}}/reviews/` or a previous `{{PRD_PATH}}/dw
214
215
 
215
216
  <critical>Invoke `dw-verify` and include the VERIFICATION REPORT at the start of the report. Without PASS, the verdict can only be `REJECTED` — never `APPROVED` or `APPROVED WITH CAVEATS`.</critical>
216
217
 
218
+ ### 6.7. Security Layer (Required for TS/Python/C#/Rust projects)
219
+
220
+ <critical>For TypeScript/JavaScript, Python, C#, or Rust projects whose diff touches code, invoke `/dw-security-check` with the same `{{PRD_PATH}}`. Without a `security-check.md` present in the PRD OR with a status other than CLEAN / PASSED WITH OBSERVATIONS, the verdict is **REJECTED** — no exception.</critical>
221
+
222
+ - If `/dw-security-check` returns **REJECTED**: automatic verdict **REJECTED**. Include the security-check's CRITICAL/HIGH findings with appropriate severity in the final report's "Issues Found" section.
223
+ - If it returns **PASSED WITH OBSERVATIONS**: may proceed to APPROVED WITH CAVEATS, listing medium/low observations as caveats.
224
+ - If it returns **CLEAN**: proceeds normally to a verdict based on the remaining criteria.
225
+ - Projects in languages not supported by security-check (Go, Java, PHP, Ruby, etc.) → skip this step with a visible note in the code-review report.
226
+
217
227
  ### 7. Generate Code Review Report (Required)
218
228
 
219
229
  Save to `{{PRD_PATH}}/dw-code-review.md`:
@@ -14,8 +14,11 @@ You are an assistant specialized in creating well-documented Pull Requests. Your
14
14
  | Skill | Trigger |
15
15
  |-------|---------|
16
16
  | `dw-verify` | **ALWAYS** — invoked before `git push`. Without a VERIFICATION REPORT PASS in the current session AFTER the last code edit, the PR **CANNOT** be created. |
17
+ | `/dw-security-check` | **ALWAYS for TS/Python/C#/Rust projects** — `security-check.md` with status ≠ REJECTED is required for supported-language projects. |
17
18
 
18
- <critical>Hard gate: if the current session has no VERIFICATION REPORT PASS from `dw-verify` produced AFTER the last edit/commit, STOP and invoke `dw-verify` before proceeding. A PR is a permanent artifact — it demands the highest verification standard.</critical>
19
+ <critical>Hard gate 1 (verify): if the current session has no VERIFICATION REPORT PASS from `dw-verify` produced AFTER the last edit/commit, STOP and invoke `dw-verify` before proceeding. A PR is a permanent artifact — it demands the highest verification standard.</critical>
20
+
21
+ <critical>Hard gate 2 (security): for TS/Python/C#/Rust projects, if `{{PRD_PATH}}/security-check.md` is missing OR has REJECTED status, STOP and invoke `/dw-security-check` before proceeding. HIGH/CRITICAL vulnerabilities CANNOT reach the PR. For other languages (Go, Java, etc.), this gate is skipped with a note.</critical>
19
22
 
20
23
  ## Usage
21
24
 
@@ -25,6 +25,7 @@ You are a workspace help assistant. When invoked, present the user with a comple
25
25
  | design, ui, redesign | `/dw-redesign-ui` | Audit + propose + implement visual |
26
26
  | decision, adr, architecture | `/dw-adr` | Record an Architecture Decision Record |
27
27
  | debate, council, stress-test, opinions | `/dw-brainstorm --council` or `/dw-create-techspec --council` | Invokes `dw-council` for a multi-advisor debate |
28
+ | security, vulnerability, owasp, trivy, cve | `/dw-security-check` | Rigid multi-layer check (OWASP static + Trivy SCA/IaC + native audit) for TS/Python/C#/Rust |
28
29
  | revert, rollback task | `/dw-revert-task` | Safe revert with dependency checks |
29
30
  | hotfix, quick change | `/dw-quick` | One-off task with guarantees, no PRD |
30
31
  | resume, where I left off | `/dw-resume` | Restore previous session context |
@@ -148,6 +149,7 @@ This workspace uses an AI command system that automates the full development cyc
148
149
  | `/dw-review-implementation` | Compares PRD vs code (FRs, endpoints, tasks) | PRD path | Gap report |
149
150
  | `/dw-code-review` | Formal code review (quality, rules, tests) | PRD path | `code-review.md` |
150
151
  | `/dw-refactoring-analysis` | Audit code smells and refactoring opportunities (Fowler's catalog) | PRD path | `refactoring-analysis.md` |
152
+ | `/dw-security-check` | Rigid security check (OWASP static + Trivy SCA/IaC + native audit) for TS/Python/C#/Rust | PRD path or code | `security-check.md` |
151
153
 
152
154
  ### Versioning
153
155
 
@@ -28,6 +28,7 @@ This command is called automatically by `/dw-run-plan` at the end of all tasks,
28
28
  | Skill | Trigger |
29
29
  |-------|---------|
30
30
  | `dw-review-rigor` | **ALWAYS** — when listing gaps between PRD/TechSpec and code, apply de-duplication (same gap in N modules = 1 entry), severity ordering, and verify-intent-before-flag |
31
+ | `/dw-security-check` | **ALWAYS for TS/Python/C#/Rust projects whose diff touches code** — findings become a "Security Gaps" category in the interactive corrections cycle. If status is REJECTED, the gaps are blocking. |
31
32
 
32
33
  ## Input Variables
33
34
 
@@ -42,6 +43,16 @@ Analyze the implementation by comparing:
42
43
  2. Technical specifications from the TechSpec
43
44
  3. Tasks defined in tasks.md
44
45
  4. Actually implemented code (via git diff/status)
46
+ 5. **Security of the implemented code** (via `/dw-security-check` for TS/Python/C#/Rust projects)
47
+
48
+ ## Security Layer (Required for TS/Python/C#/Rust projects)
49
+
50
+ <critical>If the project uses TypeScript, Python, C#, or Rust and the diff touches code (not just docs), INVOKE `/dw-security-check {{PRD_PATH}}` before listing gaps. The status and findings returned feed the "Security Gaps" section of the Level 2 report.</critical>
51
+
52
+ - **REJECTED** status from security-check → CRITICAL/HIGH findings become **blocking** gaps in the interactive corrections cycle (equivalent to a critical missing feature)
53
+ - **PASSED WITH OBSERVATIONS** → MEDIUM/LOW findings become recommendations in the cycle
54
+ - **CLEAN** → "Security Gaps: None" section in the report
55
+ - Project in an unsupported language → note in the report indicating the security layer was skipped
45
56
 
46
57
  ## Files to Read (Required)
47
58
 
@@ -0,0 +1,271 @@
1
+ <system_instructions>
2
+ You are a rigorous security auditor. Your job is to perform a **multi-layer security check** on a dev-workflow project — static OWASP review (language-aware for TypeScript, Python, and C#), Trivy dependency/secret/IaC scanning, and native lockfile audit — and emit a blocking verdict with no bypass.
3
+
4
+ <critical>This command is rigid. CRITICAL or HIGH findings produce REJECTED status. There is NO `--skip`, `--ignore`, or allowlist flag. Findings are fixed or the verdict stands.</critical>
5
+ <critical>Supported languages in this release: TypeScript/JavaScript, Python, C#, Rust. If none is detected in scope, abort with a clear message.</critical>
6
+
7
+ ## When to Use
8
+ - Before `/dw-code-review` as the security layer for any TS/Python/C#/Rust project
9
+ - Before `/dw-generate-pr` to ensure no HIGH/CRITICAL vulnerabilities ship
10
+ - Automatically invoked by `/dw-review-implementation` when the diff touches code in a supported language
11
+ - Manually when auditing dependencies after adding a new package
12
+ - NOT for auto-fix (this command detects; remediation is manual or via `/dw-fix-qa`)
13
+ - NOT for DAST — this is SAST + SCA + IaC scanning (`/dw-run-qa` covers runtime)
14
+
15
+ ## Pipeline Position
16
+ **Predecessor:** `/dw-run-plan` or `/dw-run-task` (code committed) | **Successor:** `/dw-code-review` (which hard-gates on this command's output for supported languages)
17
+
18
+ ## Complementary Skills
19
+
20
+ | Skill | Trigger |
21
+ |-------|---------|
22
+ | `security-review` | **ALWAYS** — primary OWASP knowledge base; language-specific rules live in `languages/{typescript,python,csharp}.md`, cross-cutting topics in `references/*.md` |
23
+ | `dw-review-rigor` | **ALWAYS** — applies de-duplication (same pattern in N files = 1 finding), severity ordering, verify-intent-before-flag, skip-what-linter-catches, and signal-over-volume |
24
+ | `dw-verify` | **ALWAYS** — a VERIFICATION REPORT (Trivy command + exit code + summary) must be present before any status is emitted |
25
+
26
+ ## Input Variables
27
+
28
+ | Variable | Description | Example |
29
+ |----------|-------------|---------|
30
+ | `{{SCOPE}}` | PRD path OR source path. Optional — defaults to `.dw/spec/prd-<slug>` inferred from `feat/prd-<slug>` git branch | `.dw/spec/prd-checkout-v2` or `src/` |
31
+
32
+ If `{{SCOPE}}` is not provided and no PRD is active, abort and ask the user to specify.
33
+
34
+ ## File Locations
35
+
36
+ - Report (PRD scope): `{{SCOPE}}/security-check.md`
37
+ - Report (non-PRD scope): stdout
38
+ - Language reference files: `.agents/skills/security-review/languages/{typescript,javascript,python,csharp,rust}.md`
39
+ - Cross-cutting OWASP refs: `.agents/skills/security-review/references/*.md`
40
+
41
+ ## Required Behavior — Pipeline (execute in order, no bypass)
42
+
43
+ ### 0. Detect Languages in Scope
44
+
45
+ Enumerate files in scope and detect languages:
46
+
47
+ | Language | Indicators |
48
+ |----------|------------|
49
+ | TypeScript / JavaScript | `tsconfig.json`, `package.json`, `*.ts`, `*.tsx`, `*.js`, `*.jsx`, `*.mjs` |
50
+ | Python | `pyproject.toml`, `requirements*.txt`, `Pipfile`, `poetry.lock`, `setup.py`, `*.py` |
51
+ | C# / .NET | `*.csproj`, `*.sln`, `packages.config`, `Directory.Build.props`, `*.cs`, `*.cshtml`, `*.razor` |
52
+ | Rust | `Cargo.toml`, `Cargo.lock`, `*.rs`, `rust-toolchain.toml` |
53
+
54
+ - If **none** of the four is detected → **abort** with:
55
+ `"dw-security-check currently supports TypeScript, Python, C#, and Rust. No files in supported languages were detected in <scope>. Aborting."`
56
+ - If **one or more** are detected → proceed; polyglot repos run every applicable language layer and the report has a section per language.
57
+
58
+ Record the detected language(s) — they drive which `languages/*.md` file(s) the static review consults and which native audit command runs.
59
+
60
+ ### 1. Static Code Review (Language-Aware)
61
+
62
+ For each detected language, invoke the `security-review` skill using the corresponding reference file(s) as the primary guide:
63
+
64
+ - **TS/JS** → `languages/typescript.md` + `languages/javascript.md`
65
+ - **Python** → `languages/python.md`
66
+ - **C#** → `languages/csharp.md`
67
+ - **Rust** → `languages/rust.md`
68
+ - **Cross-cutting** (all languages) → `references/{injection,xss,csrf,ssrf,cryptography,authentication,authorization,deserialization,supply-chain,secrets,file-security,api-security}.md` as applicable
69
+
70
+ Apply the `dw-review-rigor` five rules:
71
+ 1. De-duplicate: same pattern in N files → 1 finding with affected file list
72
+ 2. Severity ordering: CRITICAL → HIGH → MEDIUM → LOW
73
+ 3. Verify intent before flagging: adjacent comments, ADRs, tests, `.dw/rules/`
74
+ 4. Skip what the linter catches
75
+ 5. Signal over volume: keep all CRITICAL/HIGH; prune MEDIUM/LOW to the most impactful
76
+
77
+ ### 1.5. Context7 MCP — Framework Best Practices (MANDATORY when framework detected)
78
+
79
+ <critical>When the scope has a detectable framework, you MUST consult Context7 MCP for current best practices before applying framework-specific checks. Offline knowledge may be outdated.</critical>
80
+
81
+ Framework detection and query:
82
+
83
+ | Language | Framework detection source | Example Context7 queries |
84
+ |----------|----------------------------|--------------------------|
85
+ | TS/JS | `package.json` deps | `"next.js 14 security best practices app router"`, `"nestjs 10 authentication guards"`, `"remix v2 csrf"` |
86
+ | Python | `pyproject.toml` / `requirements.txt` | `"django 5 security checklist"`, `"fastapi pydantic validation"`, `"flask-login secure cookies"` |
87
+ | C# | `*.csproj` `PackageReference` | `"asp.net core 8 jwt bearer"`, `"blazor server antiforgery"`, `"minimal apis authorization"` |
88
+ | Rust | `Cargo.toml` `[dependencies]` | `"actix-web 4 security middleware"`, `"axum 0.7 extractor auth"`, `"rocket 0.5 forms csrf"`, `"sqlx query macros"` |
89
+
90
+ For each detected framework+version:
91
+ 1. Build the query with framework name + detected major/minor version + the topic (auth, CSP, cookies, server actions, etc.)
92
+ 2. Invoke Context7 MCP
93
+ 3. Incorporate the returned guidance as live context when reviewing framework-specific code
94
+ 4. If a Context7 result contradicts offline knowledge in `languages/*.md`, **Context7 wins** — cite the source in the finding
95
+
96
+ If Context7 MCP is unavailable in the environment:
97
+ - Degrade to offline knowledge only
98
+ - **Add a visible warning** in the report: `⚠️ Context7 MCP unavailable — framework-version-specific checks used offline knowledge; best practices for <framework@version> may be stale.`
99
+
100
+ ### 2. Dependency + Secret + IaC Scan (Trivy)
101
+
102
+ <critical>Trivy must be installed. If missing, abort with: `"Trivy not found. Install via 'brew install trivy' (macOS) or equivalent; see 'npx @brunosps00/dev-workflow install-deps' instructions."`</critical>
103
+
104
+ Run:
105
+
106
+ ```bash
107
+ trivy fs --scanners vuln,secret,misconfig --severity HIGH,CRITICAL --exit-code 1 --format json --output /tmp/dw-trivy-fs.json <scope-path>
108
+ ```
109
+
110
+ Parse the JSON output. The scan covers:
111
+ - **Vulnerabilities** in manifests: `package.json`/`package-lock.json`/`pnpm-lock.yaml`/`yarn.lock` (TS/JS), `requirements*.txt`/`Pipfile.lock`/`poetry.lock` (Python), `*.csproj`/`packages.lock.json` (C# / NuGet)
112
+ - **Secrets**: API keys, tokens, private keys accidentally committed
113
+ - **Misconfig**: surface-level — subsumed by step 3 for IaC
114
+
115
+ Capture the exact command and exit code; include both in the VERIFICATION REPORT (step 5).
116
+
117
+ ### 3. IaC Config Scan (Trivy)
118
+
119
+ Run:
120
+
121
+ ```bash
122
+ trivy config --severity HIGH,CRITICAL --format json --output /tmp/dw-trivy-config.json <scope-path>
123
+ ```
124
+
125
+ Covers Dockerfile, Kubernetes manifests, Terraform, CloudFormation, GitHub Actions workflows, Helm charts, AWS CDK.
126
+
127
+ ### 4. Native Lockfile Audit (language-specific, second signal)
128
+
129
+ For each detected language, run the native audit tool (if available). Treat its output as a second signal — Trivy is primary; this catches gaps.
130
+
131
+ | Language | Primary command | Fallback |
132
+ |----------|-----------------|----------|
133
+ | TS/JS (npm) | `npm audit --production --audit-level=high --json` | `npm audit --production` (human) |
134
+ | TS/JS (pnpm) | `pnpm audit --prod --audit-level high --json` | — |
135
+ | TS/JS (yarn) | `yarn npm audit --severity high --recursive --json` | — |
136
+ | Python | `pip-audit --strict --format json` | skip with note if `pip-audit` missing |
137
+ | C# | `dotnet list package --vulnerable --include-transitive` | — |
138
+ | Rust | `cargo audit --json` | skip with note if `cargo-audit` not installed (install via `cargo install cargo-audit`); optionally `cargo deny check advisories` |
139
+
140
+ If the tool returns exit ≠ 0 or reports HIGH/CRITICAL, escalate to REJECTED (same policy as Trivy).
141
+
142
+ ### 5. VERIFICATION REPORT (dw-verify)
143
+
144
+ Before emitting a status, produce a VERIFICATION REPORT per `dw-verify` skill. Required shape:
145
+
146
+ ```
147
+ VERIFICATION REPORT
148
+ -------------------
149
+ Claim: Security check complete for <scope> (languages: <list>)
150
+ Commands:
151
+ - trivy fs ... --exit-code 1 → exit <N>, findings: C=<x> H=<y>
152
+ - trivy config ... → exit <N>, findings: C=<x> H=<y>
153
+ - <native audit> → exit <N>, findings: ...
154
+ Executed: just now, after all changes
155
+ Static review: <X> findings (C=<a> H=<b> M=<c> L=<d>)
156
+ Framework context: Context7 MCP [consulted | unavailable]
157
+ Verdict: <CLEAN | PASSED WITH OBSERVATIONS | REJECTED>
158
+ ```
159
+
160
+ ### 6. Emit Status (rigid gates)
161
+
162
+ | Condition | Status |
163
+ |-----------|--------|
164
+ | Any CRITICAL finding (static OR Trivy OR native audit) | **REJECTED** |
165
+ | Any HIGH finding | **REJECTED** |
166
+ | Only MEDIUM / LOW findings | **PASSED WITH OBSERVATIONS** |
167
+ | Zero findings | **CLEAN** |
168
+
169
+ <critical>No finding is "accepted as caveat" at HIGH or above. The user may choose to fix and re-run, or raise the issue as an ADR documenting why the risk is accepted — but this command's verdict does not change.</critical>
170
+
171
+ ## Report Format
172
+
173
+ Save to `{{SCOPE}}/security-check.md` (when PRD scope) with frontmatter:
174
+
175
+ ```markdown
176
+ ---
177
+ type: security-check
178
+ schema_version: "1.0"
179
+ status: <CLEAN | PASSED WITH OBSERVATIONS | REJECTED>
180
+ date: YYYY-MM-DD
181
+ languages: [typescript, python, csharp, rust]
182
+ ---
183
+
184
+ # Security Check — <feature name>
185
+
186
+ ## Status: <STATUS>
187
+
188
+ <short summary>
189
+
190
+ ## VERIFICATION REPORT
191
+ <the block from step 5>
192
+
193
+ ## Findings
194
+
195
+ ### Critical (<count>)
196
+ - **[CRITICAL]** `path/to/file.ts:42` — <title ≤72 chars>
197
+ <description>
198
+ <remediation>
199
+ Also affects: <other paths if de-duplicated>
200
+ Evidence: <snippet or CVE id>
201
+
202
+ ### High (<count>)
203
+ ...
204
+
205
+ ### Medium (<count>)
206
+ ...
207
+
208
+ ### Low (<count>)
209
+ ...
210
+
211
+ ## Dependency Vulnerabilities (Trivy)
212
+
213
+ | CVE | Package | Installed | Fixed in | Severity | Path |
214
+ |-----|---------|-----------|----------|----------|------|
215
+ | CVE-... | ... | ... | ... | CRITICAL | package-lock.json |
216
+
217
+ ## Secrets Found (Trivy)
218
+
219
+ | Rule | File | Line |
220
+ |------|------|------|
221
+ | aws-access-key-id | src/config.ts | 14 |
222
+
223
+ ## IaC Misconfigurations (Trivy config)
224
+
225
+ | Rule | File | Severity | Description |
226
+ |------|------|----------|-------------|
227
+ | AVD-DS-0002 | Dockerfile | HIGH | Running as root |
228
+
229
+ ## Framework Best Practices (Context7)
230
+
231
+ For each framework consulted, one paragraph summarizing the guidance applied.
232
+
233
+ If Context7 was unavailable, include the warning block.
234
+
235
+ ## Well-Implemented Aspects
236
+ - <short list for tone calibration; does not affect verdict>
237
+
238
+ ## Recommendations
239
+ 1. <action for blocking findings>
240
+ 2. <action for observations>
241
+ ```
242
+
243
+ ## Integration With Other dw-* Commands
244
+
245
+ - **`/dw-code-review`** (Level 3): for TS/Python/C#/Rust projects, invokes this command as step 6.7 "Security Layer" and hard-gates on the result. APPROVED cannot be emitted if `security-check.md` is missing or REJECTED.
246
+ - **`/dw-review-implementation`** (Level 2): for TS/Python/C#/Rust projects that touch code, invokes this command and maps its findings into a "Security Gaps" category in the interactive corrections cycle.
247
+ - **`/dw-generate-pr`**: hard gate — for supported-language projects, blocks the PR if `security-check.md` is missing or REJECTED from the current session.
248
+ - **`/dw-bugfix --analysis`**: if the root cause area involves auth / secrets / external input, suggests running this command before the fix.
249
+
250
+ ## Critical Rules
251
+
252
+ - <critical>NO bypass flag. The command does not accept `--skip`, `--ignore`, `--allowlist`.</critical>
253
+ - <critical>Trivy is required. If missing, abort with install instructions. Do NOT silently skip the SCA layer.</critical>
254
+ - <critical>Context7 MCP is consulted when frameworks are detected. Degradation to offline mode must be visible in the report.</critical>
255
+ - Do NOT modify source code — this command detects only.
256
+ - Do NOT re-flag findings already tracked as accepted in a prior ADR (`.dw/spec/*/adrs/adr-*.md` with status `Accepted` and topic covering the finding).
257
+ - If running without PRD scope (raw path), emit the report to stdout — do not write to arbitrary locations.
258
+
259
+ ## Error Handling
260
+
261
+ - Trivy missing → abort with install instructions (see `install-deps`)
262
+ - `.dw/spec/<slug>/` missing → check if scope is a raw path; otherwise abort asking for explicit scope
263
+ - Native audit tool missing (e.g., `pip-audit`) → skip with visible note in report; do not fail
264
+ - Context7 MCP unavailable → visible warning in report; do not fail
265
+ - Scope contains 0 files of supported languages → abort (see step 0)
266
+
267
+ ## Inspired by
268
+
269
+ `dw-security-check` is dev-workflow-native. Conceptually inspired by the open-source skills surfaced via `/find-skills` (`supercent-io/skills-template@security-best-practices`, `hoodini/ai-agents-skills@owasp-security`, `github/awesome-copilot@agent-owasp-compliance`), but implemented from scratch with native integration to dev-workflow's primitives (`dw-verify`, `dw-review-rigor`, `security-review`) and Trivy — none of which those skills integrate.
270
+
271
+ </system_instructions>
@@ -23,6 +23,7 @@ Quando disponíveis no projeto em `./.agents/skills/`, use estas skills como apo
23
23
 
24
24
  - `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, e signal-over-volume. A tabela "Problemas Encontrados" do relatório segue essa disciplina.
25
25
  - `dw-verify`: **SEMPRE** — invocada antes de emitir verdict `APROVADO` ou `APROVADO COM RESSALVAS`. Sem VERIFICATION REPORT PASS (test + lint + build), o verdict não pode sair como APROVADO.
26
+ - `/dw-security-check`: **SEMPRE para projetos TS/Python/C#/Rust** — invocado como step 6.7 (Camada de Segurança) antes de emitir verdict. Se o projeto usa linguagem suportada e `security-check.md` não existe OU tem status REJECTED, o verdict é **REPROVADO** — sem exceção.
26
27
  - `security-review`: use quando auth, autorização, input externo, upload, SQL, integração externa, secrets, SSRF, XSS ou superfícies sensíveis estiverem presentes
27
28
  - `vercel-react-best-practices`: use quando o diff tocar React/Next.js para revisar padrões de renderização, fetching, bundle, hidratação e performance
28
29
 
@@ -198,6 +199,15 @@ Se houver reviews anteriores em `{{PRD_PATH}}/reviews/` ou `{{PRD_PATH}}/dw-code
198
199
 
199
200
  <critical>Invocar `dw-verify` e incluir o VERIFICATION REPORT no início do relatório. Sem PASS, o verdict só pode ser `REPROVADO` — nunca `APROVADO` ou `APROVADO COM RESSALVAS`.</critical>
200
201
 
202
+ ### 6.7. Camada de Segurança (Obrigatório para projetos TS/Python/C#/Rust)
203
+
204
+ <critical>Para projetos em TypeScript/JavaScript, Python, C# ou Rust que tiveram código modificado no diff, invocar `/dw-security-check` com o mesmo `{{PRD_PATH}}`. Sem `security-check.md` presente no PRD OU com status diferente de CLEAN/PASSED WITH OBSERVATIONS, o verdict é **REPROVADO** — sem exceção.</critical>
205
+
206
+ - Se `/dw-security-check` retornar **REJECTED**: verdict automático **REPROVADO**. Incluir na seção "Problemas Encontrados" do relatório final os findings CRITICAL/HIGH do security-check com severity apropriada.
207
+ - Se retornar **PASSED WITH OBSERVATIONS**: pode seguir para APROVADO COM RESSALVAS, listando as observations medium/low como ressalvas.
208
+ - Se retornar **CLEAN**: prossegue normalmente para o verdict baseado nos demais critérios.
209
+ - Projetos em linguagens não suportadas pelo security-check (Go, Java, PHP, Ruby etc.) → pular este step com nota visível no relatório de code-review.
210
+
201
211
  ### 7. Gerar Relatório de Code Review (Obrigatório)
202
212
 
203
213
  Salvar em `{{PRD_PATH}}/dw-code-review.md`:
@@ -14,8 +14,11 @@
14
14
  | Skill | Gatilho |
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
+ | `/dw-security-check` | **SEMPRE para projetos TS/Python/C#/Rust** — `security-check.md` com status ≠ REJECTED é obrigatório para projetos em linguagem suportada. |
17
18
 
18
- <critical>Hard gate: 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>
19
+ <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>
20
+
21
+ <critical>Hard gate 2 (security): para projetos TS/Python/C#/Rust, se `{{PRD_PATH}}/security-check.md` não existir OU tiver status REJECTED, PARAR e invocar `/dw-security-check` antes de prosseguir. Vulnerabilidades HIGH/CRITICAL NÃO podem chegar ao PR. Para outras linguagens (Go, Java, etc.), este gate é pulado com nota.</critical>
19
22
 
20
23
  ## Uso
21
24
 
@@ -25,6 +25,7 @@ Você é um assistente de ajuda do workspace. Quando invocado, apresente ao usu
25
25
  | design, ui, redesign | `/dw-redesign-ui` | Auditoria + propostas + implementação visual |
26
26
  | decisão, adr, arquitetura | `/dw-adr` | Registrar Architecture Decision Record |
27
27
  | debate, council, stress-test, opiniões | `/dw-brainstorm --council` ou `/dw-create-techspec --council` | Invoca `dw-council` para debate multi-advisor |
28
+ | security, segurança, vulnerabilidade, owasp, trivy, cve | `/dw-security-check` | Check multi-camada rígido (OWASP estático + Trivy SCA/IaC + audit nativo) para TS/Python/C#/Rust |
28
29
  | reverter, rollback de task | `/dw-revert-task` | Revert seguro com check de dependências |
29
30
  | hotfix, mudança rápida | `/dw-quick` | Task pontual com garantias sem PRD |
30
31
  | retomar, onde parei | `/dw-resume` | Restaura contexto da sessão anterior |
@@ -135,6 +136,7 @@ Este workspace utiliza um sistema de comandos AI que automatiza o ciclo completo
135
136
  | `/dw-review-implementation` | Compara PRD vs código (FRs, endpoints, tasks) | Path do PRD | Relatório de gaps |
136
137
  | `/dw-code-review` | Code review formal (qualidade, rules, testes) | Path do PRD | `code-review.md` |
137
138
  | `/dw-refactoring-analysis` | Auditoria de code smells e oportunidades de refatoração (catálogo Fowler) | Path do PRD | `refactoring-analysis.md` |
139
+ | `/dw-security-check` | Check de segurança rígido (OWASP estático + Trivy SCA/IaC + audit nativo) para TS/Python/C#/Rust | Path do PRD ou código | `security-check.md` |
138
140
 
139
141
  ### Versionamento
140
142
 
@@ -28,6 +28,7 @@
28
28
  | Skill | Gatilho |
29
29
  |-------|---------|
30
30
  | `dw-review-rigor` | **SEMPRE** — ao listar gaps entre PRD/TechSpec e código, aplicar de-duplication (mesmo gap em N módulos = 1 entrada), severity ordering e verify-intent-before-flag |
31
+ | `/dw-security-check` | **SEMPRE para projetos TS/Python/C#/Rust com diff que toca código** — os findings viram uma categoria "Security Gaps" no ciclo interativo de correções. Se status REJECTED, os gaps são bloqueantes. |
31
32
 
32
33
  ## Variáveis de Entrada
33
34
 
@@ -42,6 +43,16 @@
42
43
  2. Especificações técnicas da TechSpec
43
44
  3. Tasks definidas no tasks.md
44
45
  4. Código efetivamente implementado (via git diff/status)
46
+ 5. **Segurança do código implementado** (via `/dw-security-check` para projetos TS/Python/C#/Rust)
47
+
48
+ ## Camada de Segurança (Obrigatório para projetos TS/Python/C#/Rust)
49
+
50
+ <critical>Se o projeto usa TypeScript, Python, C# ou Rust e o diff toca código (não apenas docs), INVOCAR `/dw-security-check {{PRD_PATH}}` antes de listar gaps. O status e findings retornados alimentam a seção "Security Gaps" do relatório de Nível 2.</critical>
51
+
52
+ - Status **REJECTED** do security-check → os findings CRITICAL/HIGH viram gaps **bloqueantes** no ciclo interativo de correções (equivalente a gap de funcionalidade crítica não implementada)
53
+ - Status **PASSED WITH OBSERVATIONS** → os findings MEDIUM/LOW viram recomendações no ciclo
54
+ - Status **CLEAN** → seção "Security Gaps: Nenhum" no relatório
55
+ - Projeto em linguagem não suportada → nota no relatório indicando que a camada de segurança foi pulada
45
56
 
46
57
  ## Arquivos a Ler (Obrigatório)
47
58