musubix 2.1.0 → 2.2.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 +44 -310
- package/bin/musubix.js +4 -12
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +73 -0
- package/dist/index.js.map +1 -0
- package/package.json +49 -72
- package/.github/AGENTS.md +0 -242
- package/.github/prompts/sdd-change-apply.prompt.md +0 -283
- package/.github/prompts/sdd-change-archive.prompt.md +0 -241
- package/.github/prompts/sdd-change-init.prompt.md +0 -269
- package/.github/prompts/sdd-design.prompt.md +0 -250
- package/.github/prompts/sdd-implement.prompt.md +0 -387
- package/.github/prompts/sdd-requirements.prompt.md +0 -193
- package/.github/prompts/sdd-review.prompt.md +0 -155
- package/.github/prompts/sdd-security.prompt.md +0 -228
- package/.github/prompts/sdd-steering.prompt.md +0 -269
- package/.github/prompts/sdd-tasks.prompt.md +0 -255
- package/.github/prompts/sdd-test.prompt.md +0 -230
- package/.github/prompts/sdd-validate.prompt.md +0 -304
- package/.github/skills/musubix-adr-generation/SKILL.md +0 -209
- package/.github/skills/musubix-best-practices/SKILL.md +0 -315
- package/.github/skills/musubix-c4-design/SKILL.md +0 -162
- package/.github/skills/musubix-code-generation/SKILL.md +0 -229
- package/.github/skills/musubix-domain-inference/SKILL.md +0 -196
- package/.github/skills/musubix-ears-validation/SKILL.md +0 -161
- package/.github/skills/musubix-sdd-workflow/SKILL.md +0 -210
- package/.github/skills/musubix-test-generation/SKILL.md +0 -212
- package/.github/skills/musubix-traceability/SKILL.md +0 -141
- package/AGENTS.md +0 -622
- package/LICENSE +0 -21
- package/README.ja.md +0 -302
- package/bin/musubix-mcp.js +0 -19
- package/docs/API-REFERENCE.md +0 -1425
- package/docs/GITHUB-ACTIONS-NPM-SETUP.md +0 -132
- package/docs/INSTALL-GUIDE.ja.md +0 -459
- package/docs/INSTALL-GUIDE.md +0 -459
- package/docs/MUSUBI-enhancement_roadmap_20260105.md +0 -651
- package/docs/MUSUBIv1.6.1-enhancement_roadmap_20260105.md +0 -291
- package/docs/ROADMAP-v1.5.md +0 -116
- package/docs/SwarmCoding.md +0 -1284
- package/docs/Test-prompt.md +0 -105
- package/docs/USER-GUIDE-v1.8.0.md +0 -2371
- package/docs/USER-GUIDE.ja.md +0 -2147
- package/docs/USER-GUIDE.md +0 -2652
- package/docs/adr/0001-real-time-pattern-learning-architecture-for-v1-5-0.md +0 -75
- package/docs/adr/0002-pattern-sharing-protocol-for-cross-team-collaborat.md +0 -79
- package/docs/adr/0003-owl-2-rl-implementation-strategy-for-advanced-infe.md +0 -90
- package/docs/evolution-from-musubi-to-musubix.md +0 -2168
- package/docs/getting-started-with-sdd.md +0 -1602
- package/docs/overview/MUSUBIX-Core.md +0 -671
- package/docs/overview/MUSUBIX-FormalVerify.md +0 -566
- package/docs/overview/MUSUBIX-Learning.md +0 -837
- package/docs/overview/MUSUBIX-MCP-Server.md +0 -535
- package/docs/overview/MUSUBIX-Overview.md +0 -264
- package/docs/overview/MUSUBIX-Phase1-Complete.md +0 -271
- package/docs/overview/MUSUBIX-Phase2-Complete.md +0 -310
- package/docs/overview/MUSUBIX-Roadmap-v2.md +0 -399
- package/docs/overview/MUSUBIX-Security-Plan.md +0 -939
- package/docs/overview/MUSUBIX-Security.md +0 -891
- package/docs/overview/MUSUBIX-YATA.md +0 -666
- package/docs/overview/Neuro-SymbolicAI.md +0 -159
- package/scripts/generate-quality-gate-report.ts +0 -106
- package/scripts/postinstall.js +0 -94
- package/steering/.musubi-version +0 -1
- package/steering/product.ja.md +0 -572
- package/steering/project.yml +0 -66
- package/steering/rules/constitution.md +0 -412
- package/steering/structure.ja.md +0 -503
- package/steering/tech.ja.md +0 -208
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
# MUSUBIX Requirements Command
|
|
2
|
-
|
|
3
|
-
Create EARS-format requirements specification through interactive dialogue.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## Instructions for AI Agent
|
|
8
|
-
|
|
9
|
-
You are executing the `musubix requirements [feature-name]` command to create a requirements specification.
|
|
10
|
-
|
|
11
|
-
### Command Format
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
npx musubix requirements analyze authentication
|
|
15
|
-
npx musubix requirements validate spec.md
|
|
16
|
-
npx musubix requirements map spec.md
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
### Your Task
|
|
20
|
-
|
|
21
|
-
**CRITICAL**: Before generating requirements, engage in an interactive 1-on-1 dialogue with the user to uncover the TRUE PURPOSE behind their request.
|
|
22
|
-
|
|
23
|
-
### Output Directory
|
|
24
|
-
|
|
25
|
-
**Requirements documents are saved to**: `storage/specs/`
|
|
26
|
-
|
|
27
|
-
- File: `storage/specs/REQ-{{FEATURE}}-001.md`
|
|
28
|
-
|
|
29
|
-
---
|
|
30
|
-
|
|
31
|
-
## Process
|
|
32
|
-
|
|
33
|
-
### 1. Read Steering Context (Article VI)
|
|
34
|
-
|
|
35
|
-
**IMPORTANT**: Before starting, read steering files to understand project context:
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
# Read these files first
|
|
39
|
-
steering/product.ja.md # Business context, users, goals
|
|
40
|
-
steering/structure.ja.md # Architecture patterns
|
|
41
|
-
steering/tech.ja.md # Technology stack
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
**Extract**:
|
|
45
|
-
|
|
46
|
-
- Target users
|
|
47
|
-
- Product goals
|
|
48
|
-
- Existing architecture patterns
|
|
49
|
-
- Technology constraints (TypeScript, Node.js 20+)
|
|
50
|
-
|
|
51
|
-
---
|
|
52
|
-
|
|
53
|
-
### 2. Interactive True Purpose Discovery
|
|
54
|
-
|
|
55
|
-
**CRITICAL RULE**: Ask ONE question at a time, then STOP and WAIT.
|
|
56
|
-
|
|
57
|
-
#### Question Sequence
|
|
58
|
-
|
|
59
|
-
**Turn 1**: WHY question
|
|
60
|
-
```
|
|
61
|
-
この機能で解決したい『本当の課題』は何ですか?
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
**Turn 2**: WHO question
|
|
65
|
-
```
|
|
66
|
-
この機能を最も必要としているのは誰ですか?
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
**Turn 3**: WHAT-IF question
|
|
70
|
-
```
|
|
71
|
-
もしこの機能が完璧に動作したら、何が変わりますか?
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
**Turn 4**: CONSTRAINT question
|
|
75
|
-
```
|
|
76
|
-
この機能で『絶対にやってはいけないこと』はありますか?
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
**Turn 5**: SUCCESS CRITERIA question
|
|
80
|
-
```
|
|
81
|
-
この機能が『成功した』と言えるのはどんな状態ですか?
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
---
|
|
85
|
-
|
|
86
|
-
### 3. Apply EARS Format (Article IV)
|
|
87
|
-
|
|
88
|
-
**CRITICAL**: All requirements MUST use one of 5 EARS patterns.
|
|
89
|
-
|
|
90
|
-
| Pattern | Syntax | Usage |
|
|
91
|
-
|---------|--------|-------|
|
|
92
|
-
| **Ubiquitous** | `The [system] SHALL [action]` | Always-active features |
|
|
93
|
-
| **Event-driven** | `WHEN [event], the [system] SHALL [action]` | User action triggers |
|
|
94
|
-
| **State-driven** | `WHILE [state], the [system] SHALL [action]` | Continuous conditions |
|
|
95
|
-
| **Unwanted** | `IF [error], THEN the [system] SHALL [action]` | Error handling |
|
|
96
|
-
| **Optional** | `WHERE [feature], the [system] SHALL [action]` | Feature flags |
|
|
97
|
-
|
|
98
|
-
---
|
|
99
|
-
|
|
100
|
-
### 4. Generate Requirements Document
|
|
101
|
-
|
|
102
|
-
**Template**:
|
|
103
|
-
|
|
104
|
-
```markdown
|
|
105
|
-
# Requirements Specification: {{FEATURE_NAME}}
|
|
106
|
-
|
|
107
|
-
**Document ID**: REQ-{{FEATURE}}-001
|
|
108
|
-
**Version**: 1.0.0
|
|
109
|
-
**Date**: {{DATE}}
|
|
110
|
-
**Status**: Draft
|
|
111
|
-
|
|
112
|
-
## Overview
|
|
113
|
-
|
|
114
|
-
- **Purpose**: [True purpose discovered through dialogue]
|
|
115
|
-
- **Scope**: [In/Out scope]
|
|
116
|
-
- **Package**: packages/core/ or packages/mcp-server/ or packages/yata-client/
|
|
117
|
-
|
|
118
|
-
## Stakeholders
|
|
119
|
-
|
|
120
|
-
| Role | Description | Needs |
|
|
121
|
-
|------|-------------|-------|
|
|
122
|
-
| Developer | Uses MUSUBIX CLI | Efficient workflow |
|
|
123
|
-
|
|
124
|
-
## Functional Requirements
|
|
125
|
-
|
|
126
|
-
### REQ-{{COMPONENT}}-001: [Title]
|
|
127
|
-
|
|
128
|
-
**EARS Pattern**: [Pattern name]
|
|
129
|
-
|
|
130
|
-
> [EARS statement]
|
|
131
|
-
|
|
132
|
-
**Priority**: P0/P1/P2/P3
|
|
133
|
-
**Acceptance Criteria**:
|
|
134
|
-
- [ ] [Criterion 1]
|
|
135
|
-
- [ ] [Criterion 2]
|
|
136
|
-
|
|
137
|
-
**Traceability**: → DES-{{FEATURE}}-001
|
|
138
|
-
|
|
139
|
-
## Non-Functional Requirements
|
|
140
|
-
|
|
141
|
-
### REQ-PERF-001: Performance
|
|
142
|
-
The system SHALL respond within 200ms for 95% of requests.
|
|
143
|
-
|
|
144
|
-
### REQ-SEC-001: Security
|
|
145
|
-
The system SHALL prevent OWASP Top 10 vulnerabilities.
|
|
146
|
-
|
|
147
|
-
## Traceability Matrix
|
|
148
|
-
|
|
149
|
-
| Requirement | Design | Task | Test |
|
|
150
|
-
|-------------|--------|------|------|
|
|
151
|
-
| REQ-{{COMPONENT}}-001 | DES-{{FEATURE}}-001 | TSK-{{FEATURE}}-001 | TBD |
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
---
|
|
155
|
-
|
|
156
|
-
### 5. Requirements ID Format
|
|
157
|
-
|
|
158
|
-
**Format**: `REQ-[COMPONENT]-[NUMBER]`
|
|
159
|
-
|
|
160
|
-
**Examples**:
|
|
161
|
-
- `REQ-CLI-001` - CLI component
|
|
162
|
-
- `REQ-MCP-001` - MCP Server component
|
|
163
|
-
- `REQ-YATA-001` - YATA Client component
|
|
164
|
-
- `REQ-CORE-001` - Core library component
|
|
165
|
-
|
|
166
|
-
---
|
|
167
|
-
|
|
168
|
-
### 6. Quality Checklist
|
|
169
|
-
|
|
170
|
-
Each requirement MUST have:
|
|
171
|
-
|
|
172
|
-
- [ ] Unique ID (REQ-COMPONENT-NNN)
|
|
173
|
-
- [ ] EARS pattern (one of 5)
|
|
174
|
-
- [ ] Clear SHALL statement
|
|
175
|
-
- [ ] Testable acceptance criteria
|
|
176
|
-
- [ ] Priority (P0/P1/P2/P3)
|
|
177
|
-
- [ ] Status (Draft initially)
|
|
178
|
-
|
|
179
|
-
---
|
|
180
|
-
|
|
181
|
-
### 7. MCP Tool Integration
|
|
182
|
-
|
|
183
|
-
Use MUSUBIX MCP tools:
|
|
184
|
-
|
|
185
|
-
```
|
|
186
|
-
sdd_create_requirements - Create requirements document
|
|
187
|
-
sdd_validate_requirements - Validate EARS patterns
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
---
|
|
191
|
-
|
|
192
|
-
**MUSUBIX**: https://github.com/nahisaho/MUSUBIX
|
|
193
|
-
**Version**: 1.0.0
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
# MUSUBIX Code Review Command
|
|
2
|
-
|
|
3
|
-
Perform comprehensive code review with SOLID principles and quality checks.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## Instructions for AI Agent
|
|
8
|
-
|
|
9
|
-
You are executing the `musubix review [feature-name]` command to perform code review.
|
|
10
|
-
|
|
11
|
-
### Command Format
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
npx musubix codegen analyze <file>
|
|
15
|
-
npx musubix trace validate
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
### Your Task
|
|
19
|
-
|
|
20
|
-
Perform comprehensive code review focusing on:
|
|
21
|
-
|
|
22
|
-
1. SOLID Principles Compliance
|
|
23
|
-
2. Code Quality Metrics
|
|
24
|
-
3. Design Pattern Usage
|
|
25
|
-
4. Traceability Verification
|
|
26
|
-
5. Best Practices Adherence
|
|
27
|
-
|
|
28
|
-
---
|
|
29
|
-
|
|
30
|
-
## Process
|
|
31
|
-
|
|
32
|
-
### 1. Read Source Code and Context
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
# Source Code
|
|
36
|
-
packages/core/src/{{feature}}/**/*.ts
|
|
37
|
-
packages/mcp-server/src/tools/**/*.ts
|
|
38
|
-
|
|
39
|
-
# Design Documentation
|
|
40
|
-
storage/specs/DES-{{FEATURE}}-001.md
|
|
41
|
-
|
|
42
|
-
# Steering Context
|
|
43
|
-
steering/structure.ja.md
|
|
44
|
-
steering/tech.ja.md
|
|
45
|
-
steering/rules/constitution.md
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### 2. SOLID Principles Check
|
|
49
|
-
|
|
50
|
-
Review each file for:
|
|
51
|
-
|
|
52
|
-
| Principle | Check |
|
|
53
|
-
|-----------|-------|
|
|
54
|
-
| **S**ingle Responsibility | 1つのクラス/関数は1つの責務のみ |
|
|
55
|
-
| **O**pen/Closed | 拡張に開き、修正に閉じている |
|
|
56
|
-
| **L**iskov Substitution | 派生クラスは基底クラスと置換可能 |
|
|
57
|
-
| **I**nterface Segregation | クライアント固有のインターフェース |
|
|
58
|
-
| **D**ependency Inversion | 抽象に依存、具象に依存しない |
|
|
59
|
-
|
|
60
|
-
### 3. Code Quality Metrics
|
|
61
|
-
|
|
62
|
-
Analyze:
|
|
63
|
-
|
|
64
|
-
- **Cyclomatic Complexity**: 関数あたり10以下
|
|
65
|
-
- **Lines per Function**: 50行以下
|
|
66
|
-
- **Lines per File**: 300行以下
|
|
67
|
-
- **Nesting Depth**: 3レベル以下
|
|
68
|
-
- **Parameter Count**: 5個以下
|
|
69
|
-
|
|
70
|
-
### 4. Design Pattern Review
|
|
71
|
-
|
|
72
|
-
Check for:
|
|
73
|
-
|
|
74
|
-
- [ ] Repository Pattern (データアクセス)
|
|
75
|
-
- [ ] Service Layer (ビジネスロジック)
|
|
76
|
-
- [ ] Factory Pattern (オブジェクト生成)
|
|
77
|
-
- [ ] Value Objects (ドメイン概念)
|
|
78
|
-
- [ ] Result Type (エラーハンドリング)
|
|
79
|
-
|
|
80
|
-
### 5. Best Practices Check
|
|
81
|
-
|
|
82
|
-
| カテゴリ | チェック項目 |
|
|
83
|
-
|---------|-------------|
|
|
84
|
-
| 命名規則 | PascalCase (型), camelCase (変数/関数), UPPER_CASE (定数) |
|
|
85
|
-
| TypeScript | strict mode, 明示的な型定義, any禁止 |
|
|
86
|
-
| エラー処理 | Result<T, E>パターン, 適切なエラーメッセージ |
|
|
87
|
-
| コメント | JSDoc形式, 複雑なロジックの説明 |
|
|
88
|
-
| インポート | 絶対パス, 循環参照なし |
|
|
89
|
-
|
|
90
|
-
---
|
|
91
|
-
|
|
92
|
-
## Output Format
|
|
93
|
-
|
|
94
|
-
```markdown
|
|
95
|
-
# Code Review Report: {{FEATURE}}
|
|
96
|
-
|
|
97
|
-
## Summary
|
|
98
|
-
- **Overall Score**: A/B/C/D/F
|
|
99
|
-
- **Files Reviewed**: X files
|
|
100
|
-
- **Issues Found**: X critical, X warnings, X suggestions
|
|
101
|
-
|
|
102
|
-
## SOLID Compliance
|
|
103
|
-
| Principle | Status | Notes |
|
|
104
|
-
|-----------|--------|-------|
|
|
105
|
-
| SRP | ✅/⚠️/❌ | ... |
|
|
106
|
-
| OCP | ✅/⚠️/❌ | ... |
|
|
107
|
-
| LSP | ✅/⚠️/❌ | ... |
|
|
108
|
-
| ISP | ✅/⚠️/❌ | ... |
|
|
109
|
-
| DIP | ✅/⚠️/❌ | ... |
|
|
110
|
-
|
|
111
|
-
## Quality Metrics
|
|
112
|
-
| Metric | Value | Status |
|
|
113
|
-
|--------|-------|--------|
|
|
114
|
-
| Avg Cyclomatic Complexity | X | ✅/⚠️/❌ |
|
|
115
|
-
| Max Lines per Function | X | ✅/⚠️/❌ |
|
|
116
|
-
| Max Nesting Depth | X | ✅/⚠️/❌ |
|
|
117
|
-
|
|
118
|
-
## Issues
|
|
119
|
-
|
|
120
|
-
### Critical (Must Fix)
|
|
121
|
-
1. [FILE:LINE] Description
|
|
122
|
-
|
|
123
|
-
### Warnings (Should Fix)
|
|
124
|
-
1. [FILE:LINE] Description
|
|
125
|
-
|
|
126
|
-
### Suggestions (Nice to Have)
|
|
127
|
-
1. [FILE:LINE] Description
|
|
128
|
-
|
|
129
|
-
## Recommendations
|
|
130
|
-
1. ...
|
|
131
|
-
2. ...
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
---
|
|
135
|
-
|
|
136
|
-
## Traceability
|
|
137
|
-
|
|
138
|
-
This skill implements:
|
|
139
|
-
- **Article III**: Test-First Imperative (コードレビューによる品質確保)
|
|
140
|
-
- **Article VII**: Simplicity Gate (コードの複雑性チェック)
|
|
141
|
-
|
|
142
|
-
---
|
|
143
|
-
|
|
144
|
-
## Related Commands
|
|
145
|
-
|
|
146
|
-
```bash
|
|
147
|
-
# Static analysis
|
|
148
|
-
npx musubix codegen analyze <file>
|
|
149
|
-
|
|
150
|
-
# Traceability validation
|
|
151
|
-
npx musubix trace validate
|
|
152
|
-
|
|
153
|
-
# Security scanning
|
|
154
|
-
npx musubix codegen security <path>
|
|
155
|
-
```
|
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
# MUSUBIX Security Scan Command
|
|
2
|
-
|
|
3
|
-
Perform comprehensive security scanning and vulnerability detection.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## Instructions for AI Agent
|
|
8
|
-
|
|
9
|
-
You are executing the `musubix security [feature-name]` command to perform security analysis.
|
|
10
|
-
|
|
11
|
-
### Command Format
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
npx musubix codegen security <path>
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
### Your Task
|
|
18
|
-
|
|
19
|
-
Perform comprehensive security analysis covering:
|
|
20
|
-
|
|
21
|
-
1. OWASP Top 10 vulnerabilities
|
|
22
|
-
2. Dependency vulnerabilities
|
|
23
|
-
3. Authentication/Authorization issues
|
|
24
|
-
4. Data validation gaps
|
|
25
|
-
5. Sensitive data exposure
|
|
26
|
-
|
|
27
|
-
---
|
|
28
|
-
|
|
29
|
-
## Process
|
|
30
|
-
|
|
31
|
-
### 1. Read Source Code and Dependencies
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
# Source Code
|
|
35
|
-
packages/core/src/{{feature}}/**/*.ts
|
|
36
|
-
packages/mcp-server/src/tools/**/*.ts
|
|
37
|
-
|
|
38
|
-
# Dependencies
|
|
39
|
-
package.json
|
|
40
|
-
package-lock.json
|
|
41
|
-
|
|
42
|
-
# Auth module
|
|
43
|
-
packages/core/src/auth/**/*.ts
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
### 2. OWASP Top 10 Checks
|
|
47
|
-
|
|
48
|
-
| # | Vulnerability | Check |
|
|
49
|
-
|---|--------------|-------|
|
|
50
|
-
| A01 | Broken Access Control | 認可チェックの実装確認 |
|
|
51
|
-
| A02 | Cryptographic Failures | 暗号化の適切な使用 |
|
|
52
|
-
| A03 | Injection | SQL/NoSQL/コマンドインジェクション |
|
|
53
|
-
| A04 | Insecure Design | セキュリティパターンの適用 |
|
|
54
|
-
| A05 | Security Misconfiguration | 設定の安全性 |
|
|
55
|
-
| A06 | Vulnerable Components | 依存関係の脆弱性 |
|
|
56
|
-
| A07 | Authentication Failures | 認証の実装不備 |
|
|
57
|
-
| A08 | Software/Data Integrity | データ整合性の検証 |
|
|
58
|
-
| A09 | Security Logging | ログと監視 |
|
|
59
|
-
| A10 | SSRF | サーバーサイドリクエストフォージェリ |
|
|
60
|
-
|
|
61
|
-
### 3. Code Pattern Analysis
|
|
62
|
-
|
|
63
|
-
#### ❌ Dangerous Patterns
|
|
64
|
-
|
|
65
|
-
```typescript
|
|
66
|
-
// SQL Injection - 危険
|
|
67
|
-
const query = `SELECT * FROM users WHERE id = ${userId}`;
|
|
68
|
-
|
|
69
|
-
// Command Injection - 危険
|
|
70
|
-
exec(`ls ${userInput}`);
|
|
71
|
-
|
|
72
|
-
// Path Traversal - 危険
|
|
73
|
-
const file = fs.readFileSync(`./uploads/${filename}`);
|
|
74
|
-
|
|
75
|
-
// Hardcoded Secrets - 危険
|
|
76
|
-
const apiKey = 'sk-1234567890abcdef';
|
|
77
|
-
|
|
78
|
-
// eval() - 危険
|
|
79
|
-
eval(userInput);
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
#### ✅ Safe Patterns
|
|
83
|
-
|
|
84
|
-
```typescript
|
|
85
|
-
// Parameterized Query - 安全
|
|
86
|
-
const query = db.query('SELECT * FROM users WHERE id = ?', [userId]);
|
|
87
|
-
|
|
88
|
-
// Input Validation - 安全
|
|
89
|
-
const sanitized = sanitize(userInput);
|
|
90
|
-
|
|
91
|
-
// Path Validation - 安全
|
|
92
|
-
const safePath = path.resolve('./uploads', path.basename(filename));
|
|
93
|
-
|
|
94
|
-
// Environment Variables - 安全
|
|
95
|
-
const apiKey = process.env.API_KEY;
|
|
96
|
-
|
|
97
|
-
// No eval - 安全
|
|
98
|
-
const result = JSON.parse(jsonString);
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
### 4. Authentication & Authorization
|
|
102
|
-
|
|
103
|
-
Check for:
|
|
104
|
-
|
|
105
|
-
- [ ] JWT/Session token validation
|
|
106
|
-
- [ ] Password hashing (bcrypt, argon2)
|
|
107
|
-
- [ ] Role-based access control (RBAC)
|
|
108
|
-
- [ ] Rate limiting
|
|
109
|
-
- [ ] CSRF protection
|
|
110
|
-
- [ ] Secure cookie flags
|
|
111
|
-
|
|
112
|
-
### 5. Data Validation
|
|
113
|
-
|
|
114
|
-
```typescript
|
|
115
|
-
// ✅ Recommended: Zod schema validation
|
|
116
|
-
import { z } from 'zod';
|
|
117
|
-
|
|
118
|
-
const UserInputSchema = z.object({
|
|
119
|
-
email: z.string().email(),
|
|
120
|
-
password: z.string().min(8).max(100),
|
|
121
|
-
age: z.number().int().positive().max(150),
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
// Validate all user inputs
|
|
125
|
-
const result = UserInputSchema.safeParse(userInput);
|
|
126
|
-
if (!result.success) {
|
|
127
|
-
return err(new ValidationError(result.error));
|
|
128
|
-
}
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
### 6. Dependency Audit
|
|
132
|
-
|
|
133
|
-
```bash
|
|
134
|
-
# Check for known vulnerabilities
|
|
135
|
-
npm audit
|
|
136
|
-
npm audit --audit-level=moderate
|
|
137
|
-
|
|
138
|
-
# Update vulnerable packages
|
|
139
|
-
npm audit fix
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
---
|
|
143
|
-
|
|
144
|
-
## Output Format
|
|
145
|
-
|
|
146
|
-
```markdown
|
|
147
|
-
# Security Scan Report: {{FEATURE}}
|
|
148
|
-
|
|
149
|
-
## Summary
|
|
150
|
-
- **Risk Level**: Critical/High/Medium/Low
|
|
151
|
-
- **Vulnerabilities Found**: X critical, X high, X medium, X low
|
|
152
|
-
- **Dependencies Audited**: X packages
|
|
153
|
-
|
|
154
|
-
## OWASP Top 10 Assessment
|
|
155
|
-
|
|
156
|
-
| Category | Status | Findings |
|
|
157
|
-
|----------|--------|----------|
|
|
158
|
-
| A01: Access Control | ✅/⚠️/❌ | ... |
|
|
159
|
-
| A02: Cryptographic | ✅/⚠️/❌ | ... |
|
|
160
|
-
| A03: Injection | ✅/⚠️/❌ | ... |
|
|
161
|
-
| A04: Insecure Design | ✅/⚠️/❌ | ... |
|
|
162
|
-
| A05: Misconfiguration | ✅/⚠️/❌ | ... |
|
|
163
|
-
| A06: Vulnerable Deps | ✅/⚠️/❌ | ... |
|
|
164
|
-
| A07: Auth Failures | ✅/⚠️/❌ | ... |
|
|
165
|
-
| A08: Integrity | ✅/⚠️/❌ | ... |
|
|
166
|
-
| A09: Logging | ✅/⚠️/❌ | ... |
|
|
167
|
-
| A10: SSRF | ✅/⚠️/❌ | ... |
|
|
168
|
-
|
|
169
|
-
## Critical Vulnerabilities
|
|
170
|
-
|
|
171
|
-
### 1. [CRITICAL] SQL Injection in user-service.ts
|
|
172
|
-
- **Location**: packages/core/src/user/user-service.ts:45
|
|
173
|
-
- **Description**: User input directly concatenated in SQL query
|
|
174
|
-
- **Remediation**: Use parameterized queries
|
|
175
|
-
- **Reference**: CWE-89
|
|
176
|
-
|
|
177
|
-
### 2. [HIGH] Hardcoded API Key
|
|
178
|
-
- **Location**: packages/core/src/auth/config.ts:12
|
|
179
|
-
- **Description**: API key stored in source code
|
|
180
|
-
- **Remediation**: Use environment variables
|
|
181
|
-
- **Reference**: CWE-798
|
|
182
|
-
|
|
183
|
-
## Dependency Vulnerabilities
|
|
184
|
-
|
|
185
|
-
| Package | Severity | Version | Fixed In |
|
|
186
|
-
|---------|----------|---------|----------|
|
|
187
|
-
| lodash | High | 4.17.20 | 4.17.21 |
|
|
188
|
-
|
|
189
|
-
## Recommendations
|
|
190
|
-
|
|
191
|
-
1. **Immediate**: Fix all critical vulnerabilities
|
|
192
|
-
2. **Short-term**: Update vulnerable dependencies
|
|
193
|
-
3. **Long-term**: Implement security testing in CI/CD
|
|
194
|
-
|
|
195
|
-
## Compliance Checklist
|
|
196
|
-
|
|
197
|
-
- [ ] Input validation on all user inputs
|
|
198
|
-
- [ ] Output encoding for XSS prevention
|
|
199
|
-
- [ ] Parameterized queries for database access
|
|
200
|
-
- [ ] Secrets in environment variables
|
|
201
|
-
- [ ] HTTPS enforced
|
|
202
|
-
- [ ] Security headers configured
|
|
203
|
-
- [ ] Rate limiting implemented
|
|
204
|
-
- [ ] Audit logging enabled
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
---
|
|
208
|
-
|
|
209
|
-
## Traceability
|
|
210
|
-
|
|
211
|
-
This skill implements:
|
|
212
|
-
- **Article IX**: Integration-First Testing (セキュリティテスト)
|
|
213
|
-
- Security requirements validation
|
|
214
|
-
|
|
215
|
-
---
|
|
216
|
-
|
|
217
|
-
## Related Commands
|
|
218
|
-
|
|
219
|
-
```bash
|
|
220
|
-
# Security scan
|
|
221
|
-
npx musubix codegen security <path>
|
|
222
|
-
|
|
223
|
-
# Dependency audit
|
|
224
|
-
npm audit
|
|
225
|
-
|
|
226
|
-
# Static analysis
|
|
227
|
-
npx musubix codegen analyze <file>
|
|
228
|
-
```
|