0xray 4.0.21 → 4.0.22

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 (56) 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 +22 -0
  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 +75 -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-cycle.js +22 -5
  17. package/dist/integrations/cursor/README.md +1 -1
  18. package/dist/integrations/cursor/hooks/cursor-hook-utils.js +19 -0
  19. package/dist/integrations/cursor/hooks/pre-tool-use.js +2 -1
  20. package/dist/integrations/hooks/station-hook-runtime.cjs +90 -30
  21. package/dist/integrations/hooks/station-hook-runtime.mjs +1 -0
  22. package/dist/integrations/hooks/station-memory-ingest.mjs +4 -2
  23. package/dist/integrations/openclaw/plugin/xray-pre-tool/package.json +1 -1
  24. package/dist/memory-routing/provider-loader.d.ts +3 -1
  25. package/dist/memory-routing/provider-loader.js +3 -1
  26. package/dist/nucleus/thin-dispatch.js +11 -2
  27. package/dist/processors/implementations/agents-md-validation-processor.js +1 -1
  28. package/dist/skills/hermes-agent/SKILL.md +1 -1
  29. package/dist/skills/orchestrator/SKILL.md +22 -0
  30. package/package.json +2 -2
  31. package/scripts/foundry/CHANGELOG.md +2 -0
  32. package/scripts/foundry/README.md +2 -2
  33. package/scripts/foundry/cli.mjs +1 -1
  34. package/scripts/foundry/inspect.mjs +160 -5
  35. package/scripts/foundry/plant/skills/inspect/SKILL.md +2 -0
  36. package/scripts/foundry/validate-release-docs.mjs +24 -20
  37. package/scripts/foundry/version-manager.mjs +127 -7
  38. package/scripts/mjs/test-consumer-readiness.mjs +10 -3
  39. package/src/integrations/openclaw/plugin/xray-pre-tool/package.json +1 -1
  40. package/src/skills/hermes-agent/SKILL.md +1 -1
  41. package/src/skills/orchestrator/SKILL.md +22 -0
  42. package/vendor/@0xray/repertoire/data/stack-overlay.json +154 -1
  43. package/vendor/@0xray/repertoire/dist/RepertoireService.js +7 -6
  44. package/vendor/@0xray/repertoire/dist/ingestion/xray-session-ingester.js +10 -11
  45. package/vendor/@0xray/repertoire/dist/paths.js +66 -4
  46. package/vendor/@0xray/repertoire/dist/registry/CuratedSignalsManager.js +54 -14
  47. package/xray/agents_template.md +10 -5
  48. package/xray/features.json +1 -1
  49. package/dist/mcps/shared/prompt-security-validator.d.ts +0 -44
  50. package/dist/mcps/shared/prompt-security-validator.js +0 -148
  51. package/dist/mcps/shared/security-scanner.d.ts +0 -119
  52. package/dist/mcps/shared/security-scanner.js +0 -429
  53. package/dist/scripts/activate-kernel-pipeline.d.ts +0 -7
  54. package/dist/scripts/activate-kernel-pipeline.js +0 -101
  55. package/src/mcps/shared/prompt-security-validator.ts +0 -199
  56. package/src/mcps/shared/security-scanner.ts +0 -599
@@ -1,429 +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
- import { exec } from "child_process";
8
- import { promises as fs } from "fs";
9
- import { frameworkLogger } from "../../core/framework-logger.js";
10
- import { promisify } from "util";
11
- import { promptSecurityValidator, } from "./prompt-security-validator.js";
12
- const execAsync = promisify(exec);
13
- export class SecurityScanner {
14
- config;
15
- constructor(config = {}) {
16
- this.config = {
17
- enabled: true,
18
- tools: {
19
- npmAudit: true,
20
- trivy: false, // Requires separate installation
21
- eslintSecurity: true,
22
- dependencyCheck: false, // Requires separate installation
23
- ...config.tools,
24
- },
25
- severityThreshold: "moderate",
26
- reportPath: "./security-report.json",
27
- failOnVulnerabilities: true,
28
- ...config,
29
- };
30
- }
31
- /**
32
- * Run comprehensive security scan
33
- */
34
- async runSecurityScan() {
35
- const jobId = `security-scan-${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;
36
- const startTime = Date.now();
37
- if (!this.config.enabled) {
38
- return this.createEmptyReport();
39
- }
40
- frameworkLogger.log("security-scanner", "scan-start", "info", {
41
- jobId,
42
- tools: this.config.tools,
43
- severityThreshold: this.config.severityThreshold,
44
- });
45
- const results = await Promise.allSettled([
46
- this.config.tools.npmAudit ? this.runNpmAudit() : Promise.resolve([]),
47
- this.config.tools.trivy ? this.runTrivyScan() : Promise.resolve([]),
48
- this.config.tools.eslintSecurity
49
- ? this.runEslintSecurity()
50
- : Promise.resolve([]),
51
- this.config.tools.dependencyCheck
52
- ? this.runDependencyCheck()
53
- : Promise.resolve([]),
54
- ]);
55
- const tools = {
56
- npmAudit: results[0].status === "fulfilled" ? results[0].value : [],
57
- trivy: results[1].status === "fulfilled" ? results[1].value : [],
58
- eslintSecurity: results[2].status === "fulfilled" ? results[2].value : [],
59
- dependencyCheck: results[3].status === "fulfilled" ? results[3].value : [],
60
- };
61
- const duration = Date.now() - startTime;
62
- const report = this.generateReport(tools, duration);
63
- // Save report
64
- await this.saveReport(report, jobId);
65
- // Log results
66
- await this.logResults(report);
67
- return report;
68
- }
69
- /**
70
- * Run npm audit
71
- */
72
- async runNpmAudit() {
73
- try {
74
- const { stdout } = await execAsync("npm audit --json");
75
- const auditResult = JSON.parse(stdout);
76
- const vulnerabilities = [];
77
- if (auditResult.vulnerabilities) {
78
- for (const [packageName, vuln] of Object.entries(auditResult.vulnerabilities)) {
79
- vulnerabilities.push({
80
- id: vuln.name || packageName,
81
- title: vuln.title || "Security vulnerability",
82
- description: vuln.overview || "No description available",
83
- severity: this.mapNpmSeverity(vuln.severity),
84
- package: packageName,
85
- version: vuln.version,
86
- cve: vuln.cwe,
87
- url: vuln.url,
88
- recommendation: vuln.recommendation || "Update to a secure version",
89
- });
90
- }
91
- }
92
- return vulnerabilities;
93
- }
94
- catch (error) {
95
- const errorMessage = error instanceof Error ? error.message : String(error);
96
- frameworkLogger.log("security-scanner", "npm-audit-failed", "warning", { message: "⚠️ npm audit failed", error: errorMessage });
97
- return [];
98
- }
99
- }
100
- /**
101
- * Run Trivy security scan
102
- */
103
- async runTrivyScan() {
104
- try {
105
- const { stdout } = await execAsync("trivy fs --format json .");
106
- const trivyResult = JSON.parse(stdout);
107
- const vulnerabilities = [];
108
- if (trivyResult.Results) {
109
- for (const result of trivyResult.Results) {
110
- if (result.Vulnerabilities) {
111
- for (const vuln of result.Vulnerabilities) {
112
- vulnerabilities.push({
113
- id: vuln.VulnerabilityID,
114
- title: vuln.Title,
115
- description: vuln.Description,
116
- severity: this.mapTrivySeverity(vuln.Severity),
117
- package: vuln.PkgName,
118
- version: vuln.InstalledVersion,
119
- cve: vuln.VulnerabilityID,
120
- url: vuln.PrimaryURL,
121
- recommendation: vuln.FixedVersion
122
- ? `Update to ${vuln.FixedVersion}`
123
- : "Review and mitigate",
124
- });
125
- }
126
- }
127
- }
128
- }
129
- return vulnerabilities;
130
- }
131
- catch (error) {
132
- const errorMessage = error instanceof Error ? error.message : String(error);
133
- frameworkLogger.log("security-scanner", "trivy-scan-failed", "warning", { message: "⚠️ Trivy scan failed", error: errorMessage });
134
- return [];
135
- }
136
- }
137
- /**
138
- * Run ESLint security rules
139
- */
140
- async runEslintSecurity() {
141
- try {
142
- const { stdout } = await execAsync("npx eslint --format json src/");
143
- const eslintResults = JSON.parse(stdout);
144
- const vulnerabilities = [];
145
- for (const result of eslintResults) {
146
- for (const message of result.messages) {
147
- if (message.ruleId &&
148
- (message.ruleId.includes("security") ||
149
- message.ruleId.includes("xss") ||
150
- message.ruleId.includes("injection"))) {
151
- vulnerabilities.push({
152
- id: message.ruleId,
153
- title: message.message,
154
- description: `Security issue in ${result.filePath}:${message.line}:${message.column}`,
155
- severity: "moderate",
156
- recommendation: "Fix the security vulnerability according to ESLint recommendations",
157
- });
158
- }
159
- }
160
- }
161
- return vulnerabilities;
162
- }
163
- catch (error) {
164
- const errorMessage = error instanceof Error ? error.message : String(error);
165
- frameworkLogger.log("security-scanner", "eslint-scan-failed", "warning", { message: "⚠️ ESLint security scan failed", error: errorMessage });
166
- return [];
167
- }
168
- }
169
- /**
170
- * Run OWASP Dependency Check
171
- */
172
- async runDependencyCheck() {
173
- try {
174
- const { stdout } = await execAsync("dependency-check --format JSON --out . --scan .");
175
- const dcResult = JSON.parse(stdout);
176
- const vulnerabilities = [];
177
- if (dcResult.dependencies) {
178
- for (const dep of dcResult.dependencies) {
179
- if (dep.vulnerabilities) {
180
- for (const vuln of dep.vulnerabilities) {
181
- vulnerabilities.push({
182
- id: vuln.name,
183
- title: vuln.description,
184
- description: vuln.description,
185
- severity: this.mapDependencyCheckSeverity(vuln.severity),
186
- package: dep.fileName,
187
- cve: vuln.name,
188
- url: vuln.references?.[0]?.url,
189
- recommendation: "Update dependency or apply security patches",
190
- });
191
- }
192
- }
193
- }
194
- }
195
- return vulnerabilities;
196
- }
197
- catch (error) {
198
- const errorMessage = error instanceof Error ? error.message : String(error);
199
- frameworkLogger.log("security-scanner", "dependency-check-failed", "warning", { message: "⚠️ Dependency check failed", error: errorMessage });
200
- return [];
201
- }
202
- }
203
- /**
204
- * Generate comprehensive security report
205
- */
206
- generateReport(tools, duration) {
207
- const allVulnerabilities = [
208
- ...tools.npmAudit,
209
- ...tools.trivy,
210
- ...tools.eslintSecurity,
211
- ...tools.dependencyCheck,
212
- ];
213
- const bySeverity = allVulnerabilities.reduce((acc, vuln) => {
214
- acc[vuln.severity] = (acc[vuln.severity] || 0) + 1;
215
- return acc;
216
- }, {});
217
- const byTool = {
218
- npmAudit: tools.npmAudit.length,
219
- trivy: tools.trivy.length,
220
- eslintSecurity: tools.eslintSecurity.length,
221
- dependencyCheck: tools.dependencyCheck.length,
222
- };
223
- const highSeverityCount = (bySeverity.high || 0) + (bySeverity.critical || 0);
224
- const shouldFail = this.config.failOnVulnerabilities &&
225
- highSeverityCount > 0 &&
226
- this.config.severityThreshold !== "low";
227
- const recommendations = this.generateRecommendations(allVulnerabilities);
228
- return {
229
- timestamp: new Date().toISOString(),
230
- duration,
231
- tools,
232
- summary: {
233
- totalVulnerabilities: allVulnerabilities.length,
234
- bySeverity,
235
- byTool,
236
- },
237
- recommendations,
238
- compliant: !shouldFail,
239
- };
240
- }
241
- /**
242
- * Generate security recommendations
243
- */
244
- generateRecommendations(vulnerabilities) {
245
- const recommendations = [];
246
- if (vulnerabilities.some((v) => v.severity === "critical")) {
247
- recommendations.push("🚨 Critical security vulnerabilities found - immediate action required");
248
- }
249
- if (vulnerabilities.some((v) => v.severity === "high")) {
250
- recommendations.push("⚠️ High-severity vulnerabilities detected - prioritize fixes");
251
- }
252
- if (vulnerabilities.filter((v) => v.package).length > 0) {
253
- recommendations.push("📦 Update vulnerable dependencies to latest secure versions");
254
- }
255
- if (vulnerabilities.filter((v) => v.id.includes("eslint")).length > 0) {
256
- recommendations.push("🔧 Fix code security issues identified by ESLint");
257
- }
258
- recommendations.push("🔍 Run regular security scans and keep dependencies updated");
259
- recommendations.push("📋 Review security policies and implement security headers");
260
- return recommendations;
261
- }
262
- /**
263
- * Save report to file
264
- */
265
- async saveReport(report, jobId) {
266
- try {
267
- await fs.writeFile(this.config.reportPath, JSON.stringify(report, null, 2));
268
- frameworkLogger.log("security-scanner", "report-saved", "success", {
269
- jobId,
270
- reportPath: this.config.reportPath,
271
- });
272
- }
273
- catch (error) {
274
- const errorMessage = error instanceof Error ? error.message : String(error);
275
- frameworkLogger.log("security-scanner", "save-report-failed", "warning", { message: "⚠️ Failed to save security report", error: errorMessage });
276
- }
277
- }
278
- /**
279
- * Log security scan results
280
- */
281
- async logResults(report) {
282
- await frameworkLogger.log("security-scanner", "-n-security-scan-complete-report-duration-ms-", "info", { message: `\n🔒 Security Scan Complete (${report.duration}ms)` });
283
- await frameworkLogger.log("security-scanner", "-total-vulnerabilities-report-summary-totalvulnera", "info", {
284
- message: `📊 Total vulnerabilities: ${report.summary.totalVulnerabilities}`,
285
- });
286
- await frameworkLogger.log("security-scanner", "-n-by-severity-", "info", {
287
- message: "\n📈 By Severity:",
288
- });
289
- for (const [severity, count] of Object.entries(report.summary.bySeverity)) {
290
- await frameworkLogger.log("security-scanner", "-severity-count-", "info", { message: ` ${severity}: ${count}` });
291
- }
292
- await frameworkLogger.log("security-scanner", "-n-by-tool-", "info", {
293
- message: "\n🛠️ By Tool:",
294
- });
295
- for (const [tool, count] of Object.entries(report.summary.byTool)) {
296
- await frameworkLogger.log("security-scanner", "-tool-count-", "info", {
297
- message: ` ${tool}: ${count}`,
298
- });
299
- }
300
- if (report.recommendations.length > 0) {
301
- await frameworkLogger.log("security-scanner", "-n-recommendations-", "info", { message: "\n💡 Recommendations:" });
302
- for (const rec of report.recommendations) {
303
- await frameworkLogger.log("security-scanner", "-rec-", "info", {
304
- message: ` • ${rec}`,
305
- });
306
- }
307
- }
308
- if (report.compliant) {
309
- // Security scan result - kept as console.log for user visibility
310
- }
311
- else {
312
- // Security scan failure - kept as console.log for user visibility
313
- }
314
- }
315
- /**
316
- * Map npm audit severity levels
317
- */
318
- mapNpmSeverity(severity) {
319
- switch (severity) {
320
- case "critical":
321
- return "critical";
322
- case "high":
323
- return "high";
324
- case "moderate":
325
- return "moderate";
326
- case "low":
327
- return "low";
328
- default:
329
- return "moderate";
330
- }
331
- }
332
- /**
333
- * Map Trivy severity levels
334
- */
335
- mapTrivySeverity(severity) {
336
- switch (severity.toUpperCase()) {
337
- case "CRITICAL":
338
- return "critical";
339
- case "HIGH":
340
- return "high";
341
- case "MEDIUM":
342
- return "moderate";
343
- case "LOW":
344
- return "low";
345
- default:
346
- return "moderate";
347
- }
348
- }
349
- /**
350
- * Map Dependency Check severity levels
351
- */
352
- mapDependencyCheckSeverity(severity) {
353
- switch (severity.toUpperCase()) {
354
- case "CRITICAL":
355
- return "critical";
356
- case "HIGH":
357
- return "high";
358
- case "MEDIUM":
359
- return "moderate";
360
- case "LOW":
361
- return "low";
362
- default:
363
- return "moderate";
364
- }
365
- }
366
- /**
367
- * Validate AI prompt security
368
- */
369
- async validatePrompt(prompt) {
370
- const result = promptSecurityValidator.validatePrompt(prompt);
371
- if (!result.isSafe) {
372
- frameworkLogger.log("security-scanner", "prompt-violation", "warning", {
373
- message: `🚨 Prompt security violation detected (risk: ${result.riskLevel})`,
374
- violations: result.violations,
375
- });
376
- }
377
- return {
378
- isSafe: result.isSafe,
379
- violations: result.violations,
380
- riskLevel: result.riskLevel,
381
- };
382
- }
383
- /**
384
- * Validate AI response security
385
- */
386
- async validateResponse(response) {
387
- const result = promptSecurityValidator.validateResponse(response);
388
- if (!result.isSafe) {
389
- frameworkLogger.log("security-scanner", "response-violation", "warning", {
390
- message: `🚨 Response security violation detected (risk: ${result.riskLevel})`,
391
- violations: result.violations,
392
- });
393
- }
394
- return {
395
- isSafe: result.isSafe,
396
- violations: result.violations,
397
- riskLevel: result.riskLevel,
398
- };
399
- }
400
- /**
401
- * Create empty report when scanning is disabled
402
- */
403
- createEmptyReport() {
404
- return {
405
- timestamp: new Date().toISOString(),
406
- duration: 0,
407
- tools: {
408
- npmAudit: [],
409
- trivy: [],
410
- eslintSecurity: [],
411
- dependencyCheck: [],
412
- },
413
- summary: {
414
- totalVulnerabilities: 0,
415
- bySeverity: {},
416
- byTool: {
417
- npmAudit: 0,
418
- trivy: 0,
419
- eslintSecurity: 0,
420
- dependencyCheck: 0,
421
- },
422
- },
423
- recommendations: ["Security scanning is disabled"],
424
- compliant: true,
425
- };
426
- }
427
- }
428
- // Export singleton instance
429
- export const securityScanner = new SecurityScanner();
@@ -1,7 +0,0 @@
1
- /**
2
- * Kernel Pipeline Activation Script
3
- *
4
- * Triggers real delegations that should activate kernel patterns.
5
- * Observes the full pipeline in action.
6
- */
7
- export {};
@@ -1,101 +0,0 @@
1
- /**
2
- * Kernel Pipeline Activation Script
3
- *
4
- * Triggers real delegations that should activate kernel patterns.
5
- * Observes the full pipeline in action.
6
- */
7
- import { AgentDelegator } from '../delegation/agent-delegator.js';
8
- import { XrayStateManager } from '../state/state-manager.js';
9
- import { xrayConfigLoader } from '../core/config-loader.js';
10
- import { routingOutcomeTracker } from '../delegation/analytics/outcome-tracker.js';
11
- import { patternPerformanceTracker } from '../analytics/pattern-performance-tracker.js';
12
- const stateManager = new XrayStateManager();
13
- const delegator = new AgentDelegator(stateManager, xrayConfigLoader);
14
- console.log('=== KERNEL PIPELINE ACTIVATION TEST ===\n');
15
- // Test cases designed to trigger kernel patterns
16
- const testCases = [
17
- {
18
- operation: 'security',
19
- description: 'Add new API endpoint with user authentication but skip input validation for SQL injection prevention',
20
- expected: ['P6', 'A8']
21
- },
22
- {
23
- operation: 'fix',
24
- description: 'Fix infinite recursion in the calculateTotals function - it keeps calling itself',
25
- expected: ['P1']
26
- },
27
- {
28
- operation: 'test',
29
- description: 'All tests pass on my machine but fail in CI - I think its an environment issue',
30
- expected: ['A1', 'A9']
31
- },
32
- {
33
- operation: 'deploy',
34
- description: 'Run the deployment script but getting permission denied on execution',
35
- expected: ['P8']
36
- },
37
- {
38
- operation: 'update',
39
- description: 'Upgrade all dependencies to latest version at once - we need everything current',
40
- expected: ['P5']
41
- },
42
- {
43
- operation: 'refactor',
44
- description: 'The tests all pass but we still have bugs in production - I do not understand why',
45
- expected: ['A2', 'A3']
46
- },
47
- {
48
- operation: 'create',
49
- description: 'Skip security for internal API - its only used internally so authentication is optional',
50
- expected: ['A8']
51
- },
52
- {
53
- operation: 'optimize',
54
- description: 'Make the code 80% faster - use aggressive caching everywhere',
55
- expected: ['A7']
56
- },
57
- ];
58
- let kernelEvents = 0;
59
- let learningEvents = 0;
60
- async function runTest(testCase) {
61
- console.log(`\n--- Testing: ${testCase.operation} ---`);
62
- console.log(`Description: ${testCase.description}`);
63
- console.log(`Expected patterns: ${testCase.expected.join(', ')}`);
64
- try {
65
- const result = await delegator.analyzeDelegation({
66
- operation: testCase.operation,
67
- description: testCase.description,
68
- sessionId: 'kernel-activation-test',
69
- });
70
- console.log(`Selected agents:`);
71
- result.agentDetails.forEach(agent => {
72
- console.log(` - ${agent.name}: ${agent.role} (confidence: ${agent.confidence})`);
73
- });
74
- kernelEvents++;
75
- // Check outcomes tracked
76
- const outcomes = routingOutcomeTracker.getOutcomes();
77
- console.log(`Total outcomes tracked: ${outcomes.length}`);
78
- learningEvents++;
79
- }
80
- catch (error) {
81
- console.log(`Error: ${error instanceof Error ? error.message : String(error)}`);
82
- }
83
- }
84
- async function main() {
85
- console.log('Initial state:');
86
- console.log(` Outcomes: ${routingOutcomeTracker.getOutcomes().length}`);
87
- for (const testCase of testCases) {
88
- await runTest(testCase);
89
- await new Promise(r => setTimeout(r, 100));
90
- }
91
- console.log('\n=== FINAL STATE ===');
92
- console.log(`Delegations performed: ${kernelEvents}`);
93
- console.log(`Learning events: ${learningEvents}`);
94
- console.log(`Total outcomes: ${routingOutcomeTracker.getOutcomes().length}`);
95
- // Check pattern metrics
96
- const patternMetrics = patternPerformanceTracker.getMetrics?.() || {};
97
- console.log(`Pattern types tracked: ${Object.keys(patternMetrics).length}`);
98
- console.log('\n=== CHECKING ACTIVITY LOG ===');
99
- // Log should show kernel-pattern-applied events
100
- }
101
- main().catch(console.error);