musubi-sdd 5.1.0 → 5.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. package/README.ja.md +106 -48
  2. package/README.md +110 -32
  3. package/bin/musubi-analyze.js +74 -67
  4. package/bin/musubi-browser.js +27 -26
  5. package/bin/musubi-change.js +48 -47
  6. package/bin/musubi-checkpoint.js +10 -7
  7. package/bin/musubi-convert.js +25 -25
  8. package/bin/musubi-costs.js +27 -10
  9. package/bin/musubi-gui.js +52 -46
  10. package/bin/musubi-init.js +1952 -10
  11. package/bin/musubi-orchestrate.js +327 -239
  12. package/bin/musubi-remember.js +69 -56
  13. package/bin/musubi-resolve.js +53 -45
  14. package/bin/musubi-trace.js +51 -22
  15. package/bin/musubi-validate.js +39 -30
  16. package/bin/musubi-workflow.js +33 -34
  17. package/bin/musubi.js +39 -2
  18. package/package.json +1 -1
  19. package/src/agents/agent-loop.js +94 -95
  20. package/src/agents/agentic/code-generator.js +119 -109
  21. package/src/agents/agentic/code-reviewer.js +105 -108
  22. package/src/agents/agentic/index.js +4 -4
  23. package/src/agents/browser/action-executor.js +13 -13
  24. package/src/agents/browser/ai-comparator.js +11 -10
  25. package/src/agents/browser/context-manager.js +6 -6
  26. package/src/agents/browser/index.js +5 -5
  27. package/src/agents/browser/nl-parser.js +31 -46
  28. package/src/agents/browser/screenshot.js +2 -2
  29. package/src/agents/browser/test-generator.js +6 -4
  30. package/src/agents/function-tool.js +71 -65
  31. package/src/agents/index.js +7 -7
  32. package/src/agents/schema-generator.js +98 -94
  33. package/src/analyzers/ast-extractor.js +158 -146
  34. package/src/analyzers/codegraph-auto-update.js +858 -0
  35. package/src/analyzers/complexity-analyzer.js +536 -0
  36. package/src/analyzers/context-optimizer.js +241 -126
  37. package/src/analyzers/impact-analyzer.js +1 -1
  38. package/src/analyzers/large-project-analyzer.js +766 -0
  39. package/src/analyzers/repository-map.js +77 -81
  40. package/src/analyzers/security-analyzer.js +19 -11
  41. package/src/analyzers/stuck-detector.js +19 -17
  42. package/src/converters/index.js +78 -57
  43. package/src/converters/ir/types.js +12 -12
  44. package/src/converters/parsers/musubi-parser.js +134 -126
  45. package/src/converters/parsers/openapi-parser.js +70 -53
  46. package/src/converters/parsers/speckit-parser.js +239 -175
  47. package/src/converters/writers/musubi-writer.js +123 -118
  48. package/src/converters/writers/speckit-writer.js +124 -113
  49. package/src/generators/rust-migration-generator.js +512 -0
  50. package/src/gui/public/index.html +1365 -1211
  51. package/src/gui/server.js +41 -40
  52. package/src/gui/services/file-watcher.js +23 -8
  53. package/src/gui/services/project-scanner.js +26 -20
  54. package/src/gui/services/replanning-service.js +27 -23
  55. package/src/gui/services/traceability-service.js +8 -8
  56. package/src/gui/services/workflow-service.js +14 -7
  57. package/src/index.js +151 -0
  58. package/src/integrations/cicd.js +90 -104
  59. package/src/integrations/codegraph-mcp.js +643 -0
  60. package/src/integrations/documentation.js +142 -103
  61. package/src/integrations/examples.js +95 -80
  62. package/src/integrations/github-client.js +17 -17
  63. package/src/integrations/index.js +5 -5
  64. package/src/integrations/mcp/index.js +21 -21
  65. package/src/integrations/mcp/mcp-context-provider.js +76 -78
  66. package/src/integrations/mcp/mcp-discovery.js +74 -72
  67. package/src/integrations/mcp/mcp-tool-registry.js +99 -94
  68. package/src/integrations/mcp-connector.js +70 -66
  69. package/src/integrations/platforms.js +50 -49
  70. package/src/integrations/tool-discovery.js +37 -31
  71. package/src/llm-providers/anthropic-provider.js +11 -11
  72. package/src/llm-providers/base-provider.js +16 -18
  73. package/src/llm-providers/copilot-provider.js +22 -19
  74. package/src/llm-providers/index.js +26 -25
  75. package/src/llm-providers/ollama-provider.js +11 -11
  76. package/src/llm-providers/openai-provider.js +12 -12
  77. package/src/managers/agent-memory.js +36 -24
  78. package/src/managers/checkpoint-manager.js +4 -8
  79. package/src/managers/delta-spec.js +19 -19
  80. package/src/managers/index.js +13 -4
  81. package/src/managers/memory-condenser.js +35 -45
  82. package/src/managers/repo-skill-manager.js +57 -31
  83. package/src/managers/skill-loader.js +25 -22
  84. package/src/managers/skill-tools.js +36 -72
  85. package/src/managers/workflow.js +30 -22
  86. package/src/monitoring/cost-tracker.js +48 -46
  87. package/src/monitoring/incident-manager.js +116 -106
  88. package/src/monitoring/index.js +144 -134
  89. package/src/monitoring/observability.js +75 -62
  90. package/src/monitoring/quality-dashboard.js +45 -41
  91. package/src/monitoring/release-manager.js +63 -53
  92. package/src/orchestration/agent-skill-binding.js +39 -47
  93. package/src/orchestration/error-handler.js +65 -107
  94. package/src/orchestration/guardrails/base-guardrail.js +26 -24
  95. package/src/orchestration/guardrails/guardrail-rules.js +50 -64
  96. package/src/orchestration/guardrails/index.js +5 -5
  97. package/src/orchestration/guardrails/input-guardrail.js +58 -45
  98. package/src/orchestration/guardrails/output-guardrail.js +104 -81
  99. package/src/orchestration/guardrails/safety-check.js +79 -79
  100. package/src/orchestration/index.js +38 -55
  101. package/src/orchestration/mcp-tool-adapters.js +96 -99
  102. package/src/orchestration/orchestration-engine.js +21 -21
  103. package/src/orchestration/pattern-registry.js +60 -45
  104. package/src/orchestration/patterns/auto.js +34 -47
  105. package/src/orchestration/patterns/group-chat.js +59 -65
  106. package/src/orchestration/patterns/handoff.js +67 -65
  107. package/src/orchestration/patterns/human-in-loop.js +51 -72
  108. package/src/orchestration/patterns/nested.js +25 -40
  109. package/src/orchestration/patterns/sequential.js +35 -34
  110. package/src/orchestration/patterns/swarm.js +63 -56
  111. package/src/orchestration/patterns/triage.js +150 -109
  112. package/src/orchestration/reasoning/index.js +9 -9
  113. package/src/orchestration/reasoning/planning-engine.js +143 -140
  114. package/src/orchestration/reasoning/reasoning-engine.js +206 -144
  115. package/src/orchestration/reasoning/self-correction.js +121 -128
  116. package/src/orchestration/replanning/adaptive-goal-modifier.js +107 -112
  117. package/src/orchestration/replanning/alternative-generator.js +37 -42
  118. package/src/orchestration/replanning/config.js +63 -59
  119. package/src/orchestration/replanning/goal-progress-tracker.js +98 -100
  120. package/src/orchestration/replanning/index.js +24 -20
  121. package/src/orchestration/replanning/plan-evaluator.js +49 -50
  122. package/src/orchestration/replanning/plan-monitor.js +32 -28
  123. package/src/orchestration/replanning/proactive-path-optimizer.js +175 -178
  124. package/src/orchestration/replanning/replan-history.js +33 -26
  125. package/src/orchestration/replanning/replanning-engine.js +106 -108
  126. package/src/orchestration/skill-executor.js +107 -109
  127. package/src/orchestration/skill-registry.js +85 -89
  128. package/src/orchestration/workflow-examples.js +228 -231
  129. package/src/orchestration/workflow-executor.js +65 -68
  130. package/src/orchestration/workflow-orchestrator.js +72 -73
  131. package/src/phase4-integration.js +47 -40
  132. package/src/phase5-integration.js +89 -30
  133. package/src/reporters/coverage-report.js +82 -30
  134. package/src/reporters/hierarchical-reporter.js +498 -0
  135. package/src/reporters/traceability-matrix-report.js +29 -20
  136. package/src/resolvers/issue-resolver.js +43 -31
  137. package/src/steering/advanced-validation.js +133 -124
  138. package/src/steering/auto-updater.js +60 -73
  139. package/src/steering/index.js +6 -6
  140. package/src/steering/quality-metrics.js +41 -35
  141. package/src/steering/steering-auto-update.js +83 -86
  142. package/src/steering/steering-validator.js +98 -106
  143. package/src/steering/template-constraints.js +53 -54
  144. package/src/templates/agents/claude-code/CLAUDE.md +32 -32
  145. package/src/templates/agents/claude-code/skills/agent-assistant/SKILL.md +13 -5
  146. package/src/templates/agents/claude-code/skills/ai-ml-engineer/mlops-guide.md +23 -23
  147. package/src/templates/agents/claude-code/skills/ai-ml-engineer/model-card-template.md +60 -41
  148. package/src/templates/agents/claude-code/skills/api-designer/api-patterns.md +27 -19
  149. package/src/templates/agents/claude-code/skills/api-designer/openapi-template.md +11 -7
  150. package/src/templates/agents/claude-code/skills/bug-hunter/SKILL.md +4 -3
  151. package/src/templates/agents/claude-code/skills/bug-hunter/root-cause-analysis.md +37 -15
  152. package/src/templates/agents/claude-code/skills/change-impact-analyzer/dependency-graph-patterns.md +36 -42
  153. package/src/templates/agents/claude-code/skills/change-impact-analyzer/impact-analysis-template.md +69 -60
  154. package/src/templates/agents/claude-code/skills/cloud-architect/aws-patterns.md +31 -38
  155. package/src/templates/agents/claude-code/skills/cloud-architect/azure-patterns.md +28 -23
  156. package/src/templates/agents/claude-code/skills/code-reviewer/SKILL.md +61 -0
  157. package/src/templates/agents/claude-code/skills/code-reviewer/best-practices.md +27 -0
  158. package/src/templates/agents/claude-code/skills/code-reviewer/review-checklist.md +29 -10
  159. package/src/templates/agents/claude-code/skills/code-reviewer/review-standards.md +29 -24
  160. package/src/templates/agents/claude-code/skills/constitution-enforcer/SKILL.md +8 -6
  161. package/src/templates/agents/claude-code/skills/constitution-enforcer/constitutional-articles.md +62 -26
  162. package/src/templates/agents/claude-code/skills/constitution-enforcer/phase-minus-one-gates.md +35 -16
  163. package/src/templates/agents/claude-code/skills/database-administrator/backup-recovery.md +27 -17
  164. package/src/templates/agents/claude-code/skills/database-administrator/tuning-guide.md +25 -20
  165. package/src/templates/agents/claude-code/skills/database-schema-designer/schema-patterns.md +39 -22
  166. package/src/templates/agents/claude-code/skills/devops-engineer/ci-cd-templates.md +25 -22
  167. package/src/templates/agents/claude-code/skills/issue-resolver/SKILL.md +24 -21
  168. package/src/templates/agents/claude-code/skills/orchestrator/SKILL.md +148 -63
  169. package/src/templates/agents/claude-code/skills/orchestrator/patterns.md +35 -16
  170. package/src/templates/agents/claude-code/skills/orchestrator/selection-matrix.md +69 -64
  171. package/src/templates/agents/claude-code/skills/performance-engineer/optimization-playbook.md +47 -47
  172. package/src/templates/agents/claude-code/skills/performance-optimizer/SKILL.md +69 -0
  173. package/src/templates/agents/claude-code/skills/performance-optimizer/benchmark-template.md +63 -45
  174. package/src/templates/agents/claude-code/skills/performance-optimizer/optimization-patterns.md +33 -35
  175. package/src/templates/agents/claude-code/skills/project-manager/SKILL.md +7 -6
  176. package/src/templates/agents/claude-code/skills/project-manager/agile-ceremonies.md +47 -28
  177. package/src/templates/agents/claude-code/skills/project-manager/project-templates.md +94 -78
  178. package/src/templates/agents/claude-code/skills/quality-assurance/SKILL.md +20 -17
  179. package/src/templates/agents/claude-code/skills/quality-assurance/qa-plan-template.md +63 -49
  180. package/src/templates/agents/claude-code/skills/release-coordinator/SKILL.md +5 -5
  181. package/src/templates/agents/claude-code/skills/release-coordinator/feature-flag-guide.md +30 -26
  182. package/src/templates/agents/claude-code/skills/release-coordinator/release-plan-template.md +67 -35
  183. package/src/templates/agents/claude-code/skills/requirements-analyst/ears-format.md +54 -42
  184. package/src/templates/agents/claude-code/skills/requirements-analyst/validation-rules.md +36 -33
  185. package/src/templates/agents/claude-code/skills/security-auditor/SKILL.md +77 -19
  186. package/src/templates/agents/claude-code/skills/security-auditor/audit-checklists.md +24 -24
  187. package/src/templates/agents/claude-code/skills/security-auditor/owasp-top-10.md +61 -20
  188. package/src/templates/agents/claude-code/skills/security-auditor/vulnerability-patterns.md +43 -11
  189. package/src/templates/agents/claude-code/skills/site-reliability-engineer/SKILL.md +1 -0
  190. package/src/templates/agents/claude-code/skills/site-reliability-engineer/incident-response-template.md +55 -25
  191. package/src/templates/agents/claude-code/skills/site-reliability-engineer/observability-patterns.md +78 -68
  192. package/src/templates/agents/claude-code/skills/site-reliability-engineer/slo-sli-guide.md +73 -53
  193. package/src/templates/agents/claude-code/skills/software-developer/solid-principles.md +83 -37
  194. package/src/templates/agents/claude-code/skills/software-developer/test-first-workflow.md +38 -31
  195. package/src/templates/agents/claude-code/skills/steering/SKILL.md +1 -0
  196. package/src/templates/agents/claude-code/skills/steering/auto-update-rules.md +31 -0
  197. package/src/templates/agents/claude-code/skills/system-architect/adr-template.md +25 -7
  198. package/src/templates/agents/claude-code/skills/system-architect/c4-model-guide.md +74 -61
  199. package/src/templates/agents/claude-code/skills/technical-writer/doc-templates/documentation-templates.md +70 -52
  200. package/src/templates/agents/claude-code/skills/test-engineer/SKILL.md +2 -0
  201. package/src/templates/agents/claude-code/skills/test-engineer/ears-test-mapping.md +75 -71
  202. package/src/templates/agents/claude-code/skills/test-engineer/test-types.md +85 -63
  203. package/src/templates/agents/claude-code/skills/traceability-auditor/coverage-matrix-template.md +39 -36
  204. package/src/templates/agents/claude-code/skills/traceability-auditor/gap-detection-rules.md +22 -17
  205. package/src/templates/agents/claude-code/skills/ui-ux-designer/SKILL.md +1 -0
  206. package/src/templates/agents/claude-code/skills/ui-ux-designer/accessibility-guidelines.md +49 -75
  207. package/src/templates/agents/claude-code/skills/ui-ux-designer/design-system-components.md +71 -59
  208. package/src/templates/agents/codex/AGENTS.md +74 -42
  209. package/src/templates/agents/cursor/AGENTS.md +74 -42
  210. package/src/templates/agents/gemini-cli/GEMINI.md +74 -42
  211. package/src/templates/agents/github-copilot/AGENTS.md +83 -51
  212. package/src/templates/agents/qwen-code/QWEN.md +74 -42
  213. package/src/templates/agents/windsurf/AGENTS.md +74 -42
  214. package/src/templates/architectures/README.md +41 -0
  215. package/src/templates/architectures/clean-architecture/README.md +113 -0
  216. package/src/templates/architectures/event-driven/README.md +162 -0
  217. package/src/templates/architectures/hexagonal/README.md +130 -0
  218. package/src/templates/index.js +6 -1
  219. package/src/templates/locale-manager.js +16 -16
  220. package/src/templates/shared/delta-spec-template.md +20 -13
  221. package/src/templates/shared/github-actions/musubi-issue-resolver.yml +5 -5
  222. package/src/templates/shared/github-actions/musubi-security-check.yml +3 -3
  223. package/src/templates/shared/github-actions/musubi-validate.yml +4 -4
  224. package/src/templates/shared/steering/structure.md +95 -0
  225. package/src/templates/skills/browser-agent.md +21 -16
  226. package/src/templates/skills/web-gui.md +8 -0
  227. package/src/templates/template-constraints.js +50 -53
  228. package/src/validators/advanced-validation.js +30 -36
  229. package/src/validators/constitutional-validator.js +77 -73
  230. package/src/validators/critic-system.js +49 -59
  231. package/src/validators/delta-format.js +59 -55
  232. package/src/validators/traceability-validator.js +7 -11
@@ -9,28 +9,32 @@ The OWASP Top 10 represents the most critical security risks to web applications
9
9
  ## A01:2021 - Broken Access Control
10
10
 
11
11
  ### Description
12
+
12
13
  Users can act outside their intended permissions.
13
14
 
14
15
  ### Examples
16
+
15
17
  - Accessing other users' data by modifying URL
16
18
  - Privilege escalation
17
19
  - CORS misconfiguration
18
20
 
19
21
  ### Prevention
22
+
20
23
  ```typescript
21
24
  // Always verify authorization
22
25
  async function getUserData(userId: string, requesterId: string) {
23
26
  const user = await userRepo.findById(userId);
24
-
27
+
25
28
  if (user.id !== requesterId && !isAdmin(requesterId)) {
26
29
  throw new ForbiddenError('Access denied');
27
30
  }
28
-
31
+
29
32
  return user;
30
33
  }
31
34
  ```
32
35
 
33
36
  ### Checklist
37
+
34
38
  - [ ] Deny by default
35
39
  - [ ] Implement access control at server side
36
40
  - [ ] Validate user permissions for every request
@@ -42,14 +46,17 @@ async function getUserData(userId: string, requesterId: string) {
42
46
  ## A02:2021 - Cryptographic Failures
43
47
 
44
48
  ### Description
49
+
45
50
  Failures related to cryptography leading to data exposure.
46
51
 
47
52
  ### Examples
53
+
48
54
  - Transmitting data in clear text
49
55
  - Using weak algorithms (MD5, SHA1)
50
56
  - Hardcoded secrets
51
57
 
52
58
  ### Prevention
59
+
53
60
  ```typescript
54
61
  // Use strong password hashing
55
62
  import bcrypt from 'bcrypt';
@@ -66,6 +73,7 @@ const apiKey = process.env.API_KEY; // Not hardcoded
66
73
  ```
67
74
 
68
75
  ### Checklist
76
+
69
77
  - [ ] Classify data by sensitivity
70
78
  - [ ] Use TLS for all data in transit
71
79
  - [ ] Use strong, up-to-date algorithms
@@ -77,15 +85,18 @@ const apiKey = process.env.API_KEY; // Not hardcoded
77
85
  ## A03:2021 - Injection
78
86
 
79
87
  ### Description
88
+
80
89
  Untrusted data is sent to an interpreter as part of a command or query.
81
90
 
82
91
  ### Examples
92
+
83
93
  - SQL injection
84
94
  - NoSQL injection
85
95
  - Command injection
86
96
  - LDAP injection
87
97
 
88
98
  ### Prevention
99
+
89
100
  ```typescript
90
101
  // BAD: SQL Injection vulnerable
91
102
  const query = `SELECT * FROM users WHERE id = '${userId}'`;
@@ -98,6 +109,7 @@ const user = await userRepo.findOne({ where: { id: userId } });
98
109
  ```
99
110
 
100
111
  ### Checklist
112
+
101
113
  - [ ] Use parameterized queries
102
114
  - [ ] Use ORM/ODM frameworks
103
115
  - [ ] Validate and sanitize input
@@ -109,14 +121,17 @@ const user = await userRepo.findOne({ where: { id: userId } });
109
121
  ## A04:2021 - Insecure Design
110
122
 
111
123
  ### Description
124
+
112
125
  Flaws in design that cannot be fixed by implementation.
113
126
 
114
127
  ### Examples
128
+
115
129
  - Missing rate limiting
116
130
  - No anti-automation
117
131
  - Insufficient fraud controls
118
132
 
119
133
  ### Prevention
134
+
120
135
  ```typescript
121
136
  // Implement rate limiting
122
137
  import rateLimit from 'express-rate-limit';
@@ -124,13 +139,14 @@ import rateLimit from 'express-rate-limit';
124
139
  const loginLimiter = rateLimit({
125
140
  windowMs: 15 * 60 * 1000, // 15 minutes
126
141
  max: 5, // 5 attempts
127
- message: 'Too many login attempts'
142
+ message: 'Too many login attempts',
128
143
  });
129
144
 
130
145
  app.post('/login', loginLimiter, loginHandler);
131
146
  ```
132
147
 
133
148
  ### Checklist
149
+
134
150
  - [ ] Threat modeling during design
135
151
  - [ ] Security requirements defined
136
152
  - [ ] Rate limiting implemented
@@ -141,15 +157,18 @@ app.post('/login', loginLimiter, loginHandler);
141
157
  ## A05:2021 - Security Misconfiguration
142
158
 
143
159
  ### Description
160
+
144
161
  Insecure default configurations or missing security hardening.
145
162
 
146
163
  ### Examples
164
+
147
165
  - Default credentials
148
166
  - Unnecessary features enabled
149
167
  - Verbose error messages
150
168
  - Missing security headers
151
169
 
152
170
  ### Prevention
171
+
153
172
  ```typescript
154
173
  // Add security headers
155
174
  import helmet from 'helmet';
@@ -165,6 +184,7 @@ if (process.env.NODE_ENV === 'production') {
165
184
  ```
166
185
 
167
186
  ### Checklist
187
+
168
188
  - [ ] Remove unused features
169
189
  - [ ] Disable default accounts
170
190
  - [ ] Set security headers
@@ -176,9 +196,11 @@ if (process.env.NODE_ENV === 'production') {
176
196
  ## A06:2021 - Vulnerable Components
177
197
 
178
198
  ### Description
199
+
179
200
  Using components with known vulnerabilities.
180
201
 
181
202
  ### Prevention
203
+
182
204
  ```bash
183
205
  # Check for vulnerabilities
184
206
  npm audit
@@ -191,6 +213,7 @@ pip install --upgrade
191
213
  ```
192
214
 
193
215
  ### Checklist
216
+
194
217
  - [ ] Remove unused dependencies
195
218
  - [ ] Use only official sources
196
219
  - [ ] Monitor for vulnerabilities
@@ -201,38 +224,46 @@ pip install --upgrade
201
224
  ## A07:2021 - Authentication Failures
202
225
 
203
226
  ### Description
227
+
204
228
  Weak authentication mechanisms.
205
229
 
206
230
  ### Examples
231
+
207
232
  - Weak passwords allowed
208
233
  - Credential stuffing
209
234
  - Missing MFA
210
235
  - Session fixation
211
236
 
212
237
  ### Prevention
238
+
213
239
  ```typescript
214
240
  // Validate password strength
215
241
  function validatePassword(password: string): boolean {
216
- return password.length >= 12 &&
217
- /[A-Z]/.test(password) &&
218
- /[a-z]/.test(password) &&
219
- /[0-9]/.test(password) &&
220
- /[^A-Za-z0-9]/.test(password);
242
+ return (
243
+ password.length >= 12 &&
244
+ /[A-Z]/.test(password) &&
245
+ /[a-z]/.test(password) &&
246
+ /[0-9]/.test(password) &&
247
+ /[^A-Za-z0-9]/.test(password)
248
+ );
221
249
  }
222
250
 
223
251
  // Secure session configuration
224
- app.use(session({
225
- secret: process.env.SESSION_SECRET,
226
- cookie: {
227
- httpOnly: true,
228
- secure: true,
229
- sameSite: 'strict',
230
- maxAge: 3600000 // 1 hour
231
- }
232
- }));
252
+ app.use(
253
+ session({
254
+ secret: process.env.SESSION_SECRET,
255
+ cookie: {
256
+ httpOnly: true,
257
+ secure: true,
258
+ sameSite: 'strict',
259
+ maxAge: 3600000, // 1 hour
260
+ },
261
+ })
262
+ );
233
263
  ```
234
264
 
235
265
  ### Checklist
266
+
236
267
  - [ ] Enforce strong passwords
237
268
  - [ ] Implement MFA
238
269
  - [ ] Rate limit authentication
@@ -244,26 +275,30 @@ app.use(session({
244
275
  ## A08:2021 - Software and Data Integrity Failures
245
276
 
246
277
  ### Description
278
+
247
279
  Failures related to code and infrastructure that doesn't protect against integrity violations.
248
280
 
249
281
  ### Examples
282
+
250
283
  - Unsigned software updates
251
284
  - Insecure CI/CD pipelines
252
285
  - Deserialization attacks
253
286
 
254
287
  ### Prevention
288
+
255
289
  ```typescript
256
290
  // Verify package integrity
257
291
  // package-lock.json with integrity hashes
258
292
 
259
293
  // Subresource Integrity for CDN
260
- <script src="https://cdn.example.com/lib.js"
261
- integrity="sha384-hash..."
294
+ <script src="https://cdn.example.com/lib.js"
295
+ integrity="sha384-hash..."
262
296
  crossorigin="anonymous">
263
297
  </script>
264
298
  ```
265
299
 
266
300
  ### Checklist
301
+
267
302
  - [ ] Use signed packages
268
303
  - [ ] Verify integrity hashes
269
304
  - [ ] Secure CI/CD pipeline
@@ -274,9 +309,11 @@ Failures related to code and infrastructure that doesn't protect against integri
274
309
  ## A09:2021 - Security Logging and Monitoring Failures
275
310
 
276
311
  ### Description
312
+
277
313
  Insufficient logging and monitoring to detect attacks.
278
314
 
279
315
  ### Prevention
316
+
280
317
  ```typescript
281
318
  // Log security events
282
319
  logger.warn('Login failure', {
@@ -284,7 +321,7 @@ logger.warn('Login failure', {
284
321
  email: email,
285
322
  ip: req.ip,
286
323
  userAgent: req.headers['user-agent'],
287
- timestamp: new Date().toISOString()
324
+ timestamp: new Date().toISOString(),
288
325
  });
289
326
 
290
327
  // Alert on suspicious activity
@@ -294,6 +331,7 @@ if (failedAttempts >= 5) {
294
331
  ```
295
332
 
296
333
  ### Checklist
334
+
297
335
  - [ ] Log authentication events
298
336
  - [ ] Log access control failures
299
337
  - [ ] Centralized log management
@@ -305,9 +343,11 @@ if (failedAttempts >= 5) {
305
343
  ## A10:2021 - Server-Side Request Forgery (SSRF)
306
344
 
307
345
  ### Description
346
+
308
347
  Application fetches remote resources without validating the URL.
309
348
 
310
349
  ### Prevention
350
+
311
351
  ```typescript
312
352
  // Validate and allowlist URLs
313
353
  const ALLOWED_HOSTS = ['api.trusted.com', 'cdn.example.com'];
@@ -326,6 +366,7 @@ async function fetchRemote(url: string) {
326
366
  ```
327
367
 
328
368
  ### Checklist
369
+
329
370
  - [ ] Validate and sanitize URLs
330
371
  - [ ] Use allowlists
331
372
  - [ ] Block internal addresses
@@ -11,6 +11,7 @@ Common vulnerability patterns and how to identify them in code review.
11
11
  ### Weak Password Storage
12
12
 
13
13
  **Pattern**:
14
+
14
15
  ```typescript
15
16
  // ❌ BAD: Plain text or weak hashing
16
17
  const passwordHash = md5(password);
@@ -18,6 +19,7 @@ const passwordHash = sha1(password);
18
19
  ```
19
20
 
20
21
  **Fix**:
22
+
21
23
  ```typescript
22
24
  // ✅ GOOD: Strong adaptive hashing
23
25
  const passwordHash = await bcrypt.hash(password, 12);
@@ -26,6 +28,7 @@ const passwordHash = await bcrypt.hash(password, 12);
26
28
  ### Missing Rate Limiting
27
29
 
28
30
  **Pattern**:
31
+
29
32
  ```typescript
30
33
  // ❌ BAD: No rate limiting on login
31
34
  app.post('/login', async (req, res) => {
@@ -35,6 +38,7 @@ app.post('/login', async (req, res) => {
35
38
  ```
36
39
 
37
40
  **Fix**:
41
+
38
42
  ```typescript
39
43
  // ✅ GOOD: Rate limited
40
44
  app.post('/login', rateLimiter({ max: 5, windowMs: 60000 }), ...);
@@ -47,12 +51,14 @@ app.post('/login', rateLimiter({ max: 5, windowMs: 60000 }), ...);
47
51
  ### SQL Injection
48
52
 
49
53
  **Pattern**:
54
+
50
55
  ```typescript
51
56
  // ❌ BAD: String concatenation
52
57
  const query = `SELECT * FROM users WHERE id = '${userId}'`;
53
58
  ```
54
59
 
55
60
  **Fix**:
61
+
56
62
  ```typescript
57
63
  // ✅ GOOD: Parameterized query
58
64
  const result = await db.query('SELECT * FROM users WHERE id = $1', [userId]);
@@ -61,12 +67,14 @@ const result = await db.query('SELECT * FROM users WHERE id = $1', [userId]);
61
67
  ### Command Injection
62
68
 
63
69
  **Pattern**:
70
+
64
71
  ```typescript
65
72
  // ❌ BAD: User input in shell command
66
73
  exec(`convert ${userFilename} output.png`);
67
74
  ```
68
75
 
69
76
  **Fix**:
77
+
70
78
  ```typescript
71
79
  // ✅ GOOD: Validate and escape
72
80
  const sanitizedName = sanitize(userFilename);
@@ -76,15 +84,17 @@ execFile('convert', [sanitizedName, 'output.png']);
76
84
  ### NoSQL Injection
77
85
 
78
86
  **Pattern**:
87
+
79
88
  ```typescript
80
89
  // ❌ BAD: Object injection in MongoDB
81
- const user = await User.findOne({
90
+ const user = await User.findOne({
82
91
  username: req.body.username,
83
- password: req.body.password // Could be { $gt: '' }
92
+ password: req.body.password, // Could be { $gt: '' }
84
93
  });
85
94
  ```
86
95
 
87
96
  **Fix**:
97
+
88
98
  ```typescript
89
99
  // ✅ GOOD: Type validation
90
100
  const username = String(req.body.username);
@@ -98,12 +108,14 @@ const password = String(req.body.password);
98
108
  ### Reflected XSS
99
109
 
100
110
  **Pattern**:
111
+
101
112
  ```typescript
102
113
  // ❌ BAD: User input in response
103
114
  res.send(`<h1>Search: ${req.query.q}</h1>`);
104
115
  ```
105
116
 
106
117
  **Fix**:
118
+
107
119
  ```typescript
108
120
  // ✅ GOOD: Escape output
109
121
  res.send(`<h1>Search: ${escapeHtml(req.query.q)}</h1>`);
@@ -112,12 +124,14 @@ res.send(`<h1>Search: ${escapeHtml(req.query.q)}</h1>`);
112
124
  ### Stored XSS
113
125
 
114
126
  **Pattern**:
127
+
115
128
  ```typescript
116
129
  // ❌ BAD: Unescaped database content
117
130
  <div dangerouslySetInnerHTML={{ __html: user.bio }} />
118
131
  ```
119
132
 
120
133
  **Fix**:
134
+
121
135
  ```typescript
122
136
  // ✅ GOOD: Sanitize HTML
123
137
  <div dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(user.bio) }} />
@@ -130,21 +144,23 @@ res.send(`<h1>Search: ${escapeHtml(req.query.q)}</h1>`);
130
144
  ### IDOR (Insecure Direct Object Reference)
131
145
 
132
146
  **Pattern**:
147
+
133
148
  ```typescript
134
149
  // ❌ BAD: No ownership check
135
150
  app.get('/documents/:id', async (req, res) => {
136
151
  const doc = await Document.findById(req.params.id);
137
- res.json(doc); // Anyone can access any document
152
+ res.json(doc); // Anyone can access any document
138
153
  });
139
154
  ```
140
155
 
141
156
  **Fix**:
157
+
142
158
  ```typescript
143
159
  // ✅ GOOD: Verify ownership
144
160
  app.get('/documents/:id', async (req, res) => {
145
161
  const doc = await Document.findOne({
146
162
  _id: req.params.id,
147
- owner: req.user.id // Only owner can access
163
+ owner: req.user.id, // Only owner can access
148
164
  });
149
165
  if (!doc) return res.status(404).end();
150
166
  res.json(doc);
@@ -154,21 +170,23 @@ app.get('/documents/:id', async (req, res) => {
154
170
  ### Privilege Escalation
155
171
 
156
172
  **Pattern**:
173
+
157
174
  ```typescript
158
175
  // ❌ BAD: Client-controlled role
159
176
  const user = await User.create({
160
177
  ...req.body,
161
- role: req.body.role // User can set admin role!
178
+ role: req.body.role, // User can set admin role!
162
179
  });
163
180
  ```
164
181
 
165
182
  **Fix**:
183
+
166
184
  ```typescript
167
185
  // ✅ GOOD: Server-controlled role
168
186
  const user = await User.create({
169
187
  name: req.body.name,
170
188
  email: req.body.email,
171
- role: 'user' // Default role, not from request
189
+ role: 'user', // Default role, not from request
172
190
  });
173
191
  ```
174
192
 
@@ -179,6 +197,7 @@ const user = await User.create({
179
197
  ### Hardcoded Secrets
180
198
 
181
199
  **Pattern**:
200
+
182
201
  ```typescript
183
202
  // ❌ BAD: Secrets in code
184
203
  const API_KEY = 'sk_live_abc123xyz';
@@ -186,6 +205,7 @@ const dbPassword = 'admin123';
186
205
  ```
187
206
 
188
207
  **Fix**:
208
+
189
209
  ```typescript
190
210
  // ✅ GOOD: Environment variables
191
211
  const API_KEY = process.env.API_KEY;
@@ -195,6 +215,7 @@ const dbPassword = process.env.DB_PASSWORD;
195
215
  ### Verbose Error Messages
196
216
 
197
217
  **Pattern**:
218
+
198
219
  ```typescript
199
220
  // ❌ BAD: Stack trace to client
200
221
  app.use((err, req, res, next) => {
@@ -203,10 +224,11 @@ app.use((err, req, res, next) => {
203
224
  ```
204
225
 
205
226
  **Fix**:
227
+
206
228
  ```typescript
207
229
  // ✅ GOOD: Generic error to client
208
230
  app.use((err, req, res, next) => {
209
- logger.error(err); // Log full error
231
+ logger.error(err); // Log full error
210
232
  res.status(500).json({ error: 'Internal server error' });
211
233
  });
212
234
  ```
@@ -218,20 +240,22 @@ app.use((err, req, res, next) => {
218
240
  ### Missing CSRF Token
219
241
 
220
242
  **Pattern**:
243
+
221
244
  ```html
222
245
  <!-- ❌ BAD: No CSRF protection -->
223
246
  <form action="/transfer" method="POST">
224
- <input name="amount" value="1000">
225
- <input name="to" value="attacker">
247
+ <input name="amount" value="1000" />
248
+ <input name="to" value="attacker" />
226
249
  </form>
227
250
  ```
228
251
 
229
252
  **Fix**:
253
+
230
254
  ```html
231
255
  <!-- ✅ GOOD: CSRF token included -->
232
256
  <form action="/transfer" method="POST">
233
- <input type="hidden" name="_csrf" value="{{csrfToken}}">
234
- <input name="amount" value="1000">
257
+ <input type="hidden" name="_csrf" value="{{csrfToken}}" />
258
+ <input name="amount" value="1000" />
235
259
  </form>
236
260
  ```
237
261
 
@@ -242,6 +266,7 @@ app.use((err, req, res, next) => {
242
266
  ### Outdated Packages
243
267
 
244
268
  **Detection**:
269
+
245
270
  ```bash
246
271
  npm audit
247
272
  snyk test
@@ -249,6 +274,7 @@ pip-audit
249
274
  ```
250
275
 
251
276
  **Prevention**:
277
+
252
278
  ```json
253
279
  // package.json
254
280
  {
@@ -263,33 +289,39 @@ pip-audit
263
289
  ## Code Review Security Checklist
264
290
 
265
291
  ### Input Handling
292
+
266
293
  - [ ] All user input validated
267
294
  - [ ] Type checking enforced
268
295
  - [ ] Length limits applied
269
296
  - [ ] Special characters escaped
270
297
 
271
298
  ### Authentication
299
+
272
300
  - [ ] Strong password hashing (bcrypt/Argon2)
273
301
  - [ ] Rate limiting on auth endpoints
274
302
  - [ ] Secure session management
275
303
  - [ ] MFA where appropriate
276
304
 
277
305
  ### Authorization
306
+
278
307
  - [ ] Ownership verified for resources
279
308
  - [ ] Roles checked on server side
280
309
  - [ ] Deny by default policy
281
310
 
282
311
  ### Output
312
+
283
313
  - [ ] HTML escaped for display
284
314
  - [ ] JSON properly encoded
285
315
  - [ ] Error messages sanitized
286
316
 
287
317
  ### Data Protection
318
+
288
319
  - [ ] Secrets in environment variables
289
320
  - [ ] Sensitive data encrypted
290
321
  - [ ] TLS for all connections
291
322
 
292
323
  ### Dependencies
324
+
293
325
  - [ ] No known vulnerabilities
294
326
  - [ ] From trusted sources
295
327
  - [ ] Minimal and necessary
@@ -49,6 +49,7 @@ musubi-gui status
49
49
  ```
50
50
 
51
51
  **ダッシュボード機能**:
52
+
52
53
  - ワークフローステータスのリアルタイム可視化
53
54
  - 要件 → 設計 → タスク → コード トレーサビリティマトリックス
54
55
  - SDD Stage 進捗トラッキング