@nahisaho/musubix-security 1.8.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 +105 -0
- package/bin/musubix-security-mcp.js +12 -0
- package/bin/musubix-security.js +12 -0
- package/dist/analysis/dependency-auditor.d.ts +30 -0
- package/dist/analysis/dependency-auditor.d.ts.map +1 -0
- package/dist/analysis/dependency-auditor.js +325 -0
- package/dist/analysis/dependency-auditor.js.map +1 -0
- package/dist/analysis/index.d.ts +9 -0
- package/dist/analysis/index.d.ts.map +1 -0
- package/dist/analysis/index.js +9 -0
- package/dist/analysis/index.js.map +1 -0
- package/dist/analysis/secret-detector.d.ts +44 -0
- package/dist/analysis/secret-detector.d.ts.map +1 -0
- package/dist/analysis/secret-detector.js +465 -0
- package/dist/analysis/secret-detector.js.map +1 -0
- package/dist/analysis/taint-analyzer.d.ts +62 -0
- package/dist/analysis/taint-analyzer.d.ts.map +1 -0
- package/dist/analysis/taint-analyzer.js +519 -0
- package/dist/analysis/taint-analyzer.js.map +1 -0
- package/dist/analysis/vulnerability-scanner.d.ts +58 -0
- package/dist/analysis/vulnerability-scanner.d.ts.map +1 -0
- package/dist/analysis/vulnerability-scanner.js +417 -0
- package/dist/analysis/vulnerability-scanner.js.map +1 -0
- package/dist/cli/commands.d.ts +15 -0
- package/dist/cli/commands.d.ts.map +1 -0
- package/dist/cli/commands.js +405 -0
- package/dist/cli/commands.js.map +1 -0
- package/dist/cli/index.d.ts +6 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +6 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +66 -0
- package/dist/index.js.map +1 -0
- package/dist/infrastructure/ast-parser.d.ts +87 -0
- package/dist/infrastructure/ast-parser.d.ts.map +1 -0
- package/dist/infrastructure/ast-parser.js +273 -0
- package/dist/infrastructure/ast-parser.js.map +1 -0
- package/dist/infrastructure/cache.d.ts +100 -0
- package/dist/infrastructure/cache.d.ts.map +1 -0
- package/dist/infrastructure/cache.js +288 -0
- package/dist/infrastructure/cache.js.map +1 -0
- package/dist/infrastructure/config-loader.d.ts +35 -0
- package/dist/infrastructure/config-loader.d.ts.map +1 -0
- package/dist/infrastructure/config-loader.js +358 -0
- package/dist/infrastructure/config-loader.js.map +1 -0
- package/dist/infrastructure/file-scanner.d.ts +94 -0
- package/dist/infrastructure/file-scanner.d.ts.map +1 -0
- package/dist/infrastructure/file-scanner.js +189 -0
- package/dist/infrastructure/file-scanner.js.map +1 -0
- package/dist/infrastructure/index.d.ts +9 -0
- package/dist/infrastructure/index.d.ts.map +1 -0
- package/dist/infrastructure/index.js +9 -0
- package/dist/infrastructure/index.js.map +1 -0
- package/dist/mcp/index.d.ts +7 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +7 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/server.d.ts +34 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +88 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tools.d.ts +88 -0
- package/dist/mcp/tools.d.ts.map +1 -0
- package/dist/mcp/tools.js +443 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/services/fix-generator.d.ts +56 -0
- package/dist/services/fix-generator.d.ts.map +1 -0
- package/dist/services/fix-generator.js +346 -0
- package/dist/services/fix-generator.js.map +1 -0
- package/dist/services/fix-verifier.d.ts +62 -0
- package/dist/services/fix-verifier.d.ts.map +1 -0
- package/dist/services/fix-verifier.js +224 -0
- package/dist/services/fix-verifier.js.map +1 -0
- package/dist/services/index.d.ts +9 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +13 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/report-generator.d.ts +87 -0
- package/dist/services/report-generator.d.ts.map +1 -0
- package/dist/services/report-generator.js +463 -0
- package/dist/services/report-generator.js.map +1 -0
- package/dist/services/security-service.d.ts +151 -0
- package/dist/services/security-service.d.ts.map +1 -0
- package/dist/services/security-service.js +279 -0
- package/dist/services/security-service.js.map +1 -0
- package/dist/types/config.d.ts +188 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +89 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/dependency.d.ts +266 -0
- package/dist/types/dependency.d.ts.map +1 -0
- package/dist/types/dependency.js +7 -0
- package/dist/types/dependency.js.map +1 -0
- package/dist/types/fix.d.ts +213 -0
- package/dist/types/fix.d.ts.map +1 -0
- package/dist/types/fix.js +7 -0
- package/dist/types/fix.js.map +1 -0
- package/dist/types/index.d.ts +14 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +8 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/secret.d.ts +151 -0
- package/dist/types/secret.d.ts.map +1 -0
- package/dist/types/secret.js +91 -0
- package/dist/types/secret.js.map +1 -0
- package/dist/types/taint.d.ts +182 -0
- package/dist/types/taint.d.ts.map +1 -0
- package/dist/types/taint.js +24 -0
- package/dist/types/taint.js.map +1 -0
- package/dist/types/vulnerability.d.ts +136 -0
- package/dist/types/vulnerability.d.ts.map +1 -0
- package/dist/types/vulnerability.js +7 -0
- package/dist/types/vulnerability.js.map +1 -0
- package/package.json +87 -0
package/README.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# @nahisaho/musubix-security
|
|
2
|
+
|
|
3
|
+
MUSUBIX Security Package - セキュリティ分析と脆弱性検出
|
|
4
|
+
|
|
5
|
+
## 概要
|
|
6
|
+
|
|
7
|
+
MUSUBIXシステムにセキュリティ特化機能を提供するパッケージです。
|
|
8
|
+
|
|
9
|
+
### 主な機能
|
|
10
|
+
|
|
11
|
+
- **脆弱性スキャン**: OWASP Top 10、CWE Top 25対応
|
|
12
|
+
- **テイント分析**: データフロー追跡による汚染検出
|
|
13
|
+
- **自動修正**: LLM(VS Code LM API)+ Z3形式検証による安全な修正
|
|
14
|
+
- **シークレット検出**: APIキー、トークン、パスワードの検出
|
|
15
|
+
- **依存関係監査**: npm依存関係の脆弱性チェック
|
|
16
|
+
|
|
17
|
+
## インストール
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @nahisaho/musubix-security
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## 使用方法
|
|
24
|
+
|
|
25
|
+
### CLI
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# 脆弱性スキャン
|
|
29
|
+
npx musubix-security scan ./src
|
|
30
|
+
|
|
31
|
+
# 自動修正
|
|
32
|
+
npx musubix-security fix VULN-2026-001
|
|
33
|
+
|
|
34
|
+
# 依存関係監査
|
|
35
|
+
npx musubix-security audit-deps
|
|
36
|
+
|
|
37
|
+
# シークレット検出
|
|
38
|
+
npx musubix-security detect-secrets ./src
|
|
39
|
+
|
|
40
|
+
# コンプライアンスチェック
|
|
41
|
+
npx musubix-security compliance --standard asvs
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Library API
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import {
|
|
48
|
+
VulnerabilityScanner,
|
|
49
|
+
TaintAnalyzer,
|
|
50
|
+
FixPipeline,
|
|
51
|
+
SecretsDetector,
|
|
52
|
+
DependencyAuditor
|
|
53
|
+
} from '@nahisaho/musubix-security';
|
|
54
|
+
|
|
55
|
+
// 脆弱性スキャン
|
|
56
|
+
const scanner = new VulnerabilityScanner();
|
|
57
|
+
const result = await scanner.scan(['./src/**/*.ts']);
|
|
58
|
+
|
|
59
|
+
// テイント分析
|
|
60
|
+
const taintAnalyzer = new TaintAnalyzer();
|
|
61
|
+
const taintResult = await taintAnalyzer.analyze(code, 'file.ts');
|
|
62
|
+
|
|
63
|
+
// 自動修正
|
|
64
|
+
const fixPipeline = new FixPipeline();
|
|
65
|
+
const fixes = await fixPipeline.generateFix(vulnerability);
|
|
66
|
+
const verified = await fixPipeline.verifyFix(fixes[0]);
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## 設定
|
|
70
|
+
|
|
71
|
+
プロジェクトルートに `.musubix-security.yaml` を作成:
|
|
72
|
+
|
|
73
|
+
```yaml
|
|
74
|
+
version: "1.0"
|
|
75
|
+
|
|
76
|
+
scan:
|
|
77
|
+
rulesets:
|
|
78
|
+
- owasp-top-10
|
|
79
|
+
- cwe-top-25
|
|
80
|
+
severity:
|
|
81
|
+
- critical
|
|
82
|
+
- high
|
|
83
|
+
exclude:
|
|
84
|
+
- "**/node_modules/**"
|
|
85
|
+
- "**/*.test.ts"
|
|
86
|
+
|
|
87
|
+
fix:
|
|
88
|
+
llm:
|
|
89
|
+
enabled: true
|
|
90
|
+
model: "copilot"
|
|
91
|
+
autoApply: false
|
|
92
|
+
|
|
93
|
+
secrets:
|
|
94
|
+
entropyThreshold: 4.5
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## トレーサビリティ
|
|
98
|
+
|
|
99
|
+
- **要件定義**: REQ-SEC-001
|
|
100
|
+
- **設計書**: DES-SEC-001
|
|
101
|
+
- **テスト**: TST-SEC-*
|
|
102
|
+
|
|
103
|
+
## ライセンス
|
|
104
|
+
|
|
105
|
+
MIT
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview MUSUBIX Security MCP Server entry point
|
|
4
|
+
* @module @nahisaho/musubix-security/bin/mcp
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { runMCPServer } from '../dist/mcp/index.js';
|
|
8
|
+
|
|
9
|
+
runMCPServer().catch((error) => {
|
|
10
|
+
console.error('Fatal error:', error.message);
|
|
11
|
+
process.exit(1);
|
|
12
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview MUSUBIX Security CLI entry point
|
|
4
|
+
* @module @nahisaho/musubix-security/bin
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { runCLI } from '../dist/cli/index.js';
|
|
8
|
+
|
|
9
|
+
runCLI().catch((error) => {
|
|
10
|
+
console.error('Fatal error:', error.message);
|
|
11
|
+
process.exit(1);
|
|
12
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Dependency auditor - check for vulnerable dependencies
|
|
3
|
+
* @module @nahisaho/musubix-security/analysis/dependency-auditor
|
|
4
|
+
* @trace REQ-SEC-DEP-001, REQ-SEC-DEP-002, REQ-SEC-DEP-003
|
|
5
|
+
*/
|
|
6
|
+
import type { AuditResult, AuditOptions, SBOM, SBOMOptions } from '../types/index.js';
|
|
7
|
+
/**
|
|
8
|
+
* Dependency auditor
|
|
9
|
+
*/
|
|
10
|
+
export declare class DependencyAuditor {
|
|
11
|
+
private options;
|
|
12
|
+
constructor(options?: AuditOptions);
|
|
13
|
+
/**
|
|
14
|
+
* Generate upgrade suggestions
|
|
15
|
+
*/
|
|
16
|
+
private generateUpgradeSuggestions;
|
|
17
|
+
/**
|
|
18
|
+
* Audit dependencies in a project
|
|
19
|
+
*/
|
|
20
|
+
audit(projectPath: string): Promise<AuditResult>;
|
|
21
|
+
/**
|
|
22
|
+
* Generate SBOM for a project
|
|
23
|
+
*/
|
|
24
|
+
generateSBOM(projectPath: string, options?: SBOMOptions): Promise<SBOM>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Create a dependency auditor
|
|
28
|
+
*/
|
|
29
|
+
export declare function createDependencyAuditor(options?: AuditOptions): DependencyAuditor;
|
|
30
|
+
//# sourceMappingURL=dependency-auditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependency-auditor.d.ts","sourceRoot":"","sources":["../../src/analysis/dependency-auditor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EAIZ,IAAI,EAEJ,WAAW,EAGZ,MAAM,mBAAmB,CAAC;AA+K3B;;GAEG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,OAAO,CAAe;gBAElB,OAAO,GAAE,YAAiB;IAItC;;OAEG;IACH,OAAO,CAAC,0BAA0B;IA0ClC;;OAEG;IACG,KAAK,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAqFtD;;OAEG;IACG,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;CAgE9E;AAwBD;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,iBAAiB,CAEjF"}
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Dependency auditor - check for vulnerable dependencies
|
|
3
|
+
* @module @nahisaho/musubix-security/analysis/dependency-auditor
|
|
4
|
+
* @trace REQ-SEC-DEP-001, REQ-SEC-DEP-002, REQ-SEC-DEP-003
|
|
5
|
+
*/
|
|
6
|
+
import { exec } from 'node:child_process';
|
|
7
|
+
import { readFile, access, constants } from 'node:fs/promises';
|
|
8
|
+
import { join } from 'node:path';
|
|
9
|
+
import { promisify } from 'node:util';
|
|
10
|
+
const execAsync = promisify(exec);
|
|
11
|
+
/**
|
|
12
|
+
* Detect package manager from project
|
|
13
|
+
*/
|
|
14
|
+
async function detectPackageManager(projectPath) {
|
|
15
|
+
// Check for lock files
|
|
16
|
+
const checks = [
|
|
17
|
+
{ file: 'pnpm-lock.yaml', manager: 'pnpm' },
|
|
18
|
+
{ file: 'yarn.lock', manager: 'yarn' },
|
|
19
|
+
{ file: 'package-lock.json', manager: 'npm' },
|
|
20
|
+
];
|
|
21
|
+
for (const { file, manager } of checks) {
|
|
22
|
+
try {
|
|
23
|
+
await access(join(projectPath, file), constants.R_OK);
|
|
24
|
+
return manager;
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
// File doesn't exist, continue checking
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return 'npm'; // Default to npm
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Convert npm severity to our severity
|
|
34
|
+
*/
|
|
35
|
+
function convertSeverity(npmSeverity) {
|
|
36
|
+
switch (npmSeverity.toLowerCase()) {
|
|
37
|
+
case 'critical':
|
|
38
|
+
return 'critical';
|
|
39
|
+
case 'high':
|
|
40
|
+
return 'high';
|
|
41
|
+
case 'moderate':
|
|
42
|
+
case 'medium':
|
|
43
|
+
return 'medium';
|
|
44
|
+
case 'low':
|
|
45
|
+
return 'low';
|
|
46
|
+
default:
|
|
47
|
+
return 'medium';
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Parse npm audit output to our format
|
|
52
|
+
*/
|
|
53
|
+
function parseNpmAuditOutput(output) {
|
|
54
|
+
const vulnerabilities = [];
|
|
55
|
+
const metadata = {
|
|
56
|
+
total: output.metadata?.dependencies?.total ?? 0,
|
|
57
|
+
direct: output.metadata?.dependencies?.prod ?? 0,
|
|
58
|
+
transitive: 0,
|
|
59
|
+
critical: output.metadata?.vulnerabilities?.critical ?? 0,
|
|
60
|
+
high: output.metadata?.vulnerabilities?.high ?? 0,
|
|
61
|
+
moderate: output.metadata?.vulnerabilities?.moderate ?? 0,
|
|
62
|
+
low: output.metadata?.vulnerabilities?.low ?? 0,
|
|
63
|
+
};
|
|
64
|
+
if (!output.vulnerabilities) {
|
|
65
|
+
return { vulnerabilities, metadata };
|
|
66
|
+
}
|
|
67
|
+
for (const [name, vuln] of Object.entries(output.vulnerabilities)) {
|
|
68
|
+
const depVulns = [];
|
|
69
|
+
for (const via of vuln.via) {
|
|
70
|
+
if (typeof via === 'object') {
|
|
71
|
+
depVulns.push({
|
|
72
|
+
id: String(via.source),
|
|
73
|
+
cve: undefined, // npm audit doesn't always provide CVE
|
|
74
|
+
cwes: via.cwe || [],
|
|
75
|
+
severity: convertSeverity(via.severity),
|
|
76
|
+
title: via.title,
|
|
77
|
+
description: via.title,
|
|
78
|
+
affectedVersions: via.range,
|
|
79
|
+
source: 'npm-audit',
|
|
80
|
+
url: via.url,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// Determine dependency type
|
|
85
|
+
let type = 'production';
|
|
86
|
+
// Note: npm audit doesn't directly tell us the type, we'd need to cross-reference with package.json
|
|
87
|
+
// Check fix availability
|
|
88
|
+
let fixAvailable = false;
|
|
89
|
+
let patchedVersion;
|
|
90
|
+
if (typeof vuln.fixAvailable === 'object') {
|
|
91
|
+
fixAvailable = true;
|
|
92
|
+
patchedVersion = vuln.fixAvailable.version;
|
|
93
|
+
}
|
|
94
|
+
else if (vuln.fixAvailable === true) {
|
|
95
|
+
fixAvailable = true;
|
|
96
|
+
}
|
|
97
|
+
// Update patched version in vulnerabilities
|
|
98
|
+
if (patchedVersion && depVulns.length > 0) {
|
|
99
|
+
depVulns[0].patchedVersion = patchedVersion;
|
|
100
|
+
}
|
|
101
|
+
vulnerabilities.push({
|
|
102
|
+
name,
|
|
103
|
+
installedVersion: vuln.range,
|
|
104
|
+
type,
|
|
105
|
+
isDirect: vuln.isDirect,
|
|
106
|
+
dependencyPath: vuln.effects,
|
|
107
|
+
vulnerabilities: depVulns,
|
|
108
|
+
highestSeverity: convertSeverity(vuln.severity),
|
|
109
|
+
fixAvailable,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
metadata.transitive = metadata.total - metadata.direct;
|
|
113
|
+
return { vulnerabilities, metadata };
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Dependency auditor
|
|
117
|
+
*/
|
|
118
|
+
export class DependencyAuditor {
|
|
119
|
+
options;
|
|
120
|
+
constructor(options = {}) {
|
|
121
|
+
this.options = options;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Generate upgrade suggestions
|
|
125
|
+
*/
|
|
126
|
+
generateUpgradeSuggestions(vulnerabilities) {
|
|
127
|
+
const suggestions = [];
|
|
128
|
+
for (const vuln of vulnerabilities) {
|
|
129
|
+
if (!vuln.fixAvailable)
|
|
130
|
+
continue;
|
|
131
|
+
const fixedVulns = vuln.vulnerabilities
|
|
132
|
+
.filter((v) => v.patchedVersion)
|
|
133
|
+
.map((v) => v.id);
|
|
134
|
+
if (fixedVulns.length === 0)
|
|
135
|
+
continue;
|
|
136
|
+
const patchedVersion = vuln.vulnerabilities[0]?.patchedVersion;
|
|
137
|
+
if (!patchedVersion)
|
|
138
|
+
continue;
|
|
139
|
+
// Determine upgrade type
|
|
140
|
+
const currentParts = vuln.installedVersion.replace(/[\^~>=<]/g, '').split('.');
|
|
141
|
+
const targetParts = patchedVersion.split('.');
|
|
142
|
+
let upgradeType = 'patch';
|
|
143
|
+
if (currentParts[0] !== targetParts[0]) {
|
|
144
|
+
upgradeType = 'major';
|
|
145
|
+
}
|
|
146
|
+
else if (currentParts[1] !== targetParts[1]) {
|
|
147
|
+
upgradeType = 'minor';
|
|
148
|
+
}
|
|
149
|
+
suggestions.push({
|
|
150
|
+
packageName: vuln.name,
|
|
151
|
+
currentVersion: vuln.installedVersion,
|
|
152
|
+
suggestedVersion: patchedVersion,
|
|
153
|
+
upgradeType,
|
|
154
|
+
breaking: upgradeType === 'major',
|
|
155
|
+
fixesVulnerabilities: fixedVulns,
|
|
156
|
+
confidence: upgradeType === 'major' ? 0.6 : upgradeType === 'minor' ? 0.8 : 0.95,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
return suggestions;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Audit dependencies in a project
|
|
163
|
+
*/
|
|
164
|
+
async audit(projectPath) {
|
|
165
|
+
const startTime = Date.now();
|
|
166
|
+
// Detect package manager
|
|
167
|
+
const packageManager = await detectPackageManager(projectPath);
|
|
168
|
+
// Read lock file path
|
|
169
|
+
const lockFiles = {
|
|
170
|
+
npm: 'package-lock.json',
|
|
171
|
+
yarn: 'yarn.lock',
|
|
172
|
+
pnpm: 'pnpm-lock.yaml',
|
|
173
|
+
};
|
|
174
|
+
const lockFilePath = join(projectPath, lockFiles[packageManager]);
|
|
175
|
+
// Run audit
|
|
176
|
+
let auditOutput;
|
|
177
|
+
try {
|
|
178
|
+
// For now, we only support npm audit
|
|
179
|
+
// TODO: Add yarn and pnpm support
|
|
180
|
+
auditOutput = await runNpmAudit(projectPath);
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
console.warn(`Warning: Failed to run audit: ${error}`);
|
|
184
|
+
auditOutput = { vulnerabilities: {}, metadata: undefined };
|
|
185
|
+
}
|
|
186
|
+
const { vulnerabilities, metadata } = parseNpmAuditOutput(auditOutput);
|
|
187
|
+
// Apply filters
|
|
188
|
+
let filteredVulns = vulnerabilities;
|
|
189
|
+
// Filter by severity
|
|
190
|
+
if (this.options.minSeverity) {
|
|
191
|
+
const severityOrder = ['low', 'medium', 'high', 'critical'];
|
|
192
|
+
const minIndex = severityOrder.indexOf(this.options.minSeverity);
|
|
193
|
+
filteredVulns = filteredVulns.filter((v) => {
|
|
194
|
+
const vulnIndex = severityOrder.indexOf(v.highestSeverity);
|
|
195
|
+
return vulnIndex >= minIndex;
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
// Filter ignored vulnerabilities
|
|
199
|
+
if (this.options.ignoreVulnerabilities) {
|
|
200
|
+
filteredVulns = filteredVulns.filter((v) => {
|
|
201
|
+
return !v.vulnerabilities.some((vuln) => this.options.ignoreVulnerabilities.includes(vuln.id));
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
// Filter ignored packages
|
|
205
|
+
if (this.options.ignorePackages) {
|
|
206
|
+
filteredVulns = filteredVulns.filter((v) => !this.options.ignorePackages.includes(v.name));
|
|
207
|
+
}
|
|
208
|
+
// Generate upgrade suggestions
|
|
209
|
+
const upgradeSuggestions = this.options.suggestUpgrades
|
|
210
|
+
? this.generateUpgradeSuggestions(filteredVulns)
|
|
211
|
+
: [];
|
|
212
|
+
const duration = Date.now() - startTime;
|
|
213
|
+
return {
|
|
214
|
+
vulnerableDependencies: filteredVulns,
|
|
215
|
+
upgradeSuggestions,
|
|
216
|
+
totalDependencies: metadata.total,
|
|
217
|
+
directDependencies: metadata.direct,
|
|
218
|
+
transitiveDependencies: metadata.transitive,
|
|
219
|
+
duration,
|
|
220
|
+
timestamp: new Date(),
|
|
221
|
+
packageManager,
|
|
222
|
+
lockFilePath,
|
|
223
|
+
summary: {
|
|
224
|
+
critical: filteredVulns.filter((v) => v.highestSeverity === 'critical').length,
|
|
225
|
+
high: filteredVulns.filter((v) => v.highestSeverity === 'high').length,
|
|
226
|
+
medium: filteredVulns.filter((v) => v.highestSeverity === 'medium').length,
|
|
227
|
+
low: filteredVulns.filter((v) => v.highestSeverity === 'low').length,
|
|
228
|
+
total: filteredVulns.length,
|
|
229
|
+
fixable: filteredVulns.filter((v) => v.fixAvailable).length,
|
|
230
|
+
breaking: upgradeSuggestions.filter((s) => s.breaking).length,
|
|
231
|
+
},
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Generate SBOM for a project
|
|
236
|
+
*/
|
|
237
|
+
async generateSBOM(projectPath, options) {
|
|
238
|
+
const format = options?.format ?? 'cyclonedx';
|
|
239
|
+
// Read package.json
|
|
240
|
+
const packageJsonPath = join(projectPath, 'package.json');
|
|
241
|
+
const packageJson = JSON.parse(await readFile(packageJsonPath, 'utf-8'));
|
|
242
|
+
// Get audit results for vulnerability info
|
|
243
|
+
const auditResult = options?.includeVulnerabilities
|
|
244
|
+
? await this.audit(projectPath)
|
|
245
|
+
: null;
|
|
246
|
+
const components = [];
|
|
247
|
+
// Add direct dependencies
|
|
248
|
+
const addDeps = (deps, type) => {
|
|
249
|
+
if (!deps)
|
|
250
|
+
return;
|
|
251
|
+
for (const [name, version] of Object.entries(deps)) {
|
|
252
|
+
const cleanVersion = version.replace(/[\^~>=<]/g, '');
|
|
253
|
+
const vuln = auditResult?.vulnerableDependencies.find((v) => v.name === name);
|
|
254
|
+
components.push({
|
|
255
|
+
name,
|
|
256
|
+
version: cleanVersion,
|
|
257
|
+
type,
|
|
258
|
+
isDirect: true,
|
|
259
|
+
purl: `pkg:npm/${name}@${cleanVersion}`,
|
|
260
|
+
vulnerabilityCount: vuln?.vulnerabilities.length ?? 0,
|
|
261
|
+
highestSeverity: vuln?.highestSeverity,
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
addDeps(packageJson.dependencies, 'production');
|
|
266
|
+
if (options?.includeDevDependencies) {
|
|
267
|
+
addDeps(packageJson.devDependencies, 'development');
|
|
268
|
+
}
|
|
269
|
+
// Get unique licenses
|
|
270
|
+
const licenses = new Set();
|
|
271
|
+
for (const comp of components) {
|
|
272
|
+
if (comp.license)
|
|
273
|
+
licenses.add(comp.license);
|
|
274
|
+
}
|
|
275
|
+
return {
|
|
276
|
+
formatVersion: '1.4',
|
|
277
|
+
spec: format,
|
|
278
|
+
projectName: packageJson.name || 'unknown',
|
|
279
|
+
projectVersion: packageJson.version || '0.0.0',
|
|
280
|
+
generatedAt: new Date(),
|
|
281
|
+
generator: {
|
|
282
|
+
name: '@nahisaho/musubix-security',
|
|
283
|
+
version: '1.8.0',
|
|
284
|
+
},
|
|
285
|
+
components,
|
|
286
|
+
summary: {
|
|
287
|
+
totalComponents: components.length,
|
|
288
|
+
directDependencies: components.filter((c) => c.isDirect).length,
|
|
289
|
+
transitiveDependencies: components.filter((c) => !c.isDirect).length,
|
|
290
|
+
uniqueLicenses: Array.from(licenses),
|
|
291
|
+
vulnerableComponents: components.filter((c) => c.vulnerabilityCount > 0).length,
|
|
292
|
+
},
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Helper function to run npm audit
|
|
298
|
+
*/
|
|
299
|
+
async function runNpmAudit(projectPath) {
|
|
300
|
+
try {
|
|
301
|
+
const { stdout } = await execAsync('npm audit --json', {
|
|
302
|
+
cwd: projectPath,
|
|
303
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
304
|
+
});
|
|
305
|
+
return JSON.parse(stdout);
|
|
306
|
+
}
|
|
307
|
+
catch (error) {
|
|
308
|
+
if (error.stdout) {
|
|
309
|
+
try {
|
|
310
|
+
return JSON.parse(error.stdout);
|
|
311
|
+
}
|
|
312
|
+
catch {
|
|
313
|
+
throw new Error(`Failed to parse npm audit output`);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
throw error;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Create a dependency auditor
|
|
321
|
+
*/
|
|
322
|
+
export function createDependencyAuditor(options) {
|
|
323
|
+
return new DependencyAuditor(options);
|
|
324
|
+
}
|
|
325
|
+
//# sourceMappingURL=dependency-auditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependency-auditor.js","sourceRoot":"","sources":["../../src/analysis/dependency-auditor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AActC,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;AAElC;;GAEG;AACH,KAAK,UAAU,oBAAoB,CACjC,WAAmB;IAEnB,uBAAuB;IACvB,MAAM,MAAM,GAAG;QACb,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAe,EAAE;QACpD,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,MAAe,EAAE;QAC/C,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,KAAc,EAAE;KACvD,CAAC;IAEF,KAAK,MAAM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|
5
|
+
export { VulnerabilityScanner, createVulnerabilityScanner, resetVulnCounter, } from './vulnerability-scanner.js';
|
|
6
|
+
export { TaintAnalyzer, createTaintAnalyzer, resetTaintCounters, } from './taint-analyzer.js';
|
|
7
|
+
export { SecretDetector, createSecretDetector, resetSecretCounter, } from './secret-detector.js';
|
|
8
|
+
export { DependencyAuditor, createDependencyAuditor, } from './dependency-auditor.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/analysis/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,gBAAgB,GACjB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Analysis module entry point
|
|
3
|
+
* @module @nahisaho/musubix-security/analysis
|
|
4
|
+
*/
|
|
5
|
+
export { VulnerabilityScanner, createVulnerabilityScanner, resetVulnCounter, } from './vulnerability-scanner.js';
|
|
6
|
+
export { TaintAnalyzer, createTaintAnalyzer, resetTaintCounters, } from './taint-analyzer.js';
|
|
7
|
+
export { SecretDetector, createSecretDetector, resetSecretCounter, } from './secret-detector.js';
|
|
8
|
+
export { DependencyAuditor, createDependencyAuditor, } from './dependency-auditor.js';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/analysis/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,gBAAgB,GACjB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Secret detection engine
|
|
3
|
+
* @module @nahisaho/musubix-security/analysis/secret-detector
|
|
4
|
+
* @trace REQ-SEC-SECRET-001, REQ-SEC-SECRET-002
|
|
5
|
+
*/
|
|
6
|
+
import type { Secret, SecretPattern, SecretScanOptions, SecretScanResult } from '../types/index.js';
|
|
7
|
+
/**
|
|
8
|
+
* Reset secret counter (for testing)
|
|
9
|
+
*/
|
|
10
|
+
export declare function resetSecretCounter(): void;
|
|
11
|
+
/**
|
|
12
|
+
* Secret detector engine
|
|
13
|
+
*/
|
|
14
|
+
export declare class SecretDetector {
|
|
15
|
+
private patterns;
|
|
16
|
+
private fileScanner;
|
|
17
|
+
private options;
|
|
18
|
+
constructor(options?: SecretScanOptions);
|
|
19
|
+
/**
|
|
20
|
+
* Scan file content for secrets
|
|
21
|
+
*/
|
|
22
|
+
scanContent(content: string, filePath: string): Secret[];
|
|
23
|
+
/**
|
|
24
|
+
* Scan a single file
|
|
25
|
+
*/
|
|
26
|
+
scanFile(filePath: string): Promise<Secret[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Scan a directory for secrets
|
|
29
|
+
*/
|
|
30
|
+
scan(rootPath: string): Promise<SecretScanResult>;
|
|
31
|
+
/**
|
|
32
|
+
* Add a custom pattern
|
|
33
|
+
*/
|
|
34
|
+
addPattern(pattern: SecretPattern): void;
|
|
35
|
+
/**
|
|
36
|
+
* Get all patterns
|
|
37
|
+
*/
|
|
38
|
+
getPatterns(): SecretPattern[];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Create a secret detector
|
|
42
|
+
*/
|
|
43
|
+
export declare function createSecretDetector(options?: SecretScanOptions): SecretDetector;
|
|
44
|
+
//# sourceMappingURL=secret-detector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secret-detector.d.ts","sourceRoot":"","sources":["../../src/analysis/secret-detector.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EACV,MAAM,EAGN,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAGjB,MAAM,mBAAmB,CAAC;AAa3B;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC;AA0RD;;GAEG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,OAAO,CAAoB;gBAEvB,OAAO,GAAE,iBAAsB;IAqB3C;;OAEG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE;IAqExD;;OAEG;IACG,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAKnD;;OAEG;IACG,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAsDvD;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAIxC;;OAEG;IACH,WAAW,IAAI,aAAa,EAAE;CAG/B;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,cAAc,CAEhF"}
|