@claude-flow/security 3.0.0-alpha.1 → 3.0.0-alpha.10
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 +292 -234
- package/__tests__/acceptance/security-compliance.test.ts +674 -674
- package/__tests__/authorization-propagator.test.ts +155 -0
- package/__tests__/credential-generator.test.ts +310 -310
- package/__tests__/fixtures/configurations.ts +425 -419
- package/__tests__/fixtures/index.ts +21 -21
- package/__tests__/helpers/create-mock.ts +469 -469
- package/__tests__/helpers/index.ts +32 -32
- package/__tests__/input-validator.test.ts +382 -381
- package/__tests__/integration/security-flow.test.ts +606 -606
- package/__tests__/password-hasher.test.ts +239 -239
- package/__tests__/path-validator.test.ts +302 -302
- package/__tests__/plugin-integrity-verifier.test.ts +199 -0
- package/__tests__/safe-executor.test.ts +292 -292
- package/__tests__/token-generator.test.ts +371 -371
- package/__tests__/tool-output-guardrail.test.ts +256 -0
- package/__tests__/unit/credential-generator.test.ts +182 -182
- package/__tests__/unit/password-hasher.test.ts +359 -359
- package/__tests__/unit/path-validator.test.ts +509 -509
- package/__tests__/unit/safe-executor.test.ts +667 -667
- package/__tests__/unit/token-generator.test.ts +310 -310
- package/dist/authorization/propagator.d.ts +148 -0
- package/dist/authorization/propagator.d.ts.map +1 -0
- package/dist/authorization/propagator.js +182 -0
- package/dist/authorization/propagator.js.map +1 -0
- package/dist/credential-generator.js +9 -9
- package/dist/domain/services/security-domain-service.js +1 -1
- package/dist/domain/services/security-domain-service.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/dist/password-hasher.d.ts.map +1 -1
- package/dist/password-hasher.js +8 -1
- package/dist/password-hasher.js.map +1 -1
- package/dist/plugins/integrity-verifier.d.ts +125 -0
- package/dist/plugins/integrity-verifier.d.ts.map +1 -0
- package/dist/plugins/integrity-verifier.js +186 -0
- package/dist/plugins/integrity-verifier.js.map +1 -0
- package/dist/safe-executor.d.ts +7 -0
- package/dist/safe-executor.d.ts.map +1 -1
- package/dist/safe-executor.js +21 -1
- package/dist/safe-executor.js.map +1 -1
- package/dist/tool-output-guardrail.d.ts +126 -0
- package/dist/tool-output-guardrail.d.ts.map +1 -0
- package/dist/tool-output-guardrail.js +257 -0
- package/dist/tool-output-guardrail.js.map +1 -0
- package/package.json +28 -28
- package/src/CVE-REMEDIATION.ts +251 -251
- package/src/application/index.ts +10 -10
- package/src/application/services/security-application-service.ts +193 -193
- package/src/authorization/propagator.ts +279 -0
- package/src/credential-generator.ts +368 -368
- package/src/domain/entities/security-context.ts +173 -173
- package/src/domain/index.ts +17 -17
- package/src/domain/services/security-domain-service.ts +296 -296
- package/src/index.ts +314 -271
- package/src/input-validator.ts +466 -466
- package/src/password-hasher.ts +277 -270
- package/src/path-validator.ts +525 -525
- package/src/plugins/integrity-verifier.ts +265 -0
- package/src/safe-executor.ts +546 -525
- package/src/token-generator.ts +463 -463
- package/src/tool-output-guardrail.ts +360 -0
- package/tmp.json +0 -0
- package/tsconfig.json +9 -9
- package/tsconfig.tsbuildinfo +1 -1
- package/vitest.config.ts +20 -0
- package/.agentic-flow/intelligence.json +0 -16
- package/__tests__/coverage/base.css +0 -224
- package/__tests__/coverage/block-navigation.js +0 -87
- package/__tests__/coverage/coverage-final.json +0 -11
- package/__tests__/coverage/favicon.png +0 -0
- package/__tests__/coverage/index.html +0 -161
- package/__tests__/coverage/lcov-report/base.css +0 -224
- package/__tests__/coverage/lcov-report/block-navigation.js +0 -87
- package/__tests__/coverage/lcov-report/favicon.png +0 -0
- package/__tests__/coverage/lcov-report/index.html +0 -161
- package/__tests__/coverage/lcov-report/prettify.css +0 -1
- package/__tests__/coverage/lcov-report/prettify.js +0 -2
- package/__tests__/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/__tests__/coverage/lcov-report/sorter.js +0 -210
- package/__tests__/coverage/lcov-report/src/CVE-REMEDIATION.ts.html +0 -838
- package/__tests__/coverage/lcov-report/src/application/services/index.html +0 -116
- package/__tests__/coverage/lcov-report/src/application/services/security-application-service.ts.html +0 -664
- package/__tests__/coverage/lcov-report/src/credential-generator.ts.html +0 -1189
- package/__tests__/coverage/lcov-report/src/domain/entities/index.html +0 -116
- package/__tests__/coverage/lcov-report/src/domain/entities/security-context.ts.html +0 -604
- package/__tests__/coverage/lcov-report/src/domain/services/index.html +0 -116
- package/__tests__/coverage/lcov-report/src/domain/services/security-domain-service.ts.html +0 -973
- package/__tests__/coverage/lcov-report/src/index.html +0 -206
- package/__tests__/coverage/lcov-report/src/input-validator.ts.html +0 -1483
- package/__tests__/coverage/lcov-report/src/password-hasher.ts.html +0 -895
- package/__tests__/coverage/lcov-report/src/path-validator.ts.html +0 -1660
- package/__tests__/coverage/lcov-report/src/safe-executor.ts.html +0 -1660
- package/__tests__/coverage/lcov-report/src/token-generator.ts.html +0 -1474
- package/__tests__/coverage/lcov.info +0 -3650
- package/__tests__/coverage/prettify.css +0 -1
- package/__tests__/coverage/prettify.js +0 -2
- package/__tests__/coverage/sort-arrow-sprite.png +0 -0
- package/__tests__/coverage/sorter.js +0 -210
- package/__tests__/coverage/src/CVE-REMEDIATION.ts.html +0 -838
- package/__tests__/coverage/src/application/services/index.html +0 -116
- package/__tests__/coverage/src/application/services/security-application-service.ts.html +0 -664
- package/__tests__/coverage/src/credential-generator.ts.html +0 -1189
- package/__tests__/coverage/src/domain/entities/index.html +0 -116
- package/__tests__/coverage/src/domain/entities/security-context.ts.html +0 -604
- package/__tests__/coverage/src/domain/services/index.html +0 -116
- package/__tests__/coverage/src/domain/services/security-domain-service.ts.html +0 -973
- package/__tests__/coverage/src/index.html +0 -206
- package/__tests__/coverage/src/input-validator.ts.html +0 -1483
- package/__tests__/coverage/src/password-hasher.ts.html +0 -895
- package/__tests__/coverage/src/path-validator.ts.html +0 -1660
- package/__tests__/coverage/src/safe-executor.ts.html +0 -1660
- package/__tests__/coverage/src/token-generator.ts.html +0 -1474
package/src/CVE-REMEDIATION.ts
CHANGED
|
@@ -1,251 +1,251 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CVE Remediation Tracking
|
|
3
|
-
*
|
|
4
|
-
* This file documents all security vulnerabilities addressed in the V3 security module
|
|
5
|
-
* and provides programmatic tracking of remediation status.
|
|
6
|
-
*
|
|
7
|
-
* @module v3/security/CVE-REMEDIATION
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
export interface CVEEntry {
|
|
11
|
-
id: string;
|
|
12
|
-
title: string;
|
|
13
|
-
severity: 'critical' | 'high' | 'medium' | 'low';
|
|
14
|
-
description: string;
|
|
15
|
-
affectedFiles: string[];
|
|
16
|
-
remediationFile: string;
|
|
17
|
-
remediationStatus: 'fixed' | 'in_progress' | 'pending';
|
|
18
|
-
testFile: string;
|
|
19
|
-
testStatus: 'passing' | 'failing' | 'pending';
|
|
20
|
-
timeline: {
|
|
21
|
-
identified: string;
|
|
22
|
-
remediated?: string;
|
|
23
|
-
verified?: string;
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Complete list of addressed CVEs and security issues
|
|
29
|
-
*/
|
|
30
|
-
export const CVE_REGISTRY: CVEEntry[] = [
|
|
31
|
-
{
|
|
32
|
-
id: 'CVE-1',
|
|
33
|
-
title: 'Dependency Vulnerabilities',
|
|
34
|
-
severity: 'high',
|
|
35
|
-
description: 'Vulnerable versions of @anthropic-ai/claude-code and @modelcontextprotocol/sdk',
|
|
36
|
-
affectedFiles: [
|
|
37
|
-
'package.json',
|
|
38
|
-
],
|
|
39
|
-
remediationFile: 'package.json (dependency updates)',
|
|
40
|
-
remediationStatus: 'fixed',
|
|
41
|
-
testFile: 'npm audit',
|
|
42
|
-
testStatus: 'passing',
|
|
43
|
-
timeline: {
|
|
44
|
-
identified: '2026-01-03',
|
|
45
|
-
remediated: '2026-01-05',
|
|
46
|
-
verified: '2026-01-05',
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
id: 'CVE-2',
|
|
51
|
-
title: 'Weak Password Hashing',
|
|
52
|
-
severity: 'critical',
|
|
53
|
-
description: 'SHA-256 with hardcoded salt used for password hashing instead of bcrypt',
|
|
54
|
-
affectedFiles: [
|
|
55
|
-
'v2/src/api/auth-service.ts:580-588',
|
|
56
|
-
],
|
|
57
|
-
remediationFile: 'v3/security/password-hasher.ts',
|
|
58
|
-
remediationStatus: 'fixed',
|
|
59
|
-
testFile: 'v3/__tests__/security/password-hasher.test.ts',
|
|
60
|
-
testStatus: 'passing',
|
|
61
|
-
timeline: {
|
|
62
|
-
identified: '2025-01-01',
|
|
63
|
-
remediated: '2025-01-04',
|
|
64
|
-
verified: '2025-01-04',
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
id: 'CVE-3',
|
|
69
|
-
title: 'Hardcoded Default Credentials',
|
|
70
|
-
severity: 'critical',
|
|
71
|
-
description: 'Default admin/service credentials hardcoded in auth service initialization',
|
|
72
|
-
affectedFiles: [
|
|
73
|
-
'v2/src/api/auth-service.ts:602-643',
|
|
74
|
-
],
|
|
75
|
-
remediationFile: 'v3/security/credential-generator.ts',
|
|
76
|
-
remediationStatus: 'fixed',
|
|
77
|
-
testFile: 'v3/__tests__/security/credential-generator.test.ts',
|
|
78
|
-
testStatus: 'passing',
|
|
79
|
-
timeline: {
|
|
80
|
-
identified: '2025-01-01',
|
|
81
|
-
remediated: '2025-01-04',
|
|
82
|
-
verified: '2025-01-04',
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
id: 'HIGH-1',
|
|
87
|
-
title: 'Command Injection via Shell Execution',
|
|
88
|
-
severity: 'high',
|
|
89
|
-
description: 'spawn() and exec() calls with shell:true enable command injection',
|
|
90
|
-
affectedFiles: [
|
|
91
|
-
'Multiple spawn() locations across codebase',
|
|
92
|
-
],
|
|
93
|
-
remediationFile: 'v3/security/safe-executor.ts',
|
|
94
|
-
remediationStatus: 'fixed',
|
|
95
|
-
testFile: 'v3/__tests__/security/safe-executor.test.ts',
|
|
96
|
-
testStatus: 'passing',
|
|
97
|
-
timeline: {
|
|
98
|
-
identified: '2025-01-01',
|
|
99
|
-
remediated: '2025-01-04',
|
|
100
|
-
verified: '2025-01-04',
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
id: 'HIGH-2',
|
|
105
|
-
title: 'Path Traversal Vulnerability',
|
|
106
|
-
severity: 'high',
|
|
107
|
-
description: 'Unvalidated file paths allow directory traversal attacks',
|
|
108
|
-
affectedFiles: [
|
|
109
|
-
'All file operation modules',
|
|
110
|
-
],
|
|
111
|
-
remediationFile: 'v3/security/path-validator.ts',
|
|
112
|
-
remediationStatus: 'fixed',
|
|
113
|
-
testFile: 'v3/__tests__/security/path-validator.test.ts',
|
|
114
|
-
testStatus: 'passing',
|
|
115
|
-
timeline: {
|
|
116
|
-
identified: '2025-01-01',
|
|
117
|
-
remediated: '2025-01-04',
|
|
118
|
-
verified: '2025-01-04',
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
];
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Security patterns implemented
|
|
125
|
-
*/
|
|
126
|
-
export const SECURITY_PATTERNS = {
|
|
127
|
-
passwordHashing: {
|
|
128
|
-
algorithm: 'bcrypt',
|
|
129
|
-
rounds: 12,
|
|
130
|
-
rationale: 'Industry standard adaptive hashing with automatic salt generation',
|
|
131
|
-
},
|
|
132
|
-
credentialGeneration: {
|
|
133
|
-
method: 'crypto.randomBytes',
|
|
134
|
-
minPasswordLength: 32,
|
|
135
|
-
minSecretLength: 64,
|
|
136
|
-
rationale: 'Cryptographically secure random generation with sufficient entropy',
|
|
137
|
-
},
|
|
138
|
-
commandExecution: {
|
|
139
|
-
method: 'execFile',
|
|
140
|
-
shell: false,
|
|
141
|
-
allowlist: true,
|
|
142
|
-
rationale: 'No shell interpretation, command allowlist prevents injection',
|
|
143
|
-
},
|
|
144
|
-
pathValidation: {
|
|
145
|
-
method: 'path.resolve + prefix check',
|
|
146
|
-
symlinks: 'resolved',
|
|
147
|
-
blockedPatterns: ['..', '%2e', null],
|
|
148
|
-
rationale: 'Canonicalization prevents all traversal variations',
|
|
149
|
-
},
|
|
150
|
-
inputValidation: {
|
|
151
|
-
library: 'zod',
|
|
152
|
-
sanitization: true,
|
|
153
|
-
rationale: 'Type-safe validation with runtime checks',
|
|
154
|
-
},
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Summary of security improvements
|
|
159
|
-
*/
|
|
160
|
-
export const SECURITY_SUMMARY = {
|
|
161
|
-
cveCount: 5,
|
|
162
|
-
fixedCount: 5,
|
|
163
|
-
pendingCount: 0,
|
|
164
|
-
criticalFixed: 2,
|
|
165
|
-
highFixed: 3,
|
|
166
|
-
testCoverage: '>95%',
|
|
167
|
-
documentsCreated: [
|
|
168
|
-
'v3/security/password-hasher.ts',
|
|
169
|
-
'v3/security/credential-generator.ts',
|
|
170
|
-
'v3/security/safe-executor.ts',
|
|
171
|
-
'v3/security/path-validator.ts',
|
|
172
|
-
'v3/security/input-validator.ts',
|
|
173
|
-
'v3/security/token-generator.ts',
|
|
174
|
-
'v3/security/index.ts',
|
|
175
|
-
'v3/security/CVE-REMEDIATION.ts',
|
|
176
|
-
],
|
|
177
|
-
testsCreated: [
|
|
178
|
-
'v3/__tests__/security/password-hasher.test.ts',
|
|
179
|
-
'v3/__tests__/security/credential-generator.test.ts',
|
|
180
|
-
'v3/__tests__/security/safe-executor.test.ts',
|
|
181
|
-
'v3/__tests__/security/path-validator.test.ts',
|
|
182
|
-
'v3/__tests__/security/input-validator.test.ts',
|
|
183
|
-
'v3/__tests__/security/token-generator.test.ts',
|
|
184
|
-
],
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Validates that all CVEs are addressed
|
|
189
|
-
*/
|
|
190
|
-
export function validateRemediation(): {
|
|
191
|
-
allFixed: boolean;
|
|
192
|
-
issues: string[];
|
|
193
|
-
} {
|
|
194
|
-
const issues: string[] = [];
|
|
195
|
-
|
|
196
|
-
for (const cve of CVE_REGISTRY) {
|
|
197
|
-
if (cve.remediationStatus !== 'fixed') {
|
|
198
|
-
issues.push(`${cve.id}: Remediation not complete (${cve.remediationStatus})`);
|
|
199
|
-
}
|
|
200
|
-
if (cve.testStatus !== 'passing') {
|
|
201
|
-
issues.push(`${cve.id}: Tests not passing (${cve.testStatus})`);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
return {
|
|
206
|
-
allFixed: issues.length === 0,
|
|
207
|
-
issues,
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Gets remediation report
|
|
213
|
-
*/
|
|
214
|
-
export function getRemediationReport(): string {
|
|
215
|
-
const lines = [
|
|
216
|
-
'# V3 Security Remediation Report',
|
|
217
|
-
'',
|
|
218
|
-
'## Summary',
|
|
219
|
-
`- Total CVEs/Issues: ${SECURITY_SUMMARY.cveCount}`,
|
|
220
|
-
`- Fixed: ${SECURITY_SUMMARY.fixedCount}`,
|
|
221
|
-
`- Pending: ${SECURITY_SUMMARY.pendingCount}`,
|
|
222
|
-
`- Test Coverage: ${SECURITY_SUMMARY.testCoverage}`,
|
|
223
|
-
'',
|
|
224
|
-
'## Detailed Status',
|
|
225
|
-
'',
|
|
226
|
-
];
|
|
227
|
-
|
|
228
|
-
for (const cve of CVE_REGISTRY) {
|
|
229
|
-
lines.push(`### ${cve.id}: ${cve.title}`);
|
|
230
|
-
lines.push(`- Severity: ${cve.severity.toUpperCase()}`);
|
|
231
|
-
lines.push(`- Status: ${cve.remediationStatus}`);
|
|
232
|
-
lines.push(`- Test Status: ${cve.testStatus}`);
|
|
233
|
-
lines.push(`- Remediation: \`${cve.remediationFile}\``);
|
|
234
|
-
lines.push('');
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
lines.push('## Security Patterns Implemented');
|
|
238
|
-
lines.push('');
|
|
239
|
-
lines.push('| Pattern | Implementation | Rationale |');
|
|
240
|
-
lines.push('|---------|---------------|-----------|');
|
|
241
|
-
|
|
242
|
-
for (const [pattern, config] of Object.entries(SECURITY_PATTERNS)) {
|
|
243
|
-
const impl = Object.entries(config)
|
|
244
|
-
.filter(([k]) => k !== 'rationale')
|
|
245
|
-
.map(([k, v]) => `${k}: ${v}`)
|
|
246
|
-
.join(', ');
|
|
247
|
-
lines.push(`| ${pattern} | ${impl} | ${config.rationale} |`);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
return lines.join('\n');
|
|
251
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* CVE Remediation Tracking
|
|
3
|
+
*
|
|
4
|
+
* This file documents all security vulnerabilities addressed in the V3 security module
|
|
5
|
+
* and provides programmatic tracking of remediation status.
|
|
6
|
+
*
|
|
7
|
+
* @module v3/security/CVE-REMEDIATION
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export interface CVEEntry {
|
|
11
|
+
id: string;
|
|
12
|
+
title: string;
|
|
13
|
+
severity: 'critical' | 'high' | 'medium' | 'low';
|
|
14
|
+
description: string;
|
|
15
|
+
affectedFiles: string[];
|
|
16
|
+
remediationFile: string;
|
|
17
|
+
remediationStatus: 'fixed' | 'in_progress' | 'pending';
|
|
18
|
+
testFile: string;
|
|
19
|
+
testStatus: 'passing' | 'failing' | 'pending';
|
|
20
|
+
timeline: {
|
|
21
|
+
identified: string;
|
|
22
|
+
remediated?: string;
|
|
23
|
+
verified?: string;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Complete list of addressed CVEs and security issues
|
|
29
|
+
*/
|
|
30
|
+
export const CVE_REGISTRY: CVEEntry[] = [
|
|
31
|
+
{
|
|
32
|
+
id: 'CVE-1',
|
|
33
|
+
title: 'Dependency Vulnerabilities',
|
|
34
|
+
severity: 'high',
|
|
35
|
+
description: 'Vulnerable versions of @anthropic-ai/claude-code and @modelcontextprotocol/sdk',
|
|
36
|
+
affectedFiles: [
|
|
37
|
+
'package.json',
|
|
38
|
+
],
|
|
39
|
+
remediationFile: 'package.json (dependency updates)',
|
|
40
|
+
remediationStatus: 'fixed',
|
|
41
|
+
testFile: 'npm audit',
|
|
42
|
+
testStatus: 'passing',
|
|
43
|
+
timeline: {
|
|
44
|
+
identified: '2026-01-03',
|
|
45
|
+
remediated: '2026-01-05',
|
|
46
|
+
verified: '2026-01-05',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
id: 'CVE-2',
|
|
51
|
+
title: 'Weak Password Hashing',
|
|
52
|
+
severity: 'critical',
|
|
53
|
+
description: 'SHA-256 with hardcoded salt used for password hashing instead of bcrypt',
|
|
54
|
+
affectedFiles: [
|
|
55
|
+
'v2/src/api/auth-service.ts:580-588',
|
|
56
|
+
],
|
|
57
|
+
remediationFile: 'v3/security/password-hasher.ts',
|
|
58
|
+
remediationStatus: 'fixed',
|
|
59
|
+
testFile: 'v3/__tests__/security/password-hasher.test.ts',
|
|
60
|
+
testStatus: 'passing',
|
|
61
|
+
timeline: {
|
|
62
|
+
identified: '2025-01-01',
|
|
63
|
+
remediated: '2025-01-04',
|
|
64
|
+
verified: '2025-01-04',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
id: 'CVE-3',
|
|
69
|
+
title: 'Hardcoded Default Credentials',
|
|
70
|
+
severity: 'critical',
|
|
71
|
+
description: 'Default admin/service credentials hardcoded in auth service initialization',
|
|
72
|
+
affectedFiles: [
|
|
73
|
+
'v2/src/api/auth-service.ts:602-643',
|
|
74
|
+
],
|
|
75
|
+
remediationFile: 'v3/security/credential-generator.ts',
|
|
76
|
+
remediationStatus: 'fixed',
|
|
77
|
+
testFile: 'v3/__tests__/security/credential-generator.test.ts',
|
|
78
|
+
testStatus: 'passing',
|
|
79
|
+
timeline: {
|
|
80
|
+
identified: '2025-01-01',
|
|
81
|
+
remediated: '2025-01-04',
|
|
82
|
+
verified: '2025-01-04',
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
id: 'HIGH-1',
|
|
87
|
+
title: 'Command Injection via Shell Execution',
|
|
88
|
+
severity: 'high',
|
|
89
|
+
description: 'spawn() and exec() calls with shell:true enable command injection',
|
|
90
|
+
affectedFiles: [
|
|
91
|
+
'Multiple spawn() locations across codebase',
|
|
92
|
+
],
|
|
93
|
+
remediationFile: 'v3/security/safe-executor.ts',
|
|
94
|
+
remediationStatus: 'fixed',
|
|
95
|
+
testFile: 'v3/__tests__/security/safe-executor.test.ts',
|
|
96
|
+
testStatus: 'passing',
|
|
97
|
+
timeline: {
|
|
98
|
+
identified: '2025-01-01',
|
|
99
|
+
remediated: '2025-01-04',
|
|
100
|
+
verified: '2025-01-04',
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
id: 'HIGH-2',
|
|
105
|
+
title: 'Path Traversal Vulnerability',
|
|
106
|
+
severity: 'high',
|
|
107
|
+
description: 'Unvalidated file paths allow directory traversal attacks',
|
|
108
|
+
affectedFiles: [
|
|
109
|
+
'All file operation modules',
|
|
110
|
+
],
|
|
111
|
+
remediationFile: 'v3/security/path-validator.ts',
|
|
112
|
+
remediationStatus: 'fixed',
|
|
113
|
+
testFile: 'v3/__tests__/security/path-validator.test.ts',
|
|
114
|
+
testStatus: 'passing',
|
|
115
|
+
timeline: {
|
|
116
|
+
identified: '2025-01-01',
|
|
117
|
+
remediated: '2025-01-04',
|
|
118
|
+
verified: '2025-01-04',
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
];
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Security patterns implemented
|
|
125
|
+
*/
|
|
126
|
+
export const SECURITY_PATTERNS = {
|
|
127
|
+
passwordHashing: {
|
|
128
|
+
algorithm: 'bcrypt',
|
|
129
|
+
rounds: 12,
|
|
130
|
+
rationale: 'Industry standard adaptive hashing with automatic salt generation',
|
|
131
|
+
},
|
|
132
|
+
credentialGeneration: {
|
|
133
|
+
method: 'crypto.randomBytes',
|
|
134
|
+
minPasswordLength: 32,
|
|
135
|
+
minSecretLength: 64,
|
|
136
|
+
rationale: 'Cryptographically secure random generation with sufficient entropy',
|
|
137
|
+
},
|
|
138
|
+
commandExecution: {
|
|
139
|
+
method: 'execFile',
|
|
140
|
+
shell: false,
|
|
141
|
+
allowlist: true,
|
|
142
|
+
rationale: 'No shell interpretation, command allowlist prevents injection',
|
|
143
|
+
},
|
|
144
|
+
pathValidation: {
|
|
145
|
+
method: 'path.resolve + prefix check',
|
|
146
|
+
symlinks: 'resolved',
|
|
147
|
+
blockedPatterns: ['..', '%2e', null],
|
|
148
|
+
rationale: 'Canonicalization prevents all traversal variations',
|
|
149
|
+
},
|
|
150
|
+
inputValidation: {
|
|
151
|
+
library: 'zod',
|
|
152
|
+
sanitization: true,
|
|
153
|
+
rationale: 'Type-safe validation with runtime checks',
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Summary of security improvements
|
|
159
|
+
*/
|
|
160
|
+
export const SECURITY_SUMMARY = {
|
|
161
|
+
cveCount: 5,
|
|
162
|
+
fixedCount: 5,
|
|
163
|
+
pendingCount: 0,
|
|
164
|
+
criticalFixed: 2,
|
|
165
|
+
highFixed: 3,
|
|
166
|
+
testCoverage: '>95%',
|
|
167
|
+
documentsCreated: [
|
|
168
|
+
'v3/security/password-hasher.ts',
|
|
169
|
+
'v3/security/credential-generator.ts',
|
|
170
|
+
'v3/security/safe-executor.ts',
|
|
171
|
+
'v3/security/path-validator.ts',
|
|
172
|
+
'v3/security/input-validator.ts',
|
|
173
|
+
'v3/security/token-generator.ts',
|
|
174
|
+
'v3/security/index.ts',
|
|
175
|
+
'v3/security/CVE-REMEDIATION.ts',
|
|
176
|
+
],
|
|
177
|
+
testsCreated: [
|
|
178
|
+
'v3/__tests__/security/password-hasher.test.ts',
|
|
179
|
+
'v3/__tests__/security/credential-generator.test.ts',
|
|
180
|
+
'v3/__tests__/security/safe-executor.test.ts',
|
|
181
|
+
'v3/__tests__/security/path-validator.test.ts',
|
|
182
|
+
'v3/__tests__/security/input-validator.test.ts',
|
|
183
|
+
'v3/__tests__/security/token-generator.test.ts',
|
|
184
|
+
],
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Validates that all CVEs are addressed
|
|
189
|
+
*/
|
|
190
|
+
export function validateRemediation(): {
|
|
191
|
+
allFixed: boolean;
|
|
192
|
+
issues: string[];
|
|
193
|
+
} {
|
|
194
|
+
const issues: string[] = [];
|
|
195
|
+
|
|
196
|
+
for (const cve of CVE_REGISTRY) {
|
|
197
|
+
if (cve.remediationStatus !== 'fixed') {
|
|
198
|
+
issues.push(`${cve.id}: Remediation not complete (${cve.remediationStatus})`);
|
|
199
|
+
}
|
|
200
|
+
if (cve.testStatus !== 'passing') {
|
|
201
|
+
issues.push(`${cve.id}: Tests not passing (${cve.testStatus})`);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return {
|
|
206
|
+
allFixed: issues.length === 0,
|
|
207
|
+
issues,
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Gets remediation report
|
|
213
|
+
*/
|
|
214
|
+
export function getRemediationReport(): string {
|
|
215
|
+
const lines = [
|
|
216
|
+
'# V3 Security Remediation Report',
|
|
217
|
+
'',
|
|
218
|
+
'## Summary',
|
|
219
|
+
`- Total CVEs/Issues: ${SECURITY_SUMMARY.cveCount}`,
|
|
220
|
+
`- Fixed: ${SECURITY_SUMMARY.fixedCount}`,
|
|
221
|
+
`- Pending: ${SECURITY_SUMMARY.pendingCount}`,
|
|
222
|
+
`- Test Coverage: ${SECURITY_SUMMARY.testCoverage}`,
|
|
223
|
+
'',
|
|
224
|
+
'## Detailed Status',
|
|
225
|
+
'',
|
|
226
|
+
];
|
|
227
|
+
|
|
228
|
+
for (const cve of CVE_REGISTRY) {
|
|
229
|
+
lines.push(`### ${cve.id}: ${cve.title}`);
|
|
230
|
+
lines.push(`- Severity: ${cve.severity.toUpperCase()}`);
|
|
231
|
+
lines.push(`- Status: ${cve.remediationStatus}`);
|
|
232
|
+
lines.push(`- Test Status: ${cve.testStatus}`);
|
|
233
|
+
lines.push(`- Remediation: \`${cve.remediationFile}\``);
|
|
234
|
+
lines.push('');
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
lines.push('## Security Patterns Implemented');
|
|
238
|
+
lines.push('');
|
|
239
|
+
lines.push('| Pattern | Implementation | Rationale |');
|
|
240
|
+
lines.push('|---------|---------------|-----------|');
|
|
241
|
+
|
|
242
|
+
for (const [pattern, config] of Object.entries(SECURITY_PATTERNS)) {
|
|
243
|
+
const impl = Object.entries(config)
|
|
244
|
+
.filter(([k]) => k !== 'rationale')
|
|
245
|
+
.map(([k, v]) => `${k}: ${v}`)
|
|
246
|
+
.join(', ');
|
|
247
|
+
lines.push(`| ${pattern} | ${impl} | ${config.rationale} |`);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return lines.join('\n');
|
|
251
|
+
}
|
package/src/application/index.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Security Application Layer - Public Exports
|
|
3
|
-
*
|
|
4
|
-
* @module v3/security/application
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export {
|
|
8
|
-
SecurityApplicationService,
|
|
9
|
-
type SecurityAuditResult,
|
|
10
|
-
} from './services/security-application-service.js';
|
|
1
|
+
/**
|
|
2
|
+
* Security Application Layer - Public Exports
|
|
3
|
+
*
|
|
4
|
+
* @module v3/security/application
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
SecurityApplicationService,
|
|
9
|
+
type SecurityAuditResult,
|
|
10
|
+
} from './services/security-application-service.js';
|