0xray 4.0.21 → 4.0.23

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 (103) hide show
  1. package/.grok-plugin/plugin.json +1 -1
  2. package/.opencode/skills/hermes-agent/SKILL.md +1 -1
  3. package/.opencode/skills/orchestrator/SKILL.md +28 -6
  4. package/.xray/features.json +1 -1
  5. package/AGENTS-consumer.md +11 -11
  6. package/AGENTS.md +8 -8
  7. package/README.md +27 -27
  8. package/SKILLS.md +1 -1
  9. package/dist/AGENTS.md +8 -8
  10. package/dist/CHANGELOG.md +98 -0
  11. package/dist/README.md +27 -27
  12. package/dist/SKILLS.md +1 -1
  13. package/dist/governance/governance-core.d.ts +2 -1
  14. package/dist/governance/governance-core.js +20 -11
  15. package/dist/governance/governance-service.js +9 -7
  16. package/dist/inference/inference-accumulator.js +36 -4
  17. package/dist/inference/inference-cycle.d.ts +12 -0
  18. package/dist/inference/inference-cycle.js +180 -21
  19. package/dist/inference/inference-proposal-generator.js +148 -5
  20. package/dist/inference/session-capture.d.ts +4 -0
  21. package/dist/integrations/cursor/README.md +1 -1
  22. package/dist/integrations/cursor/hooks/cursor-hook-utils.js +19 -0
  23. package/dist/integrations/cursor/hooks/pre-tool-use.js +2 -1
  24. package/dist/integrations/governance/index.d.ts +5 -0
  25. package/dist/integrations/governance/index.js +22 -2
  26. package/dist/integrations/governance/types.d.ts +11 -0
  27. package/dist/integrations/governance/types.js +16 -0
  28. package/dist/integrations/hooks/station-hook-runtime.cjs +90 -30
  29. package/dist/integrations/hooks/station-hook-runtime.mjs +1 -0
  30. package/dist/integrations/hooks/station-memory-ingest.mjs +4 -2
  31. package/dist/integrations/openclaw/plugin/xray-pre-tool/package.json +1 -1
  32. package/dist/mcps/governance.server.d.ts +2 -0
  33. package/dist/mcps/governance.server.js +12 -1
  34. package/dist/memory-routing/index.d.ts +1 -1
  35. package/dist/memory-routing/index.js +1 -1
  36. package/dist/memory-routing/lesson-pickup.d.ts +2 -0
  37. package/dist/memory-routing/lesson-pickup.js +57 -0
  38. package/dist/memory-routing/provider-loader.d.ts +8 -1
  39. package/dist/memory-routing/provider-loader.js +49 -1
  40. package/dist/memory-routing/provider-registry.d.ts +7 -2
  41. package/dist/memory-routing/provider-registry.js +26 -6
  42. package/dist/memory-routing/record-lesson.d.ts +16 -0
  43. package/dist/memory-routing/record-lesson.js +26 -0
  44. package/dist/memory-routing/types.d.ts +15 -0
  45. package/dist/nucleus/thin-dispatch.d.ts +2 -0
  46. package/dist/nucleus/thin-dispatch.js +14 -4
  47. package/dist/processors/implementations/agents-md-validation-processor.js +1 -1
  48. package/dist/skills/hermes-agent/SKILL.md +1 -1
  49. package/dist/skills/orchestrator/SKILL.md +28 -6
  50. package/package.json +2 -2
  51. package/scripts/foundry/CHANGELOG.md +2 -0
  52. package/scripts/foundry/README.md +2 -2
  53. package/scripts/foundry/cli.mjs +1 -1
  54. package/scripts/foundry/inspect.mjs +160 -5
  55. package/scripts/foundry/plant/skills/inspect/SKILL.md +2 -0
  56. package/scripts/foundry/reconcile-version.mjs +23 -1
  57. package/scripts/foundry/release.mjs +1 -1
  58. package/scripts/foundry/validate-release-docs.mjs +24 -20
  59. package/scripts/foundry/version-manager.mjs +180 -7
  60. package/scripts/mjs/test-consumer-readiness.mjs +10 -3
  61. package/src/integrations/openclaw/plugin/xray-pre-tool/package.json +1 -1
  62. package/src/mcps/governance.server.ts +12 -1
  63. package/src/skills/hermes-agent/SKILL.md +1 -1
  64. package/src/skills/orchestrator/SKILL.md +28 -6
  65. package/vendor/@0xray/repertoire/data/stack-overlay.json +156 -3
  66. package/vendor/@0xray/repertoire/data/subject-overlay.json +3 -3
  67. package/vendor/@0xray/repertoire/dist/RepertoireService.d.ts +4 -0
  68. package/vendor/@0xray/repertoire/dist/RepertoireService.d.ts.map +1 -1
  69. package/vendor/@0xray/repertoire/dist/RepertoireService.js +7 -6
  70. package/vendor/@0xray/repertoire/dist/RepertoireService.js.map +1 -1
  71. package/vendor/@0xray/repertoire/dist/ingestion/xray-session-ingester.d.ts.map +1 -1
  72. package/vendor/@0xray/repertoire/dist/ingestion/xray-session-ingester.js +10 -11
  73. package/vendor/@0xray/repertoire/dist/ingestion/xray-session-ingester.js.map +1 -1
  74. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/confidence-gate.d.ts.map +1 -1
  75. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/confidence-gate.js +5 -0
  76. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/confidence-gate.js.map +1 -1
  77. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/signal-injector.d.ts.map +1 -1
  78. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/signal-injector.js +16 -0
  79. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/signal-injector.js.map +1 -1
  80. package/vendor/@0xray/repertoire/dist/paths.d.ts +3 -3
  81. package/vendor/@0xray/repertoire/dist/paths.d.ts.map +1 -1
  82. package/vendor/@0xray/repertoire/dist/paths.js +66 -4
  83. package/vendor/@0xray/repertoire/dist/paths.js.map +1 -1
  84. package/vendor/@0xray/repertoire/dist/provider/memory-routing-provider.d.ts +11 -0
  85. package/vendor/@0xray/repertoire/dist/provider/memory-routing-provider.d.ts.map +1 -1
  86. package/vendor/@0xray/repertoire/dist/provider/memory-routing-provider.js +2 -0
  87. package/vendor/@0xray/repertoire/dist/provider/memory-routing-provider.js.map +1 -1
  88. package/vendor/@0xray/repertoire/dist/registry/CuratedSignalsManager.d.ts +54 -4
  89. package/vendor/@0xray/repertoire/dist/registry/CuratedSignalsManager.d.ts.map +1 -1
  90. package/vendor/@0xray/repertoire/dist/registry/CuratedSignalsManager.js +375 -20
  91. package/vendor/@0xray/repertoire/dist/registry/CuratedSignalsManager.js.map +1 -1
  92. package/vendor/@0xray/repertoire/dist/types.d.ts +21 -0
  93. package/vendor/@0xray/repertoire/dist/types.d.ts.map +1 -1
  94. package/xray/agents_template.md +10 -5
  95. package/xray/features.json +1 -1
  96. package/dist/mcps/shared/prompt-security-validator.d.ts +0 -44
  97. package/dist/mcps/shared/prompt-security-validator.js +0 -148
  98. package/dist/mcps/shared/security-scanner.d.ts +0 -119
  99. package/dist/mcps/shared/security-scanner.js +0 -429
  100. package/dist/scripts/activate-kernel-pipeline.d.ts +0 -7
  101. package/dist/scripts/activate-kernel-pipeline.js +0 -101
  102. package/src/mcps/shared/prompt-security-validator.ts +0 -199
  103. package/src/mcps/shared/security-scanner.ts +0 -599
@@ -1,599 +0,0 @@
1
- /**
2
- * 0xRay Framework - Security Scanner
3
- *
4
- * Automated security vulnerability scanning and compliance validation
5
- * Integrates with security tools and provides comprehensive security reports
6
- */
7
-
8
- import { exec } from "child_process";
9
- import { promises as fs } from "fs";
10
- import { frameworkLogger } from "../../core/framework-logger.js";
11
- import { promisify } from "util";
12
- import {
13
- promptSecurityValidator,
14
- PromptSecurityValidator,
15
- } from "./prompt-security-validator.js";
16
-
17
- const execAsync = promisify(exec);
18
-
19
- export interface SecurityScanConfig {
20
- enabled: boolean;
21
- tools: {
22
- npmAudit: boolean;
23
- trivy: boolean;
24
- eslintSecurity: boolean;
25
- dependencyCheck: boolean;
26
- };
27
- severityThreshold: "low" | "moderate" | "high" | "critical";
28
- reportPath: string;
29
- failOnVulnerabilities: boolean;
30
- }
31
-
32
- export interface SecurityVulnerability {
33
- id: string;
34
- title: string;
35
- description: string;
36
- severity: "low" | "moderate" | "high" | "critical";
37
- package?: string;
38
- version?: string;
39
- cve?: string;
40
- url?: string;
41
- recommendation: string;
42
- }
43
-
44
- export interface SecurityReport {
45
- timestamp: string;
46
- duration: number;
47
- tools: {
48
- npmAudit: SecurityVulnerability[];
49
- trivy: SecurityVulnerability[];
50
- eslintSecurity: SecurityVulnerability[];
51
- dependencyCheck: SecurityVulnerability[];
52
- };
53
- summary: {
54
- totalVulnerabilities: number;
55
- bySeverity: Record<string, number>;
56
- byTool: Record<string, number>;
57
- };
58
- recommendations: string[];
59
- compliant: boolean;
60
- }
61
-
62
- export class SecurityScanner {
63
- private config: SecurityScanConfig;
64
-
65
- constructor(config: Partial<SecurityScanConfig> = {}) {
66
- this.config = {
67
- enabled: true,
68
- tools: {
69
- npmAudit: true,
70
- trivy: false, // Requires separate installation
71
- eslintSecurity: true,
72
- dependencyCheck: false, // Requires separate installation
73
- ...config.tools,
74
- },
75
- severityThreshold: "moderate",
76
- reportPath: "./security-report.json",
77
- failOnVulnerabilities: true,
78
- ...config,
79
- };
80
- }
81
-
82
- /**
83
- * Run comprehensive security scan
84
- */
85
- async runSecurityScan(): Promise<SecurityReport> {
86
- const jobId = `security-scan-${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;
87
- const startTime = Date.now();
88
-
89
- if (!this.config.enabled) {
90
- return this.createEmptyReport();
91
- }
92
-
93
- frameworkLogger.log("security-scanner", "scan-start", "info", {
94
- jobId,
95
- tools: this.config.tools,
96
- severityThreshold: this.config.severityThreshold,
97
- });
98
-
99
- const results = await Promise.allSettled([
100
- this.config.tools.npmAudit ? this.runNpmAudit() : Promise.resolve([]),
101
- this.config.tools.trivy ? this.runTrivyScan() : Promise.resolve([]),
102
- this.config.tools.eslintSecurity
103
- ? this.runEslintSecurity()
104
- : Promise.resolve([]),
105
- this.config.tools.dependencyCheck
106
- ? this.runDependencyCheck()
107
- : Promise.resolve([]),
108
- ]);
109
-
110
- const tools = {
111
- npmAudit: results[0].status === "fulfilled" ? results[0].value : [],
112
- trivy: results[1].status === "fulfilled" ? results[1].value : [],
113
- eslintSecurity: results[2].status === "fulfilled" ? results[2].value : [],
114
- dependencyCheck:
115
- results[3].status === "fulfilled" ? results[3].value : [],
116
- };
117
-
118
- const duration = Date.now() - startTime;
119
- const report = this.generateReport(tools, duration);
120
-
121
- // Save report
122
- await this.saveReport(report, jobId);
123
-
124
- // Log results
125
- await this.logResults(report);
126
-
127
- return report;
128
- }
129
-
130
- /**
131
- * Run npm audit
132
- */
133
- private async runNpmAudit(): Promise<SecurityVulnerability[]> {
134
- try {
135
- const { stdout } = await execAsync("npm audit --json");
136
- const auditResult = JSON.parse(stdout);
137
-
138
- const vulnerabilities: SecurityVulnerability[] = [];
139
-
140
- if (auditResult.vulnerabilities) {
141
- for (const [packageName, vuln] of Object.entries(
142
- auditResult.vulnerabilities,
143
- ) as any) {
144
- vulnerabilities.push({
145
- id: vuln.name || packageName,
146
- title: vuln.title || "Security vulnerability",
147
- description: vuln.overview || "No description available",
148
- severity: this.mapNpmSeverity(vuln.severity),
149
- package: packageName,
150
- version: vuln.version,
151
- cve: vuln.cwe,
152
- url: vuln.url,
153
- recommendation: vuln.recommendation || "Update to a secure version",
154
- });
155
- }
156
- }
157
-
158
- return vulnerabilities;
159
- } catch (error) {
160
- const errorMessage =
161
- error instanceof Error ? error.message : String(error);
162
- frameworkLogger.log("security-scanner", "npm-audit-failed", "warning", { message: "āš ļø npm audit failed", error: errorMessage });
163
- return [];
164
- }
165
- }
166
-
167
- /**
168
- * Run Trivy security scan
169
- */
170
- private async runTrivyScan(): Promise<SecurityVulnerability[]> {
171
- try {
172
- const { stdout } = await execAsync("trivy fs --format json .");
173
- const trivyResult = JSON.parse(stdout);
174
-
175
- const vulnerabilities: SecurityVulnerability[] = [];
176
-
177
- if (trivyResult.Results) {
178
- for (const result of trivyResult.Results) {
179
- if (result.Vulnerabilities) {
180
- for (const vuln of result.Vulnerabilities) {
181
- vulnerabilities.push({
182
- id: vuln.VulnerabilityID,
183
- title: vuln.Title,
184
- description: vuln.Description,
185
- severity: this.mapTrivySeverity(vuln.Severity),
186
- package: vuln.PkgName,
187
- version: vuln.InstalledVersion,
188
- cve: vuln.VulnerabilityID,
189
- url: vuln.PrimaryURL,
190
- recommendation: vuln.FixedVersion
191
- ? `Update to ${vuln.FixedVersion}`
192
- : "Review and mitigate",
193
- });
194
- }
195
- }
196
- }
197
- }
198
-
199
- return vulnerabilities;
200
- } catch (error) {
201
- const errorMessage =
202
- error instanceof Error ? error.message : String(error);
203
- frameworkLogger.log("security-scanner", "trivy-scan-failed", "warning", { message: "āš ļø Trivy scan failed", error: errorMessage });
204
- return [];
205
- }
206
- }
207
-
208
- /**
209
- * Run ESLint security rules
210
- */
211
- private async runEslintSecurity(): Promise<SecurityVulnerability[]> {
212
- try {
213
- const { stdout } = await execAsync("npx eslint --format json src/");
214
- const eslintResults = JSON.parse(stdout);
215
-
216
- const vulnerabilities: SecurityVulnerability[] = [];
217
-
218
- for (const result of eslintResults) {
219
- for (const message of result.messages) {
220
- if (
221
- message.ruleId &&
222
- (message.ruleId.includes("security") ||
223
- message.ruleId.includes("xss") ||
224
- message.ruleId.includes("injection"))
225
- ) {
226
- vulnerabilities.push({
227
- id: message.ruleId,
228
- title: message.message,
229
- description: `Security issue in ${result.filePath}:${message.line}:${message.column}`,
230
- severity: "moderate",
231
- recommendation:
232
- "Fix the security vulnerability according to ESLint recommendations",
233
- });
234
- }
235
- }
236
- }
237
-
238
- return vulnerabilities;
239
- } catch (error) {
240
- const errorMessage =
241
- error instanceof Error ? error.message : String(error);
242
- frameworkLogger.log("security-scanner", "eslint-scan-failed", "warning", { message: "āš ļø ESLint security scan failed", error: errorMessage });
243
- return [];
244
- }
245
- }
246
-
247
- /**
248
- * Run OWASP Dependency Check
249
- */
250
- private async runDependencyCheck(): Promise<SecurityVulnerability[]> {
251
- try {
252
- const { stdout } = await execAsync(
253
- "dependency-check --format JSON --out . --scan .",
254
- );
255
- const dcResult = JSON.parse(stdout);
256
-
257
- const vulnerabilities: SecurityVulnerability[] = [];
258
-
259
- if (dcResult.dependencies) {
260
- for (const dep of dcResult.dependencies) {
261
- if (dep.vulnerabilities) {
262
- for (const vuln of dep.vulnerabilities) {
263
- vulnerabilities.push({
264
- id: vuln.name,
265
- title: vuln.description,
266
- description: vuln.description,
267
- severity: this.mapDependencyCheckSeverity(vuln.severity),
268
- package: dep.fileName,
269
- cve: vuln.name,
270
- url: vuln.references?.[0]?.url,
271
- recommendation: "Update dependency or apply security patches",
272
- });
273
- }
274
- }
275
- }
276
- }
277
-
278
- return vulnerabilities;
279
- } catch (error) {
280
- const errorMessage =
281
- error instanceof Error ? error.message : String(error);
282
- frameworkLogger.log("security-scanner", "dependency-check-failed", "warning", { message: "āš ļø Dependency check failed", error: errorMessage });
283
- return [];
284
- }
285
- }
286
-
287
- /**
288
- * Generate comprehensive security report
289
- */
290
- private generateReport(
291
- tools: SecurityReport["tools"],
292
- duration: number,
293
- ): SecurityReport {
294
- const allVulnerabilities = [
295
- ...tools.npmAudit,
296
- ...tools.trivy,
297
- ...tools.eslintSecurity,
298
- ...tools.dependencyCheck,
299
- ];
300
-
301
- const bySeverity = allVulnerabilities.reduce(
302
- (acc, vuln) => {
303
- acc[vuln.severity] = (acc[vuln.severity] || 0) + 1;
304
- return acc;
305
- },
306
- {} as Record<string, number>,
307
- );
308
-
309
- const byTool = {
310
- npmAudit: tools.npmAudit.length,
311
- trivy: tools.trivy.length,
312
- eslintSecurity: tools.eslintSecurity.length,
313
- dependencyCheck: tools.dependencyCheck.length,
314
- };
315
-
316
- const highSeverityCount =
317
- (bySeverity.high || 0) + (bySeverity.critical || 0);
318
- const shouldFail =
319
- this.config.failOnVulnerabilities &&
320
- highSeverityCount > 0 &&
321
- this.config.severityThreshold !== "low";
322
-
323
- const recommendations = this.generateRecommendations(allVulnerabilities);
324
-
325
- return {
326
- timestamp: new Date().toISOString(),
327
- duration,
328
- tools,
329
- summary: {
330
- totalVulnerabilities: allVulnerabilities.length,
331
- bySeverity,
332
- byTool,
333
- },
334
- recommendations,
335
- compliant: !shouldFail,
336
- };
337
- }
338
-
339
- /**
340
- * Generate security recommendations
341
- */
342
- private generateRecommendations(
343
- vulnerabilities: SecurityVulnerability[],
344
- ): string[] {
345
- const recommendations: string[] = [];
346
-
347
- if (vulnerabilities.some((v) => v.severity === "critical")) {
348
- recommendations.push(
349
- "🚨 Critical security vulnerabilities found - immediate action required",
350
- );
351
- }
352
-
353
- if (vulnerabilities.some((v) => v.severity === "high")) {
354
- recommendations.push(
355
- "āš ļø High-severity vulnerabilities detected - prioritize fixes",
356
- );
357
- }
358
-
359
- if (vulnerabilities.filter((v) => v.package).length > 0) {
360
- recommendations.push(
361
- "šŸ“¦ Update vulnerable dependencies to latest secure versions",
362
- );
363
- }
364
-
365
- if (vulnerabilities.filter((v) => v.id.includes("eslint")).length > 0) {
366
- recommendations.push("šŸ”§ Fix code security issues identified by ESLint");
367
- }
368
-
369
- recommendations.push(
370
- "šŸ” Run regular security scans and keep dependencies updated",
371
- );
372
- recommendations.push(
373
- "šŸ“‹ Review security policies and implement security headers",
374
- );
375
-
376
- return recommendations;
377
- }
378
-
379
- /**
380
- * Save report to file
381
- */
382
- private async saveReport(
383
- report: SecurityReport,
384
- jobId: string,
385
- ): Promise<void> {
386
- try {
387
- await fs.writeFile(
388
- this.config.reportPath,
389
- JSON.stringify(report, null, 2),
390
- );
391
- frameworkLogger.log("security-scanner", "report-saved", "success", {
392
- jobId,
393
- reportPath: this.config.reportPath,
394
- });
395
- } catch (error) {
396
- const errorMessage =
397
- error instanceof Error ? error.message : String(error);
398
- frameworkLogger.log("security-scanner", "save-report-failed", "warning", { message: "āš ļø Failed to save security report", error: errorMessage });
399
- }
400
- }
401
-
402
- /**
403
- * Log security scan results
404
- */
405
- private async logResults(report: SecurityReport): Promise<void> {
406
- await frameworkLogger.log(
407
- "security-scanner",
408
- "-n-security-scan-complete-report-duration-ms-",
409
- "info",
410
- { message: `\nšŸ”’ Security Scan Complete (${report.duration}ms)` },
411
- );
412
- await frameworkLogger.log(
413
- "security-scanner",
414
- "-total-vulnerabilities-report-summary-totalvulnera",
415
- "info",
416
- {
417
- message: `šŸ“Š Total vulnerabilities: ${report.summary.totalVulnerabilities}`,
418
- },
419
- );
420
-
421
- await frameworkLogger.log("security-scanner", "-n-by-severity-", "info", {
422
- message: "\nšŸ“ˆ By Severity:",
423
- });
424
- for (const [severity, count] of Object.entries(report.summary.bySeverity)) {
425
- await frameworkLogger.log(
426
- "security-scanner",
427
- "-severity-count-",
428
- "info",
429
- { message: ` ${severity}: ${count}` },
430
- );
431
- }
432
-
433
- await frameworkLogger.log("security-scanner", "-n-by-tool-", "info", {
434
- message: "\nšŸ› ļø By Tool:",
435
- });
436
- for (const [tool, count] of Object.entries(report.summary.byTool)) {
437
- await frameworkLogger.log("security-scanner", "-tool-count-", "info", {
438
- message: ` ${tool}: ${count}`,
439
- });
440
- }
441
-
442
- if (report.recommendations.length > 0) {
443
- await frameworkLogger.log(
444
- "security-scanner",
445
- "-n-recommendations-",
446
- "info",
447
- { message: "\nšŸ’” Recommendations:" },
448
- );
449
- for (const rec of report.recommendations) {
450
- await frameworkLogger.log("security-scanner", "-rec-", "info", {
451
- message: ` • ${rec}`,
452
- });
453
- }
454
- }
455
-
456
- if (report.compliant) {
457
- // Security scan result - kept as console.log for user visibility
458
- } else {
459
- // Security scan failure - kept as console.log for user visibility
460
- }
461
- }
462
-
463
- /**
464
- * Map npm audit severity levels
465
- */
466
- private mapNpmSeverity(severity: string): SecurityVulnerability["severity"] {
467
- switch (severity) {
468
- case "critical":
469
- return "critical";
470
- case "high":
471
- return "high";
472
- case "moderate":
473
- return "moderate";
474
- case "low":
475
- return "low";
476
- default:
477
- return "moderate";
478
- }
479
- }
480
-
481
- /**
482
- * Map Trivy severity levels
483
- */
484
- private mapTrivySeverity(
485
- severity: string,
486
- ): SecurityVulnerability["severity"] {
487
- switch (severity.toUpperCase()) {
488
- case "CRITICAL":
489
- return "critical";
490
- case "HIGH":
491
- return "high";
492
- case "MEDIUM":
493
- return "moderate";
494
- case "LOW":
495
- return "low";
496
- default:
497
- return "moderate";
498
- }
499
- }
500
-
501
- /**
502
- * Map Dependency Check severity levels
503
- */
504
- private mapDependencyCheckSeverity(
505
- severity: string,
506
- ): SecurityVulnerability["severity"] {
507
- switch (severity.toUpperCase()) {
508
- case "CRITICAL":
509
- return "critical";
510
- case "HIGH":
511
- return "high";
512
- case "MEDIUM":
513
- return "moderate";
514
- case "LOW":
515
- return "low";
516
- default:
517
- return "moderate";
518
- }
519
- }
520
-
521
- /**
522
- * Validate AI prompt security
523
- */
524
- async validatePrompt(prompt: string): Promise<{
525
- isSafe: boolean;
526
- violations: string[];
527
- riskLevel: string;
528
- }> {
529
- const result = promptSecurityValidator.validatePrompt(prompt);
530
-
531
- if (!result.isSafe) {
532
- frameworkLogger.log("security-scanner", "prompt-violation", "warning", {
533
- message: `🚨 Prompt security violation detected (risk: ${result.riskLevel})`,
534
- violations: result.violations,
535
- });
536
- }
537
-
538
- return {
539
- isSafe: result.isSafe,
540
- violations: result.violations,
541
- riskLevel: result.riskLevel,
542
- };
543
- }
544
-
545
- /**
546
- * Validate AI response security
547
- */
548
- async validateResponse(response: string): Promise<{
549
- isSafe: boolean;
550
- violations: string[];
551
- riskLevel: string;
552
- }> {
553
- const result = promptSecurityValidator.validateResponse(response);
554
-
555
- if (!result.isSafe) {
556
- frameworkLogger.log("security-scanner", "response-violation", "warning", {
557
- message: `🚨 Response security violation detected (risk: ${result.riskLevel})`,
558
- violations: result.violations,
559
- });
560
- }
561
-
562
- return {
563
- isSafe: result.isSafe,
564
- violations: result.violations,
565
- riskLevel: result.riskLevel,
566
- };
567
- }
568
-
569
- /**
570
- * Create empty report when scanning is disabled
571
- */
572
- private createEmptyReport(): SecurityReport {
573
- return {
574
- timestamp: new Date().toISOString(),
575
- duration: 0,
576
- tools: {
577
- npmAudit: [],
578
- trivy: [],
579
- eslintSecurity: [],
580
- dependencyCheck: [],
581
- },
582
- summary: {
583
- totalVulnerabilities: 0,
584
- bySeverity: {},
585
- byTool: {
586
- npmAudit: 0,
587
- trivy: 0,
588
- eslintSecurity: 0,
589
- dependencyCheck: 0,
590
- },
591
- },
592
- recommendations: ["Security scanning is disabled"],
593
- compliant: true,
594
- };
595
- }
596
- }
597
-
598
- // Export singleton instance
599
- export const securityScanner = new SecurityScanner();