musubix 3.4.1 → 3.4.3
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 +50 -315
- package/bin/musubix.js +1 -9
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +74 -0
- package/dist/index.js.map +1 -0
- package/package.json +51 -57
- package/.github/AGENTS.md +0 -949
- 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 -237
- 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 -217
- package/.github/skills/musubix-technical-writing/SKILL.md +0 -444
- package/.github/skills/musubix-test-generation/SKILL.md +0 -212
- package/.github/skills/musubix-traceability/SKILL.md +0 -141
- package/AGENTS.md +0 -1134
- package/LICENSE +0 -21
- package/README.ja.md +0 -313
- package/bin/musubix-mcp.js +0 -15
- 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/MIGRATION-v3.0.md +0 -324
- package/docs/MUSUBI-enhancement_roadmap_20260105.md +0 -651
- package/docs/MUSUBIX-v3.0-User-Guide.md +0 -1357
- package/docs/MUSUBIXv2.2.0-Manual-outline.md +0 -136
- package/docs/MUSUBIXv2.2.0-Manual.md +0 -3123
- package/docs/MUSUBIXv2.3.5-Refactering.md +0 -1310
- package/docs/MUSUBIv1.6.1-enhancement_roadmap_20260105.md +0 -291
- package/docs/MUSUBIv2.2.0-USERGUIDE.md +0 -2079
- 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 -3022
- package/docs/YATA-GLOBAL-GUIDE.ja.md +0 -750
- package/docs/YATA-GLOBAL-GUIDE.md +0 -595
- package/docs/YATA-LOCAL-GUIDE.ja.md +0 -989
- package/docs/YATA-LOCAL-GUIDE.md +0 -730
- 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/adr/ADR-v3.4.0-001-deep-research-architecture.md +0 -217
- package/docs/adr/ADR-v3.4.0-002-search-provider-selection.md +0 -308
- package/docs/adr/ADR-v3.4.0-003-lm-api-integration.md +0 -475
- package/docs/enterprise-knowledge-management.md +0 -1737
- package/docs/evolution-from-musubi-to-musubix.md +0 -2170
- package/docs/getting-started-with-sdd.md +0 -1602
- package/docs/moodle-refactering-codegraph-musubix.md +0 -391
- package/docs/moodle-refactering-codegraph.md +0 -278
- package/docs/overview/MUSUBIX-CodeGraph.md +0 -322
- package/docs/overview/MUSUBIX-Core.md +0 -671
- package/docs/overview/MUSUBIX-Decisions.md +0 -494
- package/docs/overview/MUSUBIX-FormalVerify.md +0 -566
- package/docs/overview/MUSUBIX-Knowledge.md +0 -1231
- 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-Policy.md +0 -477
- package/docs/overview/MUSUBIX-Roadmap-v2.md +0 -399
- package/docs/overview/MUSUBIX-Security-Plan.md +0 -939
- package/docs/overview/MUSUBIX-Security-v2.1.md +0 -668
- package/docs/overview/MUSUBIX-Security.md +0 -891
- package/docs/overview/MUSUBIX-YATA.md +0 -666
- package/docs/overview/MUSUBIX-v2.2.0-Advanced-Learning.md +0 -513
- package/docs/overview/Neuro-SymbolicAI.md +0 -159
- package/docs/packages/knowledge.md +0 -594
- package/docs/qiita-linux-kernel-knowledge-graph.md +0 -596
- 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 -491
- package/steering/structure.ja.md +0 -503
- package/steering/tech.ja.md +0 -208
|
@@ -1,668 +0,0 @@
|
|
|
1
|
-
# MUSUBIX Security v2.1.0 - セキュリティ強化リリース
|
|
2
|
-
|
|
3
|
-
**パッケージ名**: `@nahisaho/musubix-security`
|
|
4
|
-
**バージョン**: 2.1.0
|
|
5
|
-
**最終更新**: 2026-01-08
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## 1. 概要
|
|
10
|
-
|
|
11
|
-
MUSUBIX v2.1.0は、**4つのEPIC**で**30タスク**を実装したセキュリティ強化リリースです。**3400+テスト**が全て合格しており、エンタープライズグレードのセキュリティ分析を提供します。
|
|
12
|
-
|
|
13
|
-
### 1.1 v2.1.0 新機能サマリー
|
|
14
|
-
|
|
15
|
-
| EPIC | 機能 | タスク数 | テスト数 |
|
|
16
|
-
|------|------|---------|---------|
|
|
17
|
-
| **EPIC-1** | テイント分析強化 | 8 | 200+ |
|
|
18
|
-
| **EPIC-2** | CVEデータベース連携 | 7 | 150+ |
|
|
19
|
-
| **EPIC-3** | OWASP/CWE Top 25 ルール | 6 | 700+ |
|
|
20
|
-
| **EPIC-4** | 自動修正パイプライン | 9 | 200+ |
|
|
21
|
-
|
|
22
|
-
### 1.2 アーキテクチャ
|
|
23
|
-
|
|
24
|
-
```
|
|
25
|
-
┌─────────────────────────────────────────────────────────────┐
|
|
26
|
-
│ Security Analysis Engine │
|
|
27
|
-
├─────────────────────────────────────────────────────────────┤
|
|
28
|
-
│ EPIC-1: Enhanced Taint Analysis │
|
|
29
|
-
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │
|
|
30
|
-
│ │ 50+ Sources │──│ Propagation │──│ 40+ Sinks │ │
|
|
31
|
-
│ │ (HTTP,ENV) │ │ (DFG/CFG) │ │ (SQL,CMD,XSS) │ │
|
|
32
|
-
│ └─────────────┘ └─────────────┘ └─────────────────────┘ │
|
|
33
|
-
├─────────────────────────────────────────────────────────────┤
|
|
34
|
-
│ EPIC-2: CVE Database Integration │
|
|
35
|
-
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │
|
|
36
|
-
│ │ NVD API 2.0 │──│ CVE Cache │──│ Vuln Matching │ │
|
|
37
|
-
│ │ (Real-time) │ │ (SQLite) │ │ (Semver/Regex) │ │
|
|
38
|
-
│ └─────────────┘ └─────────────┘ └─────────────────────┘ │
|
|
39
|
-
├─────────────────────────────────────────────────────────────┤
|
|
40
|
-
│ EPIC-3: OWASP/CWE Rules │
|
|
41
|
-
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │
|
|
42
|
-
│ │ OWASP Top10 │──│ CWE Top 25 │──│ Rule Engine │ │
|
|
43
|
-
│ │ (10 Rules) │ │ (25 Rules) │ │ (Registry/Config) │ │
|
|
44
|
-
│ └─────────────┘ └─────────────┘ └─────────────────────┘ │
|
|
45
|
-
├─────────────────────────────────────────────────────────────┤
|
|
46
|
-
│ EPIC-4: Auto-Fix Pipeline │
|
|
47
|
-
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │
|
|
48
|
-
│ │ Fix Gen │──│ Validation │──│ CI/CD Integration │ │
|
|
49
|
-
│ │ (Template) │ │ (Sandbox) │ │ (GitHub/GitLab) │ │
|
|
50
|
-
│ └─────────────┘ └─────────────┘ └─────────────────────┘ │
|
|
51
|
-
└─────────────────────────────────────────────────────────────┘
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
---
|
|
55
|
-
|
|
56
|
-
## 2. EPIC-1: テイント分析強化
|
|
57
|
-
|
|
58
|
-
### 2.1 概要
|
|
59
|
-
|
|
60
|
-
高度なテイント追跡システムにより、ユーザー入力から危険なシンクへのデータフローを正確に追跡します。
|
|
61
|
-
|
|
62
|
-
### 2.2 ソース定義(50+)
|
|
63
|
-
|
|
64
|
-
```typescript
|
|
65
|
-
import {
|
|
66
|
-
ALL_BUILTIN_SOURCES,
|
|
67
|
-
SourceCategory,
|
|
68
|
-
} from '@nahisaho/musubix-security';
|
|
69
|
-
|
|
70
|
-
// カテゴリ別ソース
|
|
71
|
-
const categories: SourceCategory[] = [
|
|
72
|
-
'user-input', // req.body, req.query, req.params, document.getElementById
|
|
73
|
-
'network', // fetch, axios.get, http.request
|
|
74
|
-
'environment', // process.env, Deno.env
|
|
75
|
-
'file', // fs.readFile, fs.readFileSync
|
|
76
|
-
'database', // query result, findOne, findMany
|
|
77
|
-
'external-api', // response.json(), response.text()
|
|
78
|
-
];
|
|
79
|
-
|
|
80
|
-
// 例: user-input ソース
|
|
81
|
-
// req.body, req.query, req.params, req.headers
|
|
82
|
-
// document.getElementById, document.querySelector
|
|
83
|
-
// window.location, URLSearchParams
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
### 2.3 シンク定義(40+)
|
|
87
|
-
|
|
88
|
-
```typescript
|
|
89
|
-
import {
|
|
90
|
-
ALL_BUILTIN_SINKS,
|
|
91
|
-
SinkCategory,
|
|
92
|
-
} from '@nahisaho/musubix-security';
|
|
93
|
-
|
|
94
|
-
// カテゴリ別シンク
|
|
95
|
-
const sinkCategories: SinkCategory[] = [
|
|
96
|
-
'sql-query', // query(), execute(), raw()
|
|
97
|
-
'command-exec', // exec(), spawn(), execSync()
|
|
98
|
-
'html-output', // innerHTML, document.write()
|
|
99
|
-
'file-path', // fs.readFile(), fs.writeFile()
|
|
100
|
-
'code-exec', // eval(), Function(), vm.runInContext()
|
|
101
|
-
'redirect', // res.redirect(), window.location
|
|
102
|
-
];
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
### 2.4 サニタイザ定義(30+)
|
|
106
|
-
|
|
107
|
-
```typescript
|
|
108
|
-
import {
|
|
109
|
-
ALL_BUILTIN_SANITIZERS,
|
|
110
|
-
SanitizerMapping,
|
|
111
|
-
} from '@nahisaho/musubix-security';
|
|
112
|
-
|
|
113
|
-
// シンクタイプ別サニタイザ
|
|
114
|
-
const sanitizers: SanitizerMapping = {
|
|
115
|
-
'sql-query': ['parameterizedQuery', 'escapeSQL', 'preparedStatement'],
|
|
116
|
-
'html-output': ['escapeHTML', 'sanitizeHTML', 'DOMPurify.sanitize'],
|
|
117
|
-
'command-exec': ['escapeShell', 'shellEscape'],
|
|
118
|
-
'file-path': ['path.normalize', 'path.resolve', 'validatePath'],
|
|
119
|
-
'redirect': ['validateURL', 'isAllowedDomain'],
|
|
120
|
-
};
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
### 2.5 手続き間テイント伝播
|
|
124
|
-
|
|
125
|
-
```typescript
|
|
126
|
-
import {
|
|
127
|
-
CallGraphBuilder,
|
|
128
|
-
TaintPropagator,
|
|
129
|
-
InterproceduralAnalyzer,
|
|
130
|
-
} from '@nahisaho/musubix-security';
|
|
131
|
-
|
|
132
|
-
// コールグラフ構築
|
|
133
|
-
const callGraph = new CallGraphBuilder();
|
|
134
|
-
callGraph.buildFromProject('./src');
|
|
135
|
-
|
|
136
|
-
// 手続き間テイント伝播
|
|
137
|
-
const propagator = new TaintPropagator(callGraph);
|
|
138
|
-
const taintFlows = propagator.analyze(code);
|
|
139
|
-
|
|
140
|
-
// DFG統合解析
|
|
141
|
-
const analyzer = new InterproceduralAnalyzer({
|
|
142
|
-
maxDepth: 10,
|
|
143
|
-
trackImplicitFlows: true,
|
|
144
|
-
});
|
|
145
|
-
const result = await analyzer.analyze(project);
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
### 2.6 使用例
|
|
149
|
-
|
|
150
|
-
```typescript
|
|
151
|
-
import { createEnhancedTaintAnalyzer } from '@nahisaho/musubix-security';
|
|
152
|
-
|
|
153
|
-
const analyzer = createEnhancedTaintAnalyzer({
|
|
154
|
-
maxDepth: 10,
|
|
155
|
-
sources: ALL_BUILTIN_SOURCES,
|
|
156
|
-
sinks: ALL_BUILTIN_SINKS,
|
|
157
|
-
sanitizers: ALL_BUILTIN_SANITIZERS,
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
const result = await analyzer.analyze(`
|
|
161
|
-
const userInput = req.body.name;
|
|
162
|
-
const query = "SELECT * FROM users WHERE name = '" + userInput + "'";
|
|
163
|
-
db.query(query); // 🚨 SQL Injection detected!
|
|
164
|
-
`, 'app.ts');
|
|
165
|
-
|
|
166
|
-
console.log(result.taintFlows);
|
|
167
|
-
// [{
|
|
168
|
-
// source: { type: 'user-input', location: 'req.body.name' },
|
|
169
|
-
// sink: { type: 'sql-query', location: 'db.query()' },
|
|
170
|
-
// path: ['userInput', 'query', 'db.query'],
|
|
171
|
-
// sanitized: false
|
|
172
|
-
// }]
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
---
|
|
176
|
-
|
|
177
|
-
## 3. EPIC-2: CVEデータベース連携
|
|
178
|
-
|
|
179
|
-
### 3.1 概要
|
|
180
|
-
|
|
181
|
-
NVD(National Vulnerability Database)API 2.0と連携し、リアルタイムでCVE情報を取得・照合します。
|
|
182
|
-
|
|
183
|
-
### 3.2 NVDClient
|
|
184
|
-
|
|
185
|
-
```typescript
|
|
186
|
-
import { NVDClient, NVDConfig } from '@nahisaho/musubix-security';
|
|
187
|
-
|
|
188
|
-
const client = new NVDClient({
|
|
189
|
-
apiKey: process.env.NVD_API_KEY, // オプション(レートリミット緩和)
|
|
190
|
-
cacheEnabled: true,
|
|
191
|
-
cacheTTL: 86400, // 24時間
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
// CVE検索
|
|
195
|
-
const cves = await client.searchCVEs({
|
|
196
|
-
keywordSearch: 'lodash',
|
|
197
|
-
resultsPerPage: 20,
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
// 特定CVE取得
|
|
201
|
-
const cve = await client.getCVE('CVE-2021-23337');
|
|
202
|
-
console.log(cve.cvssV3Score); // 7.2
|
|
203
|
-
console.log(cve.description);
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
### 3.3 CVEマッチング
|
|
207
|
-
|
|
208
|
-
```typescript
|
|
209
|
-
import { CVEMatcher, DependencyScanner } from '@nahisaho/musubix-security';
|
|
210
|
-
|
|
211
|
-
const matcher = new CVEMatcher(nvdClient);
|
|
212
|
-
const scanner = new DependencyScanner();
|
|
213
|
-
|
|
214
|
-
// package.json解析
|
|
215
|
-
const deps = await scanner.scanPackageJson('./package.json');
|
|
216
|
-
|
|
217
|
-
// CVEマッチング
|
|
218
|
-
const matches = await matcher.matchDependencies(deps);
|
|
219
|
-
|
|
220
|
-
for (const match of matches) {
|
|
221
|
-
console.log(`${match.package}@${match.version}`);
|
|
222
|
-
console.log(` CVE: ${match.cve.id}`);
|
|
223
|
-
console.log(` CVSS: ${match.cve.cvssV3Score}`);
|
|
224
|
-
console.log(` Fix: ${match.fixedVersion || 'No fix available'}`);
|
|
225
|
-
}
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
### 3.4 ローカルキャッシュ
|
|
229
|
-
|
|
230
|
-
```typescript
|
|
231
|
-
import { CVECache, CVEDatabase } from '@nahisaho/musubix-security';
|
|
232
|
-
|
|
233
|
-
// SQLiteベースのローカルキャッシュ
|
|
234
|
-
const cache = new CVECache({
|
|
235
|
-
dbPath: './.musubix/cve-cache.db',
|
|
236
|
-
ttl: 86400 * 7, // 7日間
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
// バッチ更新
|
|
240
|
-
await cache.updateFromNVD({
|
|
241
|
-
startDate: '2024-01-01',
|
|
242
|
-
modifiedSince: lastUpdateDate,
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
// ローカル検索(高速)
|
|
246
|
-
const results = cache.search({
|
|
247
|
-
package: 'express',
|
|
248
|
-
versionRange: '>=4.0.0 <4.18.2',
|
|
249
|
-
});
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
---
|
|
253
|
-
|
|
254
|
-
## 4. EPIC-3: OWASP/CWE Top 25 ルール
|
|
255
|
-
|
|
256
|
-
### 4.1 概要
|
|
257
|
-
|
|
258
|
-
OWASP Top 10(2021)とCWE Top 25(2023)に完全対応したルールエンジンを実装しました。
|
|
259
|
-
|
|
260
|
-
### 4.2 OWASP Top 10 ルール
|
|
261
|
-
|
|
262
|
-
```typescript
|
|
263
|
-
import { OWASPRules } from '@nahisaho/musubix-security';
|
|
264
|
-
|
|
265
|
-
// A01: Broken Access Control
|
|
266
|
-
// A02: Cryptographic Failures
|
|
267
|
-
// A03: Injection
|
|
268
|
-
// A04: Insecure Design
|
|
269
|
-
// A05: Security Misconfiguration
|
|
270
|
-
// A06: Vulnerable Components
|
|
271
|
-
// A07: Authentication Failures
|
|
272
|
-
// A08: Integrity Failures
|
|
273
|
-
// A09: Logging Failures
|
|
274
|
-
// A10: SSRF
|
|
275
|
-
|
|
276
|
-
const rules = OWASPRules.getAll();
|
|
277
|
-
console.log(rules.length); // 10
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
### 4.3 CWE Top 25 ルール
|
|
281
|
-
|
|
282
|
-
```typescript
|
|
283
|
-
import { CWERules } from '@nahisaho/musubix-security';
|
|
284
|
-
|
|
285
|
-
// CWE-79: XSS
|
|
286
|
-
// CWE-89: SQL Injection
|
|
287
|
-
// CWE-78: OS Command Injection
|
|
288
|
-
// CWE-20: Improper Input Validation
|
|
289
|
-
// CWE-22: Path Traversal
|
|
290
|
-
// CWE-352: CSRF
|
|
291
|
-
// CWE-434: Unrestricted File Upload
|
|
292
|
-
// CWE-502: Deserialization
|
|
293
|
-
// CWE-798: Hardcoded Credentials
|
|
294
|
-
// CWE-862: Missing Authorization
|
|
295
|
-
// ... (25 rules total)
|
|
296
|
-
|
|
297
|
-
const rules = CWERules.getAll();
|
|
298
|
-
console.log(rules.length); // 25
|
|
299
|
-
```
|
|
300
|
-
|
|
301
|
-
### 4.4 ルールエンジン
|
|
302
|
-
|
|
303
|
-
```typescript
|
|
304
|
-
import {
|
|
305
|
-
RuleEngine,
|
|
306
|
-
RuleRegistry,
|
|
307
|
-
RuleContext,
|
|
308
|
-
} from '@nahisaho/musubix-security';
|
|
309
|
-
|
|
310
|
-
// ルール登録
|
|
311
|
-
const registry = new RuleRegistry();
|
|
312
|
-
registry.registerAll(OWASPRules.getAll());
|
|
313
|
-
registry.registerAll(CWERules.getAll());
|
|
314
|
-
|
|
315
|
-
// エンジン初期化
|
|
316
|
-
const engine = new RuleEngine(registry, {
|
|
317
|
-
severity: ['critical', 'high', 'medium'],
|
|
318
|
-
categories: ['injection', 'authentication'],
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
// 解析実行
|
|
322
|
-
const context = new RuleContext(sourceFile, project);
|
|
323
|
-
const violations = await engine.analyze(context);
|
|
324
|
-
|
|
325
|
-
for (const v of violations) {
|
|
326
|
-
console.log(`[${v.rule.id}] ${v.message}`);
|
|
327
|
-
console.log(` File: ${v.location.file}:${v.location.line}`);
|
|
328
|
-
console.log(` Severity: ${v.severity}`);
|
|
329
|
-
console.log(` Fix: ${v.suggestedFix}`);
|
|
330
|
-
}
|
|
331
|
-
```
|
|
332
|
-
|
|
333
|
-
### 4.5 設定プロファイル
|
|
334
|
-
|
|
335
|
-
```typescript
|
|
336
|
-
import { SecurityProfiles } from '@nahisaho/musubix-security';
|
|
337
|
-
|
|
338
|
-
// 組み込みプロファイル
|
|
339
|
-
const profiles = {
|
|
340
|
-
'default': SecurityProfiles.DEFAULT, // バランス
|
|
341
|
-
'strict': SecurityProfiles.STRICT, // 厳格
|
|
342
|
-
'minimal': SecurityProfiles.MINIMAL, // 最小
|
|
343
|
-
'owasp-top10': SecurityProfiles.OWASP, // OWASPのみ
|
|
344
|
-
'cwe-top25': SecurityProfiles.CWE, // CWEのみ
|
|
345
|
-
};
|
|
346
|
-
|
|
347
|
-
// カスタムプロファイル
|
|
348
|
-
const custom = SecurityProfiles.create({
|
|
349
|
-
extends: 'strict',
|
|
350
|
-
rules: {
|
|
351
|
-
'CWE-79': 'error',
|
|
352
|
-
'CWE-89': 'error',
|
|
353
|
-
'CWE-352': 'warn',
|
|
354
|
-
},
|
|
355
|
-
exclude: ['**/test/**', '**/node_modules/**'],
|
|
356
|
-
});
|
|
357
|
-
```
|
|
358
|
-
|
|
359
|
-
---
|
|
360
|
-
|
|
361
|
-
## 5. EPIC-4: 自動修正パイプライン
|
|
362
|
-
|
|
363
|
-
### 5.1 概要
|
|
364
|
-
|
|
365
|
-
検出された脆弱性に対して、安全な修正コードを自動生成し、CI/CDパイプラインに統合します。
|
|
366
|
-
|
|
367
|
-
### 5.2 AutoFixer
|
|
368
|
-
|
|
369
|
-
```typescript
|
|
370
|
-
import { AutoFixer, FixTemplate } from '@nahisaho/musubix-security';
|
|
371
|
-
|
|
372
|
-
const fixer = new AutoFixer({
|
|
373
|
-
templates: FixTemplate.loadBuiltins(),
|
|
374
|
-
validateFix: true,
|
|
375
|
-
preserveSemantics: true,
|
|
376
|
-
});
|
|
377
|
-
|
|
378
|
-
// 脆弱性に対する修正生成
|
|
379
|
-
const fix = await fixer.generateFix(vulnerability);
|
|
380
|
-
|
|
381
|
-
console.log(fix.original);
|
|
382
|
-
// const query = "SELECT * FROM users WHERE id = " + userId;
|
|
383
|
-
|
|
384
|
-
console.log(fix.fixed);
|
|
385
|
-
// const query = "SELECT * FROM users WHERE id = ?";
|
|
386
|
-
// db.query(query, [userId]);
|
|
387
|
-
|
|
388
|
-
console.log(fix.explanation);
|
|
389
|
-
// "パラメータ化クエリを使用してSQLインジェクションを防止"
|
|
390
|
-
```
|
|
391
|
-
|
|
392
|
-
### 5.3 修正検証
|
|
393
|
-
|
|
394
|
-
```typescript
|
|
395
|
-
import { FixValidator, SandboxRunner } from '@nahisaho/musubix-security';
|
|
396
|
-
|
|
397
|
-
const validator = new FixValidator({
|
|
398
|
-
sandbox: new SandboxRunner(),
|
|
399
|
-
timeout: 5000,
|
|
400
|
-
});
|
|
401
|
-
|
|
402
|
-
// 修正の検証
|
|
403
|
-
const result = await validator.validate(fix, {
|
|
404
|
-
syntaxCheck: true, // 構文チェック
|
|
405
|
-
typeCheck: true, // 型チェック
|
|
406
|
-
semanticCheck: true, // セマンティクス保持
|
|
407
|
-
securityCheck: true, // 脆弱性再発防止
|
|
408
|
-
testExecution: true, // テスト実行
|
|
409
|
-
});
|
|
410
|
-
|
|
411
|
-
if (result.valid) {
|
|
412
|
-
await fix.apply();
|
|
413
|
-
} else {
|
|
414
|
-
console.error(result.errors);
|
|
415
|
-
}
|
|
416
|
-
```
|
|
417
|
-
|
|
418
|
-
### 5.4 パッチ生成
|
|
419
|
-
|
|
420
|
-
```typescript
|
|
421
|
-
import { PatchGenerator, UnifiedDiff } from '@nahisaho/musubix-security';
|
|
422
|
-
|
|
423
|
-
const generator = new PatchGenerator();
|
|
424
|
-
|
|
425
|
-
// 単一ファイルパッチ
|
|
426
|
-
const patch = generator.generatePatch(fix);
|
|
427
|
-
console.log(patch.diff);
|
|
428
|
-
// --- a/src/api.ts
|
|
429
|
-
// +++ b/src/api.ts
|
|
430
|
-
// @@ -10,3 +10,4 @@
|
|
431
|
-
// -const query = "SELECT * FROM users WHERE id = " + userId;
|
|
432
|
-
// +const query = "SELECT * FROM users WHERE id = ?";
|
|
433
|
-
// +db.query(query, [userId]);
|
|
434
|
-
|
|
435
|
-
// 複数修正のバッチパッチ
|
|
436
|
-
const batchPatch = generator.generateBatchPatch(fixes);
|
|
437
|
-
await batchPatch.writeToFile('./security-fixes.patch');
|
|
438
|
-
```
|
|
439
|
-
|
|
440
|
-
### 5.5 CI/CD統合
|
|
441
|
-
|
|
442
|
-
```typescript
|
|
443
|
-
import { CIIntegration, GitHubActions, GitLabCI } from '@nahisaho/musubix-security';
|
|
444
|
-
|
|
445
|
-
// GitHub Actions統合
|
|
446
|
-
const github = new GitHubActions({
|
|
447
|
-
token: process.env.GITHUB_TOKEN,
|
|
448
|
-
repo: 'owner/repo',
|
|
449
|
-
});
|
|
450
|
-
|
|
451
|
-
// セキュリティスキャン結果をPRコメント
|
|
452
|
-
await github.commentOnPR(prNumber, {
|
|
453
|
-
violations: scanResult.violations,
|
|
454
|
-
fixes: generatedFixes,
|
|
455
|
-
summary: true,
|
|
456
|
-
});
|
|
457
|
-
|
|
458
|
-
// 自動修正PR作成
|
|
459
|
-
await github.createFixPR({
|
|
460
|
-
fixes: generatedFixes,
|
|
461
|
-
branch: 'security/auto-fix',
|
|
462
|
-
title: 'Security: Auto-fix vulnerabilities',
|
|
463
|
-
labels: ['security', 'auto-generated'],
|
|
464
|
-
});
|
|
465
|
-
```
|
|
466
|
-
|
|
467
|
-
### 5.6 パイプラインオーケストレーション
|
|
468
|
-
|
|
469
|
-
```typescript
|
|
470
|
-
import {
|
|
471
|
-
SecurityPipeline,
|
|
472
|
-
PipelineStage,
|
|
473
|
-
PipelineConfig,
|
|
474
|
-
} from '@nahisaho/musubix-security';
|
|
475
|
-
|
|
476
|
-
const pipeline = new SecurityPipeline({
|
|
477
|
-
stages: [
|
|
478
|
-
PipelineStage.SCAN, // 脆弱性スキャン
|
|
479
|
-
PipelineStage.TAINT_ANALYSIS, // テイント解析
|
|
480
|
-
PipelineStage.CVE_CHECK, // CVEチェック
|
|
481
|
-
PipelineStage.RULE_CHECK, // ルールチェック
|
|
482
|
-
PipelineStage.FIX_GENERATION, // 修正生成
|
|
483
|
-
PipelineStage.VALIDATION, // 検証
|
|
484
|
-
PipelineStage.REPORT, // レポート生成
|
|
485
|
-
],
|
|
486
|
-
parallel: true,
|
|
487
|
-
failFast: false,
|
|
488
|
-
});
|
|
489
|
-
|
|
490
|
-
const result = await pipeline.run('./src');
|
|
491
|
-
|
|
492
|
-
console.log(result.summary);
|
|
493
|
-
// {
|
|
494
|
-
// totalVulnerabilities: 15,
|
|
495
|
-
// fixable: 12,
|
|
496
|
-
// fixed: 10,
|
|
497
|
-
// manualReviewRequired: 5,
|
|
498
|
-
// duration: '45s'
|
|
499
|
-
// }
|
|
500
|
-
```
|
|
501
|
-
|
|
502
|
-
---
|
|
503
|
-
|
|
504
|
-
## 6. 使用例
|
|
505
|
-
|
|
506
|
-
### 6.1 基本的なセキュリティスキャン
|
|
507
|
-
|
|
508
|
-
```typescript
|
|
509
|
-
import { SecurityService } from '@nahisaho/musubix-security';
|
|
510
|
-
|
|
511
|
-
const service = new SecurityService({
|
|
512
|
-
profile: 'strict',
|
|
513
|
-
enableTaintAnalysis: true,
|
|
514
|
-
enableCVECheck: true,
|
|
515
|
-
});
|
|
516
|
-
|
|
517
|
-
const result = await service.scan('./src');
|
|
518
|
-
|
|
519
|
-
console.log(`Found ${result.vulnerabilities.length} vulnerabilities`);
|
|
520
|
-
console.log(`Critical: ${result.summary.critical}`);
|
|
521
|
-
console.log(`High: ${result.summary.high}`);
|
|
522
|
-
```
|
|
523
|
-
|
|
524
|
-
### 6.2 自動修正ワークフロー
|
|
525
|
-
|
|
526
|
-
```typescript
|
|
527
|
-
import {
|
|
528
|
-
SecurityService,
|
|
529
|
-
AutoFixer,
|
|
530
|
-
ReportGenerator,
|
|
531
|
-
} from '@nahisaho/musubix-security';
|
|
532
|
-
|
|
533
|
-
// スキャン
|
|
534
|
-
const service = new SecurityService({ profile: 'strict' });
|
|
535
|
-
const scanResult = await service.scan('./src');
|
|
536
|
-
|
|
537
|
-
// 修正生成
|
|
538
|
-
const fixer = new AutoFixer();
|
|
539
|
-
const fixes = await fixer.generateFixes(scanResult.vulnerabilities);
|
|
540
|
-
|
|
541
|
-
// 修正適用(ドライラン)
|
|
542
|
-
const dryRun = await fixer.applyFixes(fixes, { dryRun: true });
|
|
543
|
-
console.log(`${dryRun.applied} fixes would be applied`);
|
|
544
|
-
|
|
545
|
-
// レポート生成
|
|
546
|
-
const reporter = new ReportGenerator();
|
|
547
|
-
await reporter.generate(scanResult, {
|
|
548
|
-
format: 'html',
|
|
549
|
-
output: './security-report.html',
|
|
550
|
-
includeFixes: true,
|
|
551
|
-
});
|
|
552
|
-
```
|
|
553
|
-
|
|
554
|
-
### 6.3 CI/CDパイプライン統合
|
|
555
|
-
|
|
556
|
-
```yaml
|
|
557
|
-
# .github/workflows/security.yml
|
|
558
|
-
name: Security Scan
|
|
559
|
-
|
|
560
|
-
on: [push, pull_request]
|
|
561
|
-
|
|
562
|
-
jobs:
|
|
563
|
-
security:
|
|
564
|
-
runs-on: ubuntu-latest
|
|
565
|
-
steps:
|
|
566
|
-
- uses: actions/checkout@v4
|
|
567
|
-
|
|
568
|
-
- name: Run MUSUBIX Security
|
|
569
|
-
run: |
|
|
570
|
-
npx musubix security scan ./src \
|
|
571
|
-
--profile strict \
|
|
572
|
-
--format sarif \
|
|
573
|
-
--output security-results.sarif
|
|
574
|
-
|
|
575
|
-
- name: Upload SARIF
|
|
576
|
-
uses: github/codeql-action/upload-sarif@v3
|
|
577
|
-
with:
|
|
578
|
-
sarif_file: security-results.sarif
|
|
579
|
-
```
|
|
580
|
-
|
|
581
|
-
---
|
|
582
|
-
|
|
583
|
-
## 7. 設定
|
|
584
|
-
|
|
585
|
-
### 7.1 設定ファイル
|
|
586
|
-
|
|
587
|
-
```json
|
|
588
|
-
// musubix.security.json
|
|
589
|
-
{
|
|
590
|
-
"profile": "strict",
|
|
591
|
-
"rules": {
|
|
592
|
-
"CWE-79": "error",
|
|
593
|
-
"CWE-89": "error",
|
|
594
|
-
"CWE-78": "error"
|
|
595
|
-
},
|
|
596
|
-
"taintAnalysis": {
|
|
597
|
-
"enabled": true,
|
|
598
|
-
"maxDepth": 10,
|
|
599
|
-
"trackImplicitFlows": true
|
|
600
|
-
},
|
|
601
|
-
"cveCheck": {
|
|
602
|
-
"enabled": true,
|
|
603
|
-
"apiKey": "${NVD_API_KEY}",
|
|
604
|
-
"cacheTTL": 86400
|
|
605
|
-
},
|
|
606
|
-
"autoFix": {
|
|
607
|
-
"enabled": true,
|
|
608
|
-
"validateFix": true,
|
|
609
|
-
"preserveSemantics": true
|
|
610
|
-
},
|
|
611
|
-
"exclude": [
|
|
612
|
-
"**/node_modules/**",
|
|
613
|
-
"**/dist/**",
|
|
614
|
-
"**/*.test.ts"
|
|
615
|
-
]
|
|
616
|
-
}
|
|
617
|
-
```
|
|
618
|
-
|
|
619
|
-
### 7.2 環境変数
|
|
620
|
-
|
|
621
|
-
| 変数名 | 説明 | デフォルト |
|
|
622
|
-
|--------|------|-----------|
|
|
623
|
-
| `NVD_API_KEY` | NVD APIキー(オプション) | - |
|
|
624
|
-
| `MUSUBIX_SECURITY_PROFILE` | デフォルトプロファイル | `default` |
|
|
625
|
-
| `MUSUBIX_SECURITY_CACHE_DIR` | キャッシュディレクトリ | `.musubix/cache` |
|
|
626
|
-
|
|
627
|
-
---
|
|
628
|
-
|
|
629
|
-
## 8. テスト
|
|
630
|
-
|
|
631
|
-
### 8.1 テスト統計
|
|
632
|
-
|
|
633
|
-
| カテゴリ | テスト数 | 合格率 |
|
|
634
|
-
|---------|---------|--------|
|
|
635
|
-
| テイント分析 | 200+ | 100% |
|
|
636
|
-
| CVE連携 | 150+ | 100% |
|
|
637
|
-
| OWASP/CWE | 700+ | 100% |
|
|
638
|
-
| 自動修正 | 200+ | 100% |
|
|
639
|
-
| 統合テスト | 150+ | 100% |
|
|
640
|
-
| **合計** | **1400+** | **100%** |
|
|
641
|
-
|
|
642
|
-
### 8.2 テスト実行
|
|
643
|
-
|
|
644
|
-
```bash
|
|
645
|
-
# 全テスト
|
|
646
|
-
npm run test
|
|
647
|
-
|
|
648
|
-
# セキュリティパッケージのみ
|
|
649
|
-
npm run test -- --filter @nahisaho/musubix-security
|
|
650
|
-
|
|
651
|
-
# カバレッジ
|
|
652
|
-
npm run test:coverage
|
|
653
|
-
```
|
|
654
|
-
|
|
655
|
-
---
|
|
656
|
-
|
|
657
|
-
## 9. 関連ドキュメント
|
|
658
|
-
|
|
659
|
-
- [MUSUBIX-Security.md](./MUSUBIX-Security.md) - 基本機能ドキュメント
|
|
660
|
-
- [MUSUBIX-Security-Plan.md](./MUSUBIX-Security-Plan.md) - セキュリティ実装計画
|
|
661
|
-
- [API-REFERENCE.md](../API-REFERENCE.md) - APIリファレンス
|
|
662
|
-
- [CHANGELOG.md](../../CHANGELOG.md) - 変更履歴
|
|
663
|
-
|
|
664
|
-
---
|
|
665
|
-
|
|
666
|
-
**作成日**: 2026-01-08
|
|
667
|
-
**バージョン**: 2.1.0
|
|
668
|
-
**作成者**: MUSUBIX Development Team
|