stringray-ai 1.0.38 → 1.0.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/dist/plugin/architectural-integrity.d.ts +21 -0
  2. package/dist/plugin/architectural-integrity.d.ts.map +1 -0
  3. package/dist/plugin/architectural-integrity.js +81 -0
  4. package/dist/plugin/architectural-integrity.js.map +1 -0
  5. package/dist/plugin/boot-orchestrator.d.ts +100 -0
  6. package/dist/plugin/boot-orchestrator.d.ts.map +1 -0
  7. package/dist/plugin/boot-orchestrator.js +606 -0
  8. package/dist/plugin/boot-orchestrator.js.map +1 -0
  9. package/dist/plugin/codex-injector.d.ts +72 -0
  10. package/dist/plugin/codex-injector.d.ts.map +1 -0
  11. package/dist/plugin/codex-injector.js +387 -0
  12. package/dist/plugin/codex-injector.js.map +1 -0
  13. package/dist/plugin/delegation/index.d.ts +16 -0
  14. package/dist/plugin/delegation/index.d.ts.map +1 -0
  15. package/dist/plugin/delegation/index.js +13 -0
  16. package/dist/plugin/delegation/index.js.map +1 -0
  17. package/dist/plugin/delegation/session-coordinator.d.ts +121 -0
  18. package/dist/plugin/delegation/session-coordinator.d.ts.map +1 -0
  19. package/dist/plugin/delegation/session-coordinator.js +346 -0
  20. package/dist/plugin/delegation/session-coordinator.js.map +1 -0
  21. package/dist/plugin/index.d.ts +3 -0
  22. package/dist/plugin/index.d.ts.map +1 -0
  23. package/dist/plugin/index.js +3 -0
  24. package/dist/plugin/index.js.map +1 -0
  25. package/dist/plugin/monitoring/memory-monitor.d.ts +113 -0
  26. package/dist/plugin/monitoring/memory-monitor.d.ts.map +1 -0
  27. package/dist/plugin/monitoring/memory-monitor.js +283 -0
  28. package/dist/plugin/monitoring/memory-monitor.js.map +1 -0
  29. package/dist/plugin/postprocessor/PostProcessor.d.ts +90 -0
  30. package/dist/plugin/postprocessor/PostProcessor.d.ts.map +1 -0
  31. package/dist/plugin/postprocessor/PostProcessor.js +631 -0
  32. package/dist/plugin/postprocessor/PostProcessor.js.map +1 -0
  33. package/dist/plugin/postprocessor/analysis/FailureAnalysisEngine.d.ts +40 -0
  34. package/dist/plugin/postprocessor/analysis/FailureAnalysisEngine.d.ts.map +1 -0
  35. package/dist/plugin/postprocessor/analysis/FailureAnalysisEngine.js +244 -0
  36. package/dist/plugin/postprocessor/analysis/FailureAnalysisEngine.js.map +1 -0
  37. package/dist/plugin/postprocessor/autofix/AutoFixEngine.d.ts +50 -0
  38. package/dist/plugin/postprocessor/autofix/AutoFixEngine.d.ts.map +1 -0
  39. package/dist/plugin/postprocessor/autofix/AutoFixEngine.js +246 -0
  40. package/dist/plugin/postprocessor/autofix/AutoFixEngine.js.map +1 -0
  41. package/dist/plugin/postprocessor/autofix/FixValidator.d.ts +27 -0
  42. package/dist/plugin/postprocessor/autofix/FixValidator.d.ts.map +1 -0
  43. package/dist/plugin/postprocessor/autofix/FixValidator.js +158 -0
  44. package/dist/plugin/postprocessor/autofix/FixValidator.js.map +1 -0
  45. package/dist/plugin/postprocessor/config.d.ts +7 -0
  46. package/dist/plugin/postprocessor/config.d.ts.map +1 -0
  47. package/dist/plugin/postprocessor/config.js +66 -0
  48. package/dist/plugin/postprocessor/config.js.map +1 -0
  49. package/dist/plugin/postprocessor/escalation/EscalationEngine.d.ts +73 -0
  50. package/dist/plugin/postprocessor/escalation/EscalationEngine.d.ts.map +1 -0
  51. package/dist/plugin/postprocessor/escalation/EscalationEngine.js +249 -0
  52. package/dist/plugin/postprocessor/escalation/EscalationEngine.js.map +1 -0
  53. package/dist/plugin/postprocessor/monitoring/MonitoringEngine.d.ts +19 -0
  54. package/dist/plugin/postprocessor/monitoring/MonitoringEngine.d.ts.map +1 -0
  55. package/dist/plugin/postprocessor/monitoring/MonitoringEngine.js +120 -0
  56. package/dist/plugin/postprocessor/monitoring/MonitoringEngine.js.map +1 -0
  57. package/dist/plugin/postprocessor/redeploy/RedeployCoordinator.d.ts +92 -0
  58. package/dist/plugin/postprocessor/redeploy/RedeployCoordinator.d.ts.map +1 -0
  59. package/dist/plugin/postprocessor/redeploy/RedeployCoordinator.js +319 -0
  60. package/dist/plugin/postprocessor/redeploy/RedeployCoordinator.js.map +1 -0
  61. package/dist/plugin/postprocessor/success/SuccessHandler.d.ts +61 -0
  62. package/dist/plugin/postprocessor/success/SuccessHandler.d.ts.map +1 -0
  63. package/dist/plugin/postprocessor/success/SuccessHandler.js +148 -0
  64. package/dist/plugin/postprocessor/success/SuccessHandler.js.map +1 -0
  65. package/dist/plugin/postprocessor/triggers/APITrigger.d.ts +13 -0
  66. package/dist/plugin/postprocessor/triggers/APITrigger.d.ts.map +1 -0
  67. package/dist/plugin/postprocessor/triggers/APITrigger.js +20 -0
  68. package/dist/plugin/postprocessor/triggers/APITrigger.js.map +1 -0
  69. package/dist/plugin/postprocessor/triggers/GitHookTrigger.d.ts +17 -0
  70. package/dist/plugin/postprocessor/triggers/GitHookTrigger.d.ts.map +1 -0
  71. package/dist/plugin/postprocessor/triggers/GitHookTrigger.js +285 -0
  72. package/dist/plugin/postprocessor/triggers/GitHookTrigger.js.map +1 -0
  73. package/dist/plugin/postprocessor/triggers/WebhookTrigger.d.ts +13 -0
  74. package/dist/plugin/postprocessor/triggers/WebhookTrigger.d.ts.map +1 -0
  75. package/dist/plugin/postprocessor/triggers/WebhookTrigger.js +21 -0
  76. package/dist/plugin/postprocessor/triggers/WebhookTrigger.js.map +1 -0
  77. package/dist/plugin/postprocessor/types.d.ts +198 -0
  78. package/dist/plugin/postprocessor/types.d.ts.map +1 -0
  79. package/dist/plugin/postprocessor/types.js +5 -0
  80. package/dist/plugin/postprocessor/types.js.map +1 -0
  81. package/dist/plugin/security/security-auditor.d.ts +57 -0
  82. package/dist/plugin/security/security-auditor.d.ts.map +1 -0
  83. package/dist/plugin/security/security-auditor.js +583 -0
  84. package/dist/plugin/security/security-auditor.js.map +1 -0
  85. package/dist/plugin/security/security-hardener.d.ts +63 -0
  86. package/dist/plugin/security/security-hardener.d.ts.map +1 -0
  87. package/dist/plugin/security/security-hardener.js +181 -0
  88. package/dist/plugin/security/security-hardener.js.map +1 -0
  89. package/dist/plugin/security/security-headers.d.ts +52 -0
  90. package/dist/plugin/security/security-headers.d.ts.map +1 -0
  91. package/dist/plugin/security/security-headers.js +118 -0
  92. package/dist/plugin/security/security-headers.js.map +1 -0
  93. package/dist/plugin/session/session-cleanup-manager.d.ts +118 -0
  94. package/dist/plugin/session/session-cleanup-manager.d.ts.map +1 -0
  95. package/dist/plugin/session/session-cleanup-manager.js +324 -0
  96. package/dist/plugin/session/session-cleanup-manager.js.map +1 -0
  97. package/dist/plugin/session/session-monitor.d.ts +99 -0
  98. package/dist/plugin/session/session-monitor.d.ts.map +1 -0
  99. package/dist/plugin/session/session-monitor.js +363 -0
  100. package/dist/plugin/session/session-monitor.js.map +1 -0
  101. package/dist/plugin/session/session-state-manager.d.ts +142 -0
  102. package/dist/plugin/session/session-state-manager.d.ts.map +1 -0
  103. package/dist/plugin/session/session-state-manager.js +504 -0
  104. package/dist/plugin/session/session-state-manager.js.map +1 -0
  105. package/dist/plugin/strray-activation.d.ts +18 -0
  106. package/dist/plugin/strray-activation.d.ts.map +1 -0
  107. package/dist/plugin/strray-activation.js +114 -0
  108. package/dist/plugin/strray-activation.js.map +1 -0
  109. package/dist/plugin/validation/report-content-validator.d.ts +43 -0
  110. package/dist/plugin/validation/report-content-validator.d.ts.map +1 -0
  111. package/dist/plugin/validation/report-content-validator.js +219 -0
  112. package/dist/plugin/validation/report-content-validator.js.map +1 -0
  113. package/package.json +1 -1
@@ -0,0 +1,583 @@
1
+ /**
2
+ * StringRay Framework v1.0.0 - Security Audit Tool
3
+ *
4
+ * Comprehensive security auditing for the framework and its components.
5
+ * Identifies vulnerabilities, misconfigurations, and security weaknesses.
6
+ *
7
+ * @version 1.0.0
8
+ * @since 2026-01-07
9
+ */
10
+ import { readFileSync, readdirSync, statSync } from "fs";
11
+ import { join } from "path";
12
+ export class SecurityAuditor {
13
+ dangerousPatterns = [
14
+ // Code injection
15
+ {
16
+ pattern: /eval\s*\(/g,
17
+ severity: "critical",
18
+ category: "code-injection",
19
+ cwe: "CWE-95",
20
+ },
21
+ {
22
+ pattern: /Function\s*\(/g,
23
+ severity: "critical",
24
+ category: "code-injection",
25
+ cwe: "CWE-95",
26
+ },
27
+ {
28
+ pattern: /new\s+Function\s*\(/g,
29
+ severity: "critical",
30
+ category: "code-injection",
31
+ cwe: "CWE-95",
32
+ },
33
+ // Command injection
34
+ {
35
+ pattern: /child_process\.exec\s*\(/g,
36
+ severity: "high",
37
+ category: "command-injection",
38
+ cwe: "CWE-78",
39
+ },
40
+ {
41
+ pattern: /child_process\.spawn\s*\(/g,
42
+ severity: "high",
43
+ category: "command-injection",
44
+ cwe: "CWE-78",
45
+ },
46
+ {
47
+ pattern: /execSync\s*\(/g,
48
+ severity: "high",
49
+ category: "command-injection",
50
+ cwe: "CWE-78",
51
+ },
52
+ // SQL injection (if applicable)
53
+ {
54
+ pattern: /SELECT.*\+/g,
55
+ severity: "high",
56
+ category: "sql-injection",
57
+ cwe: "CWE-89",
58
+ },
59
+ {
60
+ pattern: /INSERT.*\+/g,
61
+ severity: "high",
62
+ category: "sql-injection",
63
+ cwe: "CWE-89",
64
+ },
65
+ // Path traversal
66
+ {
67
+ pattern: /\.\.[\/\\]/g,
68
+ severity: "high",
69
+ category: "path-traversal",
70
+ cwe: "CWE-22",
71
+ },
72
+ {
73
+ pattern: /path\.join\s*\(\s*\.\./g,
74
+ severity: "high",
75
+ category: "path-traversal",
76
+ cwe: "CWE-22",
77
+ },
78
+ // Hardcoded secrets
79
+ {
80
+ pattern: /password\s*[:=]\s*['"][^'"]*['"]/gi,
81
+ severity: "high",
82
+ category: "hardcoded-secrets",
83
+ cwe: "CWE-798",
84
+ },
85
+ {
86
+ pattern: /api[_-]?key\s*[:=]\s*['"][^'"]*['"]/gi,
87
+ severity: "high",
88
+ category: "hardcoded-secrets",
89
+ cwe: "CWE-798",
90
+ },
91
+ {
92
+ pattern: /secret\s*[:=]\s*['"][^'"]*['"]/gi,
93
+ severity: "high",
94
+ category: "hardcoded-secrets",
95
+ cwe: "CWE-798",
96
+ },
97
+ // Insecure random
98
+ {
99
+ pattern: /Math\.random\s*\(\)/g,
100
+ severity: "medium",
101
+ category: "weak-cryptography",
102
+ cwe: "CWE-338",
103
+ },
104
+ // Console logging sensitive data
105
+ {
106
+ pattern: /console\.log\s*\([^)]*password[^)]*\)/gi,
107
+ severity: "medium",
108
+ category: "information-disclosure",
109
+ cwe: "CWE-532",
110
+ },
111
+ {
112
+ pattern: /console\.log\s*\([^)]*secret[^)]*\)/gi,
113
+ severity: "medium",
114
+ category: "information-disclosure",
115
+ cwe: "CWE-532",
116
+ },
117
+ // Missing input validation
118
+ {
119
+ pattern: /req\.body\./g,
120
+ severity: "medium",
121
+ category: "input-validation",
122
+ cwe: "CWE-20",
123
+ },
124
+ {
125
+ pattern: /req\.query\./g,
126
+ severity: "medium",
127
+ category: "input-validation",
128
+ cwe: "CWE-20",
129
+ },
130
+ // Insecure deserialization
131
+ {
132
+ pattern: /JSON\.parse\s*\([^)]*req\./g,
133
+ severity: "medium",
134
+ category: "deserialization",
135
+ cwe: "CWE-502",
136
+ },
137
+ // Race conditions
138
+ {
139
+ pattern: /setTimeout.*0/g,
140
+ severity: "low",
141
+ category: "race-conditions",
142
+ cwe: "CWE-362",
143
+ },
144
+ // Information disclosure in errors
145
+ {
146
+ pattern: /throw\s+new\s+Error\s*\([^)]*stack[^)]*\)/gi,
147
+ severity: "low",
148
+ category: "information-disclosure",
149
+ cwe: "CWE-209",
150
+ },
151
+ ];
152
+ dangerousImports = [
153
+ "child_process",
154
+ "fs",
155
+ "net",
156
+ "http",
157
+ "https",
158
+ "crypto",
159
+ "tls",
160
+ "cluster",
161
+ "worker_threads",
162
+ "vm",
163
+ ];
164
+ /**
165
+ * Run comprehensive security audit
166
+ */
167
+ async auditProject(projectPath = ".") {
168
+ const issues = [];
169
+ const files = this.getAllFiles(projectPath);
170
+ console.log(`🔍 Security Auditor: Scanning ${files.length} files...`);
171
+ for (const file of files) {
172
+ if (this.shouldAuditFile(file)) {
173
+ const fileIssues = await this.auditFile(file);
174
+ issues.push(...fileIssues);
175
+ }
176
+ }
177
+ // Additional checks
178
+ issues.push(...this.auditPackageJson(projectPath));
179
+ issues.push(...this.auditConfiguration(projectPath));
180
+ issues.push(...this.auditDependencies(projectPath));
181
+ const summary = this.generateSummary(issues);
182
+ const score = this.calculateSecurityScore(issues, files.length);
183
+ return {
184
+ totalFiles: files.length,
185
+ issues,
186
+ summary,
187
+ score,
188
+ };
189
+ }
190
+ getAllFiles(dirPath) {
191
+ const files = [];
192
+ const traverse = (currentPath) => {
193
+ const items = readdirSync(currentPath);
194
+ for (const item of items) {
195
+ const fullPath = join(currentPath, item);
196
+ const stat = statSync(fullPath);
197
+ if (stat.isDirectory() && !this.shouldSkipDirectory(item)) {
198
+ traverse(fullPath);
199
+ }
200
+ else if (stat.isFile()) {
201
+ files.push(fullPath);
202
+ }
203
+ }
204
+ };
205
+ traverse(dirPath);
206
+ return files;
207
+ }
208
+ shouldSkipDirectory(dirName) {
209
+ const skipDirs = [
210
+ "node_modules",
211
+ ".git",
212
+ "dist",
213
+ "build",
214
+ ".next",
215
+ ".nuxt",
216
+ "coverage",
217
+ ];
218
+ return skipDirs.includes(dirName);
219
+ }
220
+ shouldAuditFile(filePath) {
221
+ const auditExtensions = [".ts", ".tsx", ".js", ".jsx", ".json", ".md"];
222
+ const excludePatterns = [/__tests__/, /test\.ts$/, /spec\.ts$/];
223
+ // Check if file should be excluded from security audit
224
+ if (excludePatterns.some((pattern) => pattern.test(filePath))) {
225
+ return false;
226
+ }
227
+ return auditExtensions.some((ext) => filePath.endsWith(ext));
228
+ }
229
+ async auditFile(filePath) {
230
+ const issues = [];
231
+ try {
232
+ const content = readFileSync(filePath, "utf-8");
233
+ const lines = content.split("\n");
234
+ // Pattern-based security checks
235
+ for (let i = 0; i < lines.length; i++) {
236
+ const line = lines[i];
237
+ const lineNumber = i + 1;
238
+ for (const { pattern, severity, category, cwe } of this
239
+ .dangerousPatterns) {
240
+ const matches = line?.match(pattern);
241
+ if (matches && line) {
242
+ // Skip false positives in security validation and test code
243
+ if (this.isFalsePositive(filePath, line, category)) {
244
+ continue;
245
+ }
246
+ issues.push({
247
+ severity,
248
+ category,
249
+ file: filePath,
250
+ line: lineNumber,
251
+ description: `Potentially dangerous pattern detected: ${pattern}`,
252
+ recommendation: this.getRecommendationForCategory(category),
253
+ cwe,
254
+ });
255
+ }
256
+ }
257
+ }
258
+ // Import security checks
259
+ if (filePath.endsWith(".ts") || filePath.endsWith(".js")) {
260
+ issues.push(...this.auditImports(content, filePath));
261
+ }
262
+ // File permission checks
263
+ issues.push(...this.auditFilePermissions(filePath));
264
+ }
265
+ catch (error) {
266
+ issues.push({
267
+ severity: "medium",
268
+ category: "file-access",
269
+ file: filePath,
270
+ description: `Failed to audit file: ${error}`,
271
+ recommendation: "Ensure file is readable and not corrupted",
272
+ });
273
+ }
274
+ return issues;
275
+ }
276
+ isFalsePositive(filePath, line, category) {
277
+ if (!line)
278
+ return false;
279
+ const safeLine = line;
280
+ // Security validation code that legitimately uses dangerous patterns for detection
281
+ if (filePath.includes("security-auditor.ts") &&
282
+ category === "code-injection") {
283
+ return true;
284
+ }
285
+ // Test code that uses eval in string literals for testing purposes
286
+ if (filePath.includes("__tests__") &&
287
+ category === "code-injection" &&
288
+ safeLine.includes("eval(")) {
289
+ return (safeLine.includes("'eval('") ||
290
+ safeLine.includes('"eval(') ||
291
+ safeLine.includes("`eval("));
292
+ }
293
+ // Security validation modules that check for dangerous patterns
294
+ if (filePath.includes("codex-parser.ts") && category === "code-injection") {
295
+ return (safeLine.includes("content.includes('eval(')") ||
296
+ safeLine.includes("content.includes('Function(')"));
297
+ }
298
+ return false;
299
+ }
300
+ auditImports(content, filePath) {
301
+ const issues = [];
302
+ for (const dangerousImport of this.dangerousImports) {
303
+ const importPatterns = [
304
+ new RegExp(`import.*from.*['"]${dangerousImport}['"]`, "g"),
305
+ new RegExp(`require\\s*\\(\\s*['"]${dangerousImport}['"]\\s*\\)`, "g"),
306
+ new RegExp(`import.*${dangerousImport}`, "g"),
307
+ ];
308
+ for (const pattern of importPatterns) {
309
+ if (pattern.test(content)) {
310
+ issues.push({
311
+ severity: "medium",
312
+ category: "dangerous-imports",
313
+ file: filePath,
314
+ description: `Potentially dangerous import detected: ${dangerousImport}`,
315
+ recommendation: "Review usage and ensure proper sandboxing/validation",
316
+ cwe: "CWE-350",
317
+ });
318
+ break; // Only report once per import per file
319
+ }
320
+ }
321
+ }
322
+ return issues;
323
+ }
324
+ auditFilePermissions(filePath) {
325
+ const issues = [];
326
+ try {
327
+ const stat = statSync(filePath);
328
+ const mode = stat.mode;
329
+ // Check for world-writable files
330
+ if (mode & parseInt("2", 8)) {
331
+ issues.push({
332
+ severity: "high",
333
+ category: "file-permissions",
334
+ file: filePath,
335
+ description: "File is world-writable",
336
+ recommendation: "Restrict file permissions to prevent unauthorized modification",
337
+ cwe: "CWE-732",
338
+ });
339
+ }
340
+ // Check for executable scripts in sensitive directories
341
+ if (mode & parseInt("111", 8) && filePath.includes("config")) {
342
+ issues.push({
343
+ severity: "medium",
344
+ category: "file-permissions",
345
+ file: filePath,
346
+ description: "Executable file in configuration directory",
347
+ recommendation: "Review if this file needs execute permissions",
348
+ cwe: "CWE-732",
349
+ });
350
+ }
351
+ }
352
+ catch (error) {
353
+ // File permission check failed
354
+ }
355
+ return issues;
356
+ }
357
+ auditPackageJson(projectPath) {
358
+ const issues = [];
359
+ try {
360
+ const packagePath = join(projectPath, "package.json");
361
+ const packageJson = JSON.parse(readFileSync(packagePath, "utf-8"));
362
+ // Check for vulnerable dependencies
363
+ const allDeps = {
364
+ ...packageJson.dependencies,
365
+ ...packageJson.devDependencies,
366
+ };
367
+ for (const [dep, version] of Object.entries(allDeps)) {
368
+ if (typeof version === "string" &&
369
+ (version.includes("*") || version.includes("latest"))) {
370
+ issues.push({
371
+ severity: "medium",
372
+ category: "dependency-management",
373
+ file: packagePath,
374
+ description: `Insecure version constraint for ${dep}: ${version}`,
375
+ recommendation: "Use specific version ranges to avoid vulnerable versions",
376
+ cwe: "CWE-1104",
377
+ });
378
+ }
379
+ }
380
+ // Check for missing security scripts
381
+ const scripts = packageJson.scripts || {};
382
+ if (!scripts["audit"] || !scripts["security-audit"]) {
383
+ issues.push({
384
+ severity: "low",
385
+ category: "security-practices",
386
+ file: packagePath,
387
+ description: "Missing security audit scripts",
388
+ recommendation: "Add npm audit and security audit scripts to package.json",
389
+ });
390
+ }
391
+ }
392
+ catch (error) {
393
+ issues.push({
394
+ severity: "medium",
395
+ category: "configuration",
396
+ file: join(projectPath, "package.json"),
397
+ description: "Failed to audit package.json",
398
+ recommendation: "Ensure package.json is valid and accessible",
399
+ });
400
+ }
401
+ return issues;
402
+ }
403
+ auditConfiguration(projectPath) {
404
+ const issues = [];
405
+ const configFiles = [
406
+ ".opencode/oh-my-opencode.json",
407
+ "config.json",
408
+ ".env",
409
+ ];
410
+ for (const configFile of configFiles) {
411
+ const configPath = join(projectPath, configFile);
412
+ try {
413
+ const content = readFileSync(configPath, "utf-8");
414
+ // Check for hardcoded secrets
415
+ const secretPatterns = [
416
+ /password\s*[:=]\s*['"][^'"]*['"]/gi,
417
+ /api[_-]?key\s*[:=]\s*['"][^'"]*['"]/gi,
418
+ /secret\s*[:=]\s*['"][^'"]*['"]/gi,
419
+ /token\s*[:=]\s*['"][^'"]*['"]/gi,
420
+ ];
421
+ for (const pattern of secretPatterns) {
422
+ if (pattern.test(content)) {
423
+ issues.push({
424
+ severity: "high",
425
+ category: "hardcoded-secrets",
426
+ file: configPath,
427
+ description: "Potential hardcoded secrets detected in configuration",
428
+ recommendation: "Move secrets to environment variables or secure vault",
429
+ cwe: "CWE-798",
430
+ });
431
+ break;
432
+ }
433
+ }
434
+ }
435
+ catch (error) {
436
+ // Config file doesn't exist or can't be read
437
+ }
438
+ }
439
+ return issues;
440
+ }
441
+ auditDependencies(projectPath) {
442
+ const issues = [];
443
+ try {
444
+ const packageLockPath = join(projectPath, "package-lock.json");
445
+ const yarnLockPath = join(projectPath, "yarn.lock");
446
+ if (!statSync(packageLockPath).isFile() &&
447
+ !statSync(yarnLockPath).isFile()) {
448
+ issues.push({
449
+ severity: "medium",
450
+ category: "dependency-management",
451
+ file: join(projectPath, "package.json"),
452
+ description: "Missing lockfile (package-lock.json or yarn.lock)",
453
+ recommendation: "Use lockfiles to ensure reproducible and secure dependency versions",
454
+ cwe: "CWE-1104",
455
+ });
456
+ }
457
+ }
458
+ catch (error) {
459
+ // Lockfile check failed
460
+ }
461
+ return issues;
462
+ }
463
+ getRecommendationForCategory(category) {
464
+ const recommendations = {
465
+ "code-injection": "Use static code analysis and avoid dynamic code execution",
466
+ "command-injection": "Validate and sanitize all user inputs, use parameterized commands",
467
+ "sql-injection": "Use parameterized queries or ORM with built-in protection",
468
+ "path-traversal": "Validate paths, use allowlists, resolve to absolute paths",
469
+ "hardcoded-secrets": "Use environment variables or secure credential management",
470
+ "weak-cryptography": "Use cryptographically secure random number generators",
471
+ "information-disclosure": "Avoid logging sensitive information, use proper log levels",
472
+ "input-validation": "Implement comprehensive input validation and sanitization",
473
+ deserialization: "Validate serialized data, use safe deserialization libraries",
474
+ "race-conditions": "Use proper synchronization primitives",
475
+ "dangerous-imports": "Review usage and implement proper access controls",
476
+ "file-permissions": "Restrict file permissions to minimum required access",
477
+ };
478
+ return (recommendations[category] ||
479
+ "Review and implement appropriate security measures");
480
+ }
481
+ generateSummary(issues) {
482
+ const summary = {
483
+ critical: 0,
484
+ high: 0,
485
+ medium: 0,
486
+ low: 0,
487
+ info: 0,
488
+ };
489
+ for (const issue of issues) {
490
+ summary[issue.severity]++;
491
+ }
492
+ return summary;
493
+ }
494
+ calculateSecurityScore(issues, totalFiles) {
495
+ let score = 100;
496
+ // Weight issues by severity
497
+ const weights = {
498
+ critical: 20,
499
+ high: 10,
500
+ medium: 5,
501
+ low: 2,
502
+ info: 1,
503
+ };
504
+ for (const issue of issues) {
505
+ score -= weights[issue.severity];
506
+ }
507
+ // Bonus for having many files (indicates thorough codebase)
508
+ if (totalFiles > 50) {
509
+ score += 5;
510
+ }
511
+ return Math.max(0, Math.min(100, score));
512
+ }
513
+ /**
514
+ * Generate security audit report
515
+ */
516
+ generateReport(result) {
517
+ let report = `# 🔒 StringRay Framework Security Audit Report
518
+
519
+ **Audit Date:** ${new Date().toISOString()}
520
+ **Framework Version:** v1.0.0
521
+ **Files Scanned:** ${result.totalFiles}
522
+ **Security Score:** ${result.score}/100
523
+
524
+ ## 📊 Summary
525
+
526
+ - **Critical Issues:** ${result.summary.critical}
527
+ - **High Severity:** ${result.summary.high}
528
+ - **Medium Severity:** ${result.summary.medium}
529
+ - **Low Severity:** ${result.summary.low}
530
+ - **Informational:** ${result.summary.info}
531
+
532
+ ## 🚨 Issues Found
533
+
534
+ `;
535
+ if (result.issues.length === 0) {
536
+ report += "✅ No security issues found!\n\n";
537
+ }
538
+ else {
539
+ // Group issues by severity
540
+ const groupedIssues = result.issues.reduce((groups, issue) => {
541
+ if (!groups[issue.severity])
542
+ groups[issue.severity] = [];
543
+ groups[issue.severity].push(issue);
544
+ return groups;
545
+ }, {});
546
+ for (const [severity, issues] of Object.entries(groupedIssues)) {
547
+ report += `### ${severity.toUpperCase()} SEVERITY (${issues.length})\n\n`;
548
+ for (const issue of issues) {
549
+ report += `**${issue.category.toUpperCase()}** in \`${issue.file}\`${issue.line ? `:${issue.line}` : ""}\n`;
550
+ report += `${issue.description}\n`;
551
+ report += `💡 ${issue.recommendation}\n`;
552
+ if (issue.cwe) {
553
+ report += `🔗 CWE: ${issue.cwe}\n`;
554
+ }
555
+ report += "\n";
556
+ }
557
+ }
558
+ }
559
+ report += `## 🛡️ Security Recommendations
560
+
561
+ 1. **Address all Critical and High severity issues immediately**
562
+ 2. **Implement automated security scanning in CI/CD pipeline**
563
+ 3. **Regular security audits and dependency updates**
564
+ 4. **Use security headers and secure coding practices**
565
+ 5. **Monitor for new vulnerabilities in dependencies**
566
+
567
+ ## 📈 Score Interpretation
568
+
569
+ - **90-100:** Excellent security posture
570
+ - **80-89:** Good security with minor issues
571
+ - **70-79:** Adequate security, address high-priority issues
572
+ - **60-69:** Security concerns present, immediate action required
573
+ - **<60:** Critical security issues, immediate remediation needed
574
+
575
+ ---
576
+ *Generated by StringRay Security Auditor v1.0.0*
577
+ `;
578
+ return report;
579
+ }
580
+ }
581
+ // Export singleton instance
582
+ export const securityAuditor = new SecurityAuditor();
583
+ //# sourceMappingURL=security-auditor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"security-auditor.js","sourceRoot":"","sources":["../../../src/security/security-auditor.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AACzD,OAAO,EAAE,IAAI,EAAW,MAAM,MAAM,CAAC;AA0BrC,MAAM,OAAO,eAAe;IACT,iBAAiB,GAAG;QACnC,iBAAiB;QACjB;YACE,OAAO,EAAE,YAAY;YACrB,QAAQ,EAAE,UAAmB;YAC7B,QAAQ,EAAE,gBAAgB;YAC1B,GAAG,EAAE,QAAQ;SACd;QACD;YACE,OAAO,EAAE,gBAAgB;YACzB,QAAQ,EAAE,UAAmB;YAC7B,QAAQ,EAAE,gBAAgB;YAC1B,GAAG,EAAE,QAAQ;SACd;QACD;YACE,OAAO,EAAE,sBAAsB;YAC/B,QAAQ,EAAE,UAAmB;YAC7B,QAAQ,EAAE,gBAAgB;YAC1B,GAAG,EAAE,QAAQ;SACd;QAED,oBAAoB;QACpB;YACE,OAAO,EAAE,2BAA2B;YACpC,QAAQ,EAAE,MAAe;YACzB,QAAQ,EAAE,mBAAmB;YAC7B,GAAG,EAAE,QAAQ;SACd;QACD;YACE,OAAO,EAAE,4BAA4B;YACrC,QAAQ,EAAE,MAAe;YACzB,QAAQ,EAAE,mBAAmB;YAC7B,GAAG,EAAE,QA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AC5G,MAAM,IAAI,GAAG,KAAK,CAAC,WAAW,IAAI,CAAC;oBACnC,MAAM,IAAI,MAAM,KAAK,CAAC,cAAc,IAAI,CAAC;oBACzC,IAAI,KAAK,CAAC,GAAG,EAAE,CAAC;wBACd,MAAM,IAAI,WAAW,KAAK,CAAC,GAAG,IAAI,CAAC;oBACrC,CAAC;oBACD,MAAM,IAAI,IAAI,CAAC;gBACjB,CAAC;YACH,CAAC;QACH,CAAC;QAED,MAAM,IAAI;;;;;;;;;;;;;;;;;;CAkBb,CAAC;QAEE,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED,4BAA4B;AAC5B,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * StringRay Framework v1.0.0 - Security Hardening Module
3
+ *
4
+ * Implements additional security measures and hardening for the framework.
5
+ * Addresses vulnerabilities identified during security audit.
6
+ *
7
+ * @version 1.0.0
8
+ * @since 2026-01-07
9
+ */
10
+ import { SecurityIssue } from "./security-auditor";
11
+ export interface SecurityHardeningConfig {
12
+ enableInputValidation: boolean;
13
+ enableRateLimiting: boolean;
14
+ enableAuditLogging: boolean;
15
+ enableSecureHeaders: boolean;
16
+ maxRequestSizeBytes: number;
17
+ rateLimitWindowMs: number;
18
+ rateLimitMaxRequests: number;
19
+ }
20
+ export declare class SecurityHardener {
21
+ private config;
22
+ constructor(config?: Partial<SecurityHardeningConfig>);
23
+ /**
24
+ * Apply security hardening based on audit results
25
+ */
26
+ hardenSecurity(auditResult: {
27
+ issues: SecurityIssue[];
28
+ }): Promise<{
29
+ appliedFixes: string[];
30
+ remainingIssues: SecurityIssue[];
31
+ }>;
32
+ private applyFixForIssue;
33
+ private fixHardcodedSecrets;
34
+ private fixFilePermissions;
35
+ private fixDependencyManagement;
36
+ private addInputValidation;
37
+ /**
38
+ * Add security headers to HTTP responses
39
+ */
40
+ addSecurityHeaders(headers: Record<string, string>): Record<string, string>;
41
+ /**
42
+ * Validate input data
43
+ */
44
+ validateInput(input: any, schema: any): {
45
+ valid: boolean;
46
+ errors: string[];
47
+ };
48
+ /**
49
+ * Check rate limiting
50
+ */
51
+ checkRateLimit(identifier: string, requests: Map<string, number[]>): boolean;
52
+ /**
53
+ * Log security events
54
+ */
55
+ logSecurityEvent(event: {
56
+ type: string;
57
+ severity: "low" | "medium" | "high" | "critical";
58
+ message: string;
59
+ metadata?: Record<string, any>;
60
+ }): void;
61
+ }
62
+ export declare const securityHardener: SecurityHardener;
63
+ //# sourceMappingURL=security-hardener.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"security-hardener.d.ts","sourceRoot":"","sources":["../../../src/security/security-hardener.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,MAAM,WAAW,uBAAuB;IACtC,qBAAqB,EAAE,OAAO,CAAC;IAC/B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAA0B;gBAE5B,MAAM,GAAE,OAAO,CAAC,uBAAuB,CAAM;IAazD;;OAEG;IACG,cAAc,CAAC,WAAW,EAAE;QAAE,MAAM,EAAE,aAAa,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC;QACtE,YAAY,EAAE,MAAM,EAAE,CAAC;QACvB,eAAe,EAAE,aAAa,EAAE,CAAC;KAClC,CAAC;YAoBY,gBAAgB;YAqBhB,mBAAmB;YAcnB,kBAAkB;YAmBlB,uBAAuB;YAkBvB,kBAAkB;IAkBhC;;OAEG;IACH,kBAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAA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