the-frame-ai 0.9.5 → 0.9.6

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.de.md CHANGED
@@ -126,12 +126,31 @@ Führe `/frame:research <Thema>` aus — Claude erkundet die Codebasis, externe
126
126
  # → Bericht gespeichert unter .planning/reports/security/security-{date}.md
127
127
  # → STATE.md mit Security Status aktualisiert
128
128
 
129
- # Bei CRITICAL-Befunden:
130
- # ⛔ Ship BLOCKIERT. Kritische Befunde vor /frame:ship beheben.
131
- # → Bericht öffnen, jeden CRITICAL-Punkt beheben, /frame:security erneut ausführen
129
+ # Bei CRITICAL oder HIGH Befunden:
130
+ # ⛔ Ship BLOCKIERT. Führe /frame:security-fix aus um kritische Befunde zu beheben.
131
+
132
+ /frame:security-fix
133
+ # → liest den letzten Bericht und behebt Befunde nach Priorität:
134
+ # CRITICAL zuerst, dann HIGH
135
+ # - entfernt .env aus Git-Tracking (git rm --cached)
136
+ # - fügt fehlende Security-Header zu next.config.js / Express hinzu
137
+ # - fügt CSRF-Schutz für Route Handler hinzu
138
+ # - führt npm audit fix für verwundbare Abhängigkeiten aus
139
+ # - behebt Dockerfile: fügt USER-Direktive hinzu, ersetzt :latest
140
+ # - für Secrets bereits in der History: erklärt genau wie rotieren + History neu schreiben
141
+ # → verifiziert jeden Fix nach der Anwendung
142
+ # → aktualisiert STATE.md: entsperrt Ship wenn alle CRITICAL behoben
143
+
144
+ # Gezielte Fixes:
145
+ /frame:security-fix critical # nur CRITICAL beheben
146
+ /frame:security-fix high # nur HIGH beheben
147
+ /frame:security-fix SEC-1 # bestimmten Befund per ID beheben
148
+
149
+ /frame:security
150
+ # → Audit erneut ausführen um zu bestätigen dass alles sauber ist
132
151
 
133
152
  # Wenn alles sauber:
134
- # ✓ Keine kritischen Probleme. Sicher fortzufahren.
153
+ # ✓ Keine kritischen Probleme. Sicher mit /frame:ship fortzufahren.
135
154
 
136
155
  /frame:ship
137
156
  # → Sicherheitsprüfung bestanden, commit und push
@@ -256,6 +275,7 @@ Diese 7 Befehle decken 90% der Solo-Dev-Arbeit ab:
256
275
  |--------|---------------|
257
276
  | `/frame:review` | Vor dem Deployment — automatisierte Prüfungen + Checkliste |
258
277
  | `/frame:security` | Tiefer Sicherheitsaudit: Secrets, OWASP, Infrastruktur, KI/LLM-Risiken |
278
+ | `/frame:security-fix` | Befunde aus dem letzten Sicherheitsbericht beheben (CRITICAL zuerst, dann HIGH) |
259
279
  | `/frame:health` | Vollständiger Projekt-Gesundheitscheck |
260
280
  | `/frame:check-deps` | Sicherheitsaudit + veraltete Pakete |
261
281
  | `/frame:performance` | Bundle-Größe und Lighthouse-Audit |
package/README.es.md CHANGED
@@ -126,12 +126,31 @@ Ejecuta `/frame:research <tema>` — Claude explora la base de código, fuentes
126
126
  # → informe guardado en .planning/reports/security/security-{date}.md
127
127
  # → STATE.md actualizado con Security Status
128
128
 
129
- # Si hay hallazgos CRITICAL:
130
- # ⛔ Ship BLOQUEADO. Corrige los hallazgos críticos antes de /frame:ship.
131
- # → abre el informe, corrige cada punto CRITICAL, vuelve a ejecutar /frame:security
129
+ # Si hay hallazgos CRITICAL o HIGH:
130
+ # ⛔ Ship BLOQUEADO. Ejecuta /frame:security-fix para corregir los hallazgos críticos.
131
+
132
+ /frame:security-fix
133
+ # → lee el último informe y corrige hallazgos por prioridad:
134
+ # CRITICAL primero, luego HIGH
135
+ # - elimina .env del seguimiento de git (git rm --cached)
136
+ # - añade security headers faltantes a next.config.js / Express
137
+ # - añade protección CSRF a Route Handlers
138
+ # - ejecuta npm audit fix para dependencias vulnerables
139
+ # - corrige Dockerfile: añade directiva USER, reemplaza :latest
140
+ # - para secretos ya en el historial: explica exactamente cómo rotar + reescribir historial
141
+ # → verifica cada corrección después de aplicarla
142
+ # → actualiza STATE.md: desbloquea ship si todos los CRITICAL están resueltos
143
+
144
+ # Correcciones específicas:
145
+ /frame:security-fix critical # corregir solo CRITICAL
146
+ /frame:security-fix high # corregir solo HIGH
147
+ /frame:security-fix SEC-1 # corregir un hallazgo específico por ID
148
+
149
+ /frame:security
150
+ # → volver a ejecutar auditoría para confirmar que todo está limpio
132
151
 
133
152
  # Si todo está limpio:
134
- # ✓ Sin problemas críticos. Seguro para continuar.
153
+ # ✓ Sin problemas críticos. Seguro para continuar con /frame:ship.
135
154
 
136
155
  /frame:ship
137
156
  # → verificación de seguridad superada, commit y push
@@ -256,6 +275,7 @@ Estos 7 comandos cubren el 90% del trabajo de desarrollo en solitario:
256
275
  |---------|--------------|
257
276
  | `/frame:review` | Antes de desplegar — verificaciones automatizadas + lista de comprobación |
258
277
  | `/frame:security` | Auditoría de seguridad profunda: secretos, OWASP, infraestructura, riesgos IA/LLM |
278
+ | `/frame:security-fix` | Corregir hallazgos del último informe de seguridad (CRITICAL primero, luego HIGH) |
259
279
  | `/frame:health` | Verificación completa del estado del proyecto |
260
280
  | `/frame:check-deps` | Auditoría de seguridad + paquetes desactualizados |
261
281
  | `/frame:performance` | Auditoría de tamaño de bundle y Lighthouse |
package/README.hi.md CHANGED
@@ -126,12 +126,31 @@ FRAME — AI-सहायता प्राप्त एकल विकास
126
126
  # → रिपोर्ट .planning/reports/security/security-{date}.md में सहेजी जाती है
127
127
  # → STATE.md Security Status के साथ अपडेट होता है
128
128
 
129
- # CRITICAL निष्कर्ष होने पर:
130
- # ⛔ Ship BLOCKED. /frame:ship से पहले critical findings ठीक करें।
131
- # → रिपोर्ट खोलें, प्रत्येक CRITICAL आइटम ठीक करें, /frame:security फिर चलाएं
129
+ # CRITICAL या HIGH निष्कर्ष होने पर:
130
+ # ⛔ Ship BLOCKED. Critical findings ठीक करने के लिए /frame:security-fix चलाएं।
131
+
132
+ /frame:security-fix
133
+ # → नवीनतम रिपोर्ट पढ़ता है और प्राथमिकता के अनुसार findings ठीक करता है:
134
+ # पहले CRITICAL, फिर HIGH
135
+ # - .env को git tracking से हटाता है (git rm --cached)
136
+ # - next.config.js / Express में missing security headers जोड़ता है
137
+ # - Route Handlers पर CSRF protection जोड़ता है
138
+ # - vulnerable dependencies के लिए npm audit fix चलाता है
139
+ # - Dockerfile ठीक करता है: USER directive जोड़ता है, :latest बदलता है
140
+ # - history में पहले से मौजूद secrets के लिए: rotate + history rewrite कैसे करें बताता है
141
+ # → प्रत्येक fix लागू करने के बाद verify करता है
142
+ # → STATE.md अपडेट करता है: सभी CRITICAL हल होने पर ship unblock करता है
143
+
144
+ # Targeted fixes:
145
+ /frame:security-fix critical # केवल CRITICAL ठीक करें
146
+ /frame:security-fix high # केवल HIGH ठीक करें
147
+ /frame:security-fix SEC-1 # ID से specific finding ठीक करें
148
+
149
+ /frame:security
150
+ # → सब कुछ साफ है यह confirm करने के लिए audit फिर चलाएं
132
151
 
133
152
  # सब कुछ साफ होने पर:
134
- # ✓ कोई critical समस्या नहीं। आगे बढ़ना सुरक्षित है।
153
+ # ✓ कोई critical समस्या नहीं। /frame:ship के साथ आगे बढ़ना सुरक्षित है।
135
154
 
136
155
  /frame:ship
137
156
  # → security check पास, commit और push
@@ -256,6 +275,7 @@ npx the-frame-ai init
256
275
  |-------|--------------|
257
276
  | `/frame:review` | डिप्लॉय करने से पहले — स्वचालित जांच + चेकलिस्ट |
258
277
  | `/frame:security` | गहरा सुरक्षा ऑडिट: secrets, OWASP, infrastructure, AI/LLM risks |
278
+ | `/frame:security-fix` | नवीनतम रिपोर्ट से findings ठीक करें (पहले CRITICAL, फिर HIGH) |
259
279
  | `/frame:health` | पूर्ण प्रोजेक्ट स्वास्थ्य जांच |
260
280
  | `/frame:check-deps` | सुरक्षा ऑडिट + पुराने पैकेज |
261
281
  | `/frame:performance` | Bundle आकार और Lighthouse ऑडिट |
package/README.ja.md CHANGED
@@ -126,12 +126,31 @@ Claude Codeで一人でプロダクトを作っていて、チームのように
126
126
  # → レポートは .planning/reports/security/security-{date}.md に保存
127
127
  # → STATE.md が Security Status で更新
128
128
 
129
- # CRITICAL な発見がある場合:
130
- # ⛔ Ship がブロックされました。/frame:ship の前に重大な発見を修正してください。
131
- # → レポートを開き、各 CRITICAL 項目を修正し、/frame:security を再実行
129
+ # CRITICAL または HIGH な発見がある場合:
130
+ # ⛔ Ship がブロックされました。/frame:security-fix を実行して修正してください。
131
+
132
+ /frame:security-fix
133
+ # → 最新レポートを読み込み、優先度順に発見を修正:
134
+ # CRITICAL を先に、次に HIGH
135
+ # - .env を git トラッキングから削除(git rm --cached)
136
+ # - next.config.js / Express に不足している security headers を追加
137
+ # - Route Handlers に CSRF 保護を追加
138
+ # - 脆弱な依存関係に npm audit fix を実行
139
+ # - Dockerfile を修正:USER ディレクティブを追加、:latest を置換
140
+ # - 既に履歴にあるシークレット:ローテーションと履歴書き換えの手順を説明
141
+ # → 各修正を適用後に検証
142
+ # → STATE.md を更新:全 CRITICAL 解決後に ship をアンブロック
143
+
144
+ # ターゲット修正:
145
+ /frame:security-fix critical # CRITICAL のみ修正
146
+ /frame:security-fix high # HIGH のみ修正
147
+ /frame:security-fix SEC-1 # ID で特定の発見を修正
148
+
149
+ /frame:security
150
+ # → 全てクリーンであることを確認するために監査を再実行
132
151
 
133
152
  # クリーンな場合:
134
- # ✓ 重大な問題なし。安全に進められます。
153
+ # ✓ 重大な問題なし。/frame:ship で安全に進められます。
135
154
 
136
155
  /frame:ship
137
156
  # → セキュリティチェック通過、コミットとプッシュ
@@ -256,6 +275,7 @@ npx the-frame-ai init
256
275
  |---------|-------------|
257
276
  | `/frame:review` | デプロイ前 — 自動チェック + チェックリスト |
258
277
  | `/frame:security` | 深度セキュリティ監査:シークレット、OWASP、インフラ、AI/LLMリスク |
278
+ | `/frame:security-fix` | 最新セキュリティレポートの発見を修正(CRITICAL 優先、次に HIGH) |
259
279
  | `/frame:health` | プロジェクト全体のヘルスチェック |
260
280
  | `/frame:check-deps` | セキュリティ監査 + 古いパッケージ |
261
281
  | `/frame:performance` | バンドルサイズとLighthouse監査 |
package/README.md CHANGED
@@ -154,12 +154,31 @@ Run `/frame:research <topic>` — Claude explores the codebase, external sources
154
154
  # → report saved to .planning/reports/security/security-{date}.md
155
155
  # → STATE.md updated with Security Status
156
156
 
157
- # If CRITICAL findings:
158
- # ⛔ Ship BLOCKED. Fix critical findings before /frame:ship.
159
- # → open the report, fix each CRITICAL item, re-run /frame:security
157
+ # If CRITICAL or HIGH findings:
158
+ # ⛔ Ship BLOCKED. Run /frame:security-fix to fix critical findings.
159
+
160
+ /frame:security-fix
161
+ # → reads the latest report and fixes findings by priority:
162
+ # CRITICAL first, then HIGH
163
+ # - removes .env files from git tracking (git rm --cached)
164
+ # - adds missing security headers to next.config.js / Express
165
+ # - adds CSRF protection to Route Handlers
166
+ # - runs npm audit fix for vulnerable dependencies
167
+ # - fixes Dockerfile: adds USER directive, pins :latest tags
168
+ # - for secrets already in history: tells you exactly how to rotate + rewrite history
169
+ # → verifies each fix after applying
170
+ # → updates STATE.md: unblocks ship if all CRITICAL resolved
171
+
172
+ # Targeted fixes:
173
+ /frame:security-fix critical # fix only CRITICAL findings
174
+ /frame:security-fix high # fix only HIGH findings
175
+ /frame:security-fix SEC-1 # fix a specific finding by ID
176
+
177
+ /frame:security
178
+ # → re-run audit to confirm everything is clean
160
179
 
161
180
  # If clean:
162
- # ✓ No critical issues. Safe to proceed.
181
+ # ✓ No critical issues. Safe to proceed with /frame:ship.
163
182
 
164
183
  /frame:ship
165
184
  # → security check passes, commit and push
@@ -258,6 +277,7 @@ These 7 commands cover 90% of solo dev work:
258
277
  |---------|-------------|
259
278
  | `/frame:review` | Before deploying — automated checks + checklist |
260
279
  | `/frame:security` | Deep security audit: secrets, OWASP, infra, AI/LLM risks |
280
+ | `/frame:security-fix` | Fix findings from the latest security report (CRITICAL first, then HIGH) |
261
281
  | `/frame:health` | Full project health check |
262
282
  | `/frame:check-deps` | Dependency vulnerabilities + outdated packages |
263
283
  | `/frame:performance` | Bundle size and Lighthouse audit |
package/README.ru.md CHANGED
@@ -124,12 +124,31 @@ Research → Plan → Build → Review → Ship → Reflect
124
124
  # → отчёт сохраняется в .planning/reports/security/security-{date}.md
125
125
  # → STATE.md обновляется с Security Status
126
126
 
127
- # Если найдены CRITICAL-проблемы:
128
- # ⛔ Ship ЗАБЛОКИРОВАН. Исправь критические находки перед /frame:ship.
129
- # → открой отчёт, исправь каждый CRITICAL-пункт, запусти /frame:security снова
127
+ # Если найдены CRITICAL или HIGH проблемы:
128
+ # ⛔ Ship ЗАБЛОКИРОВАН. Запусти /frame:security-fix чтобы исправить.
129
+
130
+ /frame:security-fix
131
+ # → читает последний отчёт и исправляет находки по приоритету:
132
+ # сначала CRITICAL, потом HIGH
133
+ # - убирает .env из git-трекинга (git rm --cached)
134
+ # - добавляет security headers в next.config.js / Express
135
+ # - добавляет CSRF-защиту на Route Handlers
136
+ # - запускает npm audit fix для уязвимых зависимостей
137
+ # - фиксит Dockerfile: добавляет USER, заменяет :latest на конкретную версию
138
+ # - для секретов уже в истории: говорит точно как ротировать + переписать историю
139
+ # → проверяет каждый фикс после применения
140
+ # → обновляет STATE.md: разблокирует ship если все CRITICAL устранены
141
+
142
+ # Точечные фиксы:
143
+ /frame:security-fix critical # исправить только CRITICAL
144
+ /frame:security-fix high # исправить только HIGH
145
+ /frame:security-fix SEC-1 # исправить конкретную находку по ID
146
+
147
+ /frame:security
148
+ # → повторный аудит чтобы убедиться что всё чисто
130
149
 
131
150
  # Если всё чисто:
132
- # ✓ Критических проблем нет. Можно продолжать.
151
+ # ✓ Критических проблем нет. Можно продолжать с /frame:ship.
133
152
 
134
153
  /frame:ship
135
154
  # → проверка безопасности пройдена, коммит и пуш
@@ -254,6 +273,7 @@ npx the-frame init
254
273
  |---------|-------------------|
255
274
  | `/frame:review` | Перед деплоем — автоматические проверки + чеклист |
256
275
  | `/frame:security` | Глубокий аудит безопасности: секреты, OWASP, инфра, AI/LLM-риски |
276
+ | `/frame:security-fix` | Исправить находки из последнего отчёта (сначала CRITICAL, потом HIGH) |
257
277
  | `/frame:health` | Полная проверка здоровья проекта |
258
278
  | `/frame:check-deps` | Аудит безопасности + устаревшие пакеты |
259
279
  | `/frame:performance` | Размер бандла и Lighthouse-аудит |
package/README.zh.md CHANGED
@@ -126,12 +126,31 @@ FRAME — 面向 AI 辅助独立开发的框架
126
126
  # → 报告保存至 .planning/reports/security/security-{date}.md
127
127
  # → STATE.md 更新 Security Status
128
128
 
129
- # 如果发现 CRITICAL 问题:
130
- # ⛔ Ship 已阻止。在 /frame:ship 之前修复严重发现。
131
- # → 打开报告,修复每个 CRITICAL 项,重新运行 /frame:security
129
+ # 如果发现 CRITICAL 或 HIGH 问题:
130
+ # ⛔ Ship 已阻止。运行 /frame:security-fix 修复严重发现。
131
+
132
+ /frame:security-fix
133
+ # → 读取最新报告并按优先级修复发现:
134
+ # 先修复 CRITICAL,再修复 HIGH
135
+ # - 从 git 跟踪中移除 .env(git rm --cached)
136
+ # - 向 next.config.js / Express 添加缺失的 security headers
137
+ # - 为 Route Handlers 添加 CSRF 保护
138
+ # - 对有漏洞的依赖运行 npm audit fix
139
+ # - 修复 Dockerfile:添加 USER 指令,替换 :latest
140
+ # - 对已在历史记录中的密钥:说明如何轮换 + 重写历史
141
+ # → 应用后验证每个修复
142
+ # → 更新 STATE.md:所有 CRITICAL 解决后解除 ship 阻止
143
+
144
+ # 针对性修复:
145
+ /frame:security-fix critical # 仅修复 CRITICAL
146
+ /frame:security-fix high # 仅修复 HIGH
147
+ /frame:security-fix SEC-1 # 按 ID 修复特定发现
148
+
149
+ /frame:security
150
+ # → 重新运行审计确认一切正常
132
151
 
133
152
  # 如果一切正常:
134
- # ✓ 没有严重问题。可以安全继续。
153
+ # ✓ 没有严重问题。可以安全继续 /frame:ship。
135
154
 
136
155
  /frame:ship
137
156
  # → 安全检查通过,提交并推送
@@ -256,6 +275,7 @@ npx the-frame-ai init
256
275
  |------|---------|
257
276
  | `/frame:review` | 部署前——自动化检查 + 清单 |
258
277
  | `/frame:security` | 深度安全审计:密钥、OWASP、基础设施、AI/LLM 风险 |
278
+ | `/frame:security-fix` | 修复最新安全报告中的发现(先 CRITICAL,再 HIGH) |
259
279
  | `/frame:health` | 完整项目健康检查 |
260
280
  | `/frame:check-deps` | 安全审计 + 过时包 |
261
281
  | `/frame:performance` | Bundle 大小和 Lighthouse 审计 |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "the-frame-ai",
3
- "version": "0.9.5",
3
+ "version": "0.9.6",
4
4
  "description": "FRAME — Framework for AI-Assisted Solo Development",
5
5
  "type": "module",
6
6
  "bin": {
@@ -0,0 +1,260 @@
1
+ # /frame:security-fix — Fix Security Findings
2
+
3
+ Fix security issues found by `/frame:security`. Reads the latest report and guides through fixes by priority: CRITICAL first, then HIGH.
4
+
5
+ ## Subcommands
6
+
7
+ - `/frame:security-fix` — fix all findings from latest report
8
+ - `/frame:security-fix critical` — fix only CRITICAL findings
9
+ - `/frame:security-fix high` — fix only HIGH findings
10
+ - `/frame:security-fix <finding-id>` — fix a specific finding (e.g. `SEC-1`)
11
+
12
+ ## Instructions
13
+
14
+ ### Step 0: Find Latest Report
15
+
16
+ ```bash
17
+ REPORT=$(ls -t .planning/reports/security/security-*.md 2>/dev/null | head -1)
18
+ [ -z "$REPORT" ] && echo "NO_REPORT" || echo "$REPORT"
19
+ ```
20
+
21
+ If no report found → **STOP**:
22
+ ```
23
+ ❌ No security report found. Run /frame:security first.
24
+ ```
25
+
26
+ Read the report and extract all findings with their severity, category, file, and line number.
27
+
28
+ Parse `$ARGUMENTS`:
29
+ - Empty → fix all CRITICAL + HIGH findings
30
+ - `critical` → fix only CRITICAL
31
+ - `high` → fix only HIGH
32
+ - `SEC-N` → fix only that finding
33
+
34
+ **Heartbeat**: "Found report: {REPORT}. Starting fixes..."
35
+
36
+ ### Step 1: Show Fix Plan
37
+
38
+ Before making any changes, output a numbered plan:
39
+
40
+ ```
41
+ Security Fix Plan
42
+ ─────────────────
43
+ CRITICAL ({N}):
44
+ [SEC-1] {category}: {short description} — {file}:{line}
45
+ ...
46
+
47
+ HIGH ({N}):
48
+ [SEC-N] {category}: {short description} — {file}:{line}
49
+ ...
50
+
51
+ Starting with CRITICAL findings...
52
+ ```
53
+
54
+ ### Step 2: Fix CRITICAL Findings
55
+
56
+ For each CRITICAL finding, apply the appropriate fix pattern:
57
+
58
+ **Secrets in git (.env committed):**
59
+ ```bash
60
+ # Remove from git tracking (do NOT delete the file)
61
+ git rm --cached {file}
62
+ echo "{file}" >> .gitignore
63
+ ```
64
+ Then output:
65
+ ```
66
+ ⚠️ MANUAL ACTION REQUIRED:
67
+ 1. Rotate ALL secrets in {file} — they are compromised (in git history)
68
+ 2. Run: git filter-repo --path {file} --invert-paths
69
+ (or use BFG: https://rtyley.github.io/bfg-repo-cleaner/)
70
+ 3. Force-push to remote after history rewrite
71
+ ```
72
+
73
+ **Secret hardcoded in source file:**
74
+ - Replace the hardcoded value with `process.env.{VAR_NAME}` (or language equivalent)
75
+ - Add `{VAR_NAME}=your_value_here` to `.env.example`
76
+ - Add `.env` to `.gitignore` if not already there
77
+
78
+ **SQL Injection (string concatenation):**
79
+ - Replace string concatenation with parameterized query / prepared statement
80
+ - Show before/after diff
81
+
82
+ **Command Injection (exec with user input):**
83
+ - Replace `exec(userInput)` with `execFile` + argument array, or validate/sanitize input
84
+
85
+ **Path Traversal:**
86
+ - Add `path.resolve` + check that result starts with allowed base directory
87
+
88
+ **Heartbeat**: "CRITICAL fixes applied. Moving to HIGH findings..."
89
+
90
+ ### Step 3: Fix HIGH Findings
91
+
92
+ **Secrets in .env committed to git:**
93
+ Same as CRITICAL secrets pattern above.
94
+
95
+ **.dockerignore missing or exposing .env:**
96
+ - If `.dockerignore` missing: create it with standard ignores
97
+ - If `.dockerignore` has `!.env*` line: remove it
98
+
99
+ ```
100
+ # .dockerignore
101
+ .env
102
+ .env.*
103
+ !.env.example
104
+ .git
105
+ node_modules
106
+ ```
107
+
108
+ **Missing CSRF protection (Next.js App Router / Express):**
109
+
110
+ For Next.js Route Handlers — add token validation:
111
+ ```typescript
112
+ // lib/csrf.ts
113
+ import { headers } from 'next/headers'
114
+
115
+ export function validateCsrf() {
116
+ const origin = headers().get('origin')
117
+ const host = headers().get('host')
118
+ if (!origin || !origin.includes(host ?? '')) {
119
+ throw new Error('CSRF validation failed')
120
+ }
121
+ }
122
+ ```
123
+ Then call `validateCsrf()` at the top of each mutating Route Handler (POST/PUT/DELETE).
124
+
125
+ For Express — add `csurf` or `csrf-csrf` middleware.
126
+
127
+ **Missing HTTP security headers (Next.js):**
128
+
129
+ Add to `next.config.js` / `next.config.ts`:
130
+ ```javascript
131
+ const securityHeaders = [
132
+ { key: 'X-Frame-Options', value: 'SAMEORIGIN' },
133
+ { key: 'X-Content-Type-Options', value: 'nosniff' },
134
+ { key: 'Strict-Transport-Security', value: 'max-age=63072000; includeSubDomains; preload' },
135
+ { key: 'Referrer-Policy', value: 'strict-origin-when-cross-origin' },
136
+ { key: 'Permissions-Policy', value: 'camera=(), microphone=(), geolocation=()' },
137
+ ]
138
+
139
+ // In nextConfig:
140
+ headers: async () => [{ source: '/(.*)', headers: securityHeaders }]
141
+ ```
142
+
143
+ For Express:
144
+ ```bash
145
+ npm install helmet
146
+ ```
147
+ ```javascript
148
+ import helmet from 'helmet'
149
+ app.use(helmet())
150
+ ```
151
+
152
+ **Vulnerable dependencies:**
153
+ ```bash
154
+ npm audit fix
155
+ ```
156
+ If `npm audit fix` can't resolve automatically:
157
+ ```bash
158
+ npm audit fix --force
159
+ ```
160
+ If still unresolved — output:
161
+ ```
162
+ ⚠️ Manual update needed for {package}:
163
+ npm install {package}@{safe-version}
164
+ Check changelog for breaking changes: {url}
165
+ ```
166
+
167
+ **Dockerfile running as root:**
168
+ Add before the last `CMD`/`ENTRYPOINT`:
169
+ ```dockerfile
170
+ RUN addgroup --system appgroup && adduser --system --ingroup appgroup appuser
171
+ USER appuser
172
+ ```
173
+
174
+ **Dockerfile using :latest tag:**
175
+ - Replace `FROM image:latest` with `FROM image:{specific-version}`
176
+ - Check Docker Hub for the current stable version
177
+
178
+ **Heartbeat**: "HIGH fixes applied. Running verification..."
179
+
180
+ ### Step 4: Verify Fixes
181
+
182
+ Re-run targeted scans for each fixed category:
183
+
184
+ ```bash
185
+ # Re-check secrets
186
+ git ls-files 2>/dev/null | grep -iE '\.env$|\.env\.' | grep -v '\.env\.example' | grep -v '\.env\.template'
187
+
188
+ # Re-check .dockerignore
189
+ [ -f .dockerignore ] && grep -E '!\.env' .dockerignore && echo "STILL_EXPOSED" || echo "OK"
190
+
191
+ # Re-check security headers
192
+ grep -rn 'X-Frame-Options\|Strict-Transport-Security' next.config.* 2>/dev/null | head -5
193
+ ```
194
+
195
+ For each fixed finding: output `✓ SEC-{N} verified` or `✗ SEC-{N} still present — {reason}`.
196
+
197
+ ### Step 5: Update Report
198
+
199
+ Append to the existing report:
200
+
201
+ ```markdown
202
+ ## Fix Session — {date}
203
+
204
+ | Finding | Status | Fix Applied |
205
+ |---------|--------|-------------|
206
+ | SEC-1 | ✓ Fixed | {description} |
207
+ | SEC-2 | ✓ Fixed | {description} |
208
+ | SEC-3 | ⚠️ Manual action required | {what user must do} |
209
+ ```
210
+
211
+ ### Step 6: Update STATE.md
212
+
213
+ If all CRITICAL findings are resolved:
214
+ ```markdown
215
+ - Security Status: HIGH (was CRITICAL — critical findings resolved)
216
+ - Ship: UNBLOCKED
217
+ ```
218
+
219
+ If CRITICAL findings remain:
220
+ ```markdown
221
+ - Security Status: CRITICAL
222
+ - Ship: BLOCKED — {N} critical findings remain
223
+ ```
224
+
225
+ ### Step 7: Final Output
226
+
227
+ ```
228
+ Security Fix Complete
229
+ ─────────────────────
230
+ Fixed: {N} findings
231
+ Manual: {N} findings require your action
232
+ Remain: {N} findings (not in scope or couldn't auto-fix)
233
+
234
+ {If all CRITICAL resolved:}
235
+ ✓ Ship UNBLOCKED. Run /frame:security to confirm, then /frame:ship.
236
+
237
+ {If CRITICAL remain:}
238
+ ⛔ Ship still BLOCKED. {N} critical findings need manual action (see above).
239
+
240
+ {If manual actions needed:}
241
+ ⚠️ Manual actions required:
242
+ {numbered list of each manual step}
243
+ ```
244
+
245
+ ## Rules
246
+
247
+ - **ALWAYS create a git checkpoint before making changes**: `git stash` or note current state
248
+ - **NEVER delete .env files** — only remove from git tracking with `git rm --cached`
249
+ - **NEVER auto-rotate secrets** — always tell the user to rotate manually
250
+ - **NEVER run `git filter-repo` automatically** — it rewrites history, user must confirm
251
+ - **ALWAYS verify** each fix after applying it
252
+ - **ALWAYS explain** what was changed and why
253
+ - **For npm audit fix --force**: warn about potential breaking changes before running
254
+
255
+ ## Result
256
+
257
+ - Security findings fixed or documented with manual steps
258
+ - Report updated with fix session
259
+ - STATE.md updated (ship unblocked if CRITICAL resolved)
260
+ - User knows exactly what manual actions remain
@@ -395,8 +395,12 @@ Security audit complete.
395
395
  Critical: {N} | High: {N} | Medium: {N} | Low: {N}
396
396
  Report: .planning/reports/security/security-{date}.md
397
397
 
398
- {If critical: "⛔ Ship BLOCKED. Fix critical findings before /frame:ship."}
399
- {If no critical: "✓ No critical issues. Safe to proceed."}
398
+ {If critical:
399
+ "⛔ Ship BLOCKED. Run /frame:security-fix to fix critical findings."}
400
+ {If high but no critical:
401
+ "⚠️ No critical issues, but HIGH findings need attention. Run /frame:security-fix high."}
402
+ {If no critical and no high:
403
+ "✓ No critical issues. Safe to proceed with /frame:ship."}
400
404
  ```
401
405
 
402
406
  ## Rules