0xray 4.0.34 → 4.0.35

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 (155) hide show
  1. package/.grok-plugin/plugin.json +1 -1
  2. package/.xray/codex.json +12 -4
  3. package/.xray/features.json +1 -1
  4. package/AGENTS-consumer.md +6 -6
  5. package/AGENTS.md +5 -5
  6. package/README.md +2 -2
  7. package/dist/AGENTS.md +5 -5
  8. package/dist/CHANGELOG.md +16 -0
  9. package/dist/README.md +2 -2
  10. package/dist/cli/index.js +2 -5
  11. package/dist/governance/governance-service.js +1 -1
  12. package/dist/integrations/base/README.md +1 -9
  13. package/dist/integrations/base/index.d.ts +0 -1
  14. package/dist/integrations/base/index.js +0 -2
  15. package/dist/integrations/governance/index.js +31 -8
  16. package/dist/integrations/grok/hooks/grok-hook-utils.js +1 -1
  17. package/dist/integrations/grok/hooks/session-start.js +12 -0
  18. package/dist/integrations/hooks/goggles-pipeline.mjs +62 -11
  19. package/dist/integrations/hooks/host-truth.mjs +74 -0
  20. package/dist/integrations/hooks/station-hook-runtime.cjs +3 -0
  21. package/dist/integrations/openclaw/plugin/xray-pre-tool/package.json +1 -1
  22. package/dist/mcps/knowledge-skills/storyteller.server.js +0 -1
  23. package/dist/nucleus/delegation-gate.d.ts +2 -2
  24. package/dist/nucleus/delegation-gate.js +13 -2
  25. package/dist/nucleus/work-freshness.mjs +189 -0
  26. package/dist/processors/implementations/agents-md-validation-processor.js +1 -1
  27. package/docs-site/docs/plates/boot.md +17 -2
  28. package/docs-site/docs/plates/governance.md +3 -2
  29. package/docs-site/docs/plates/index.md +3 -1
  30. package/docs-site/docs/plates/memory-recall.md +26 -35
  31. package/docs-site/docs/plates/orchestration.md +39 -35
  32. package/docs-site/docs/plates/processor.md +34 -36
  33. package/docs-site/docs/plates/reporting.md +3 -8
  34. package/docs-site/docs/plates/routing.md +22 -11
  35. package/package.json +2 -2
  36. package/scripts/foundry/release.mjs +48 -5
  37. package/scripts/mjs/test-consumer-readiness.mjs +1 -0
  38. package/scripts/mjs/test-mcp-functionality.mjs +14 -9
  39. package/scripts/node/basic-security-audit.cjs +0 -1
  40. package/scripts/node/bridge-mcp-wiring.cjs +66 -3
  41. package/scripts/node/postinstall.cjs +1 -1
  42. package/scripts/node/prepare-consumer.cjs +11 -7
  43. package/scripts/node/setup-dev.cjs +18 -26
  44. package/scripts/node/validate-mcp-connectivity.js +2 -1
  45. package/src/integrations/openclaw/plugin/xray-pre-tool/package.json +1 -1
  46. package/src/mcps/knowledge-skills/storyteller.server.ts +0 -1
  47. package/xray/agents_template.md +5 -5
  48. package/xray/codex.json +12 -4
  49. package/xray/features.json +1 -1
  50. package/dist/agents/known-names.d.ts +0 -26
  51. package/dist/agents/known-names.js +0 -72
  52. package/dist/analytics/consent-manager.d.ts +0 -92
  53. package/dist/analytics/consent-manager.js +0 -257
  54. package/dist/benchmark/performance-benchmark.d.ts +0 -103
  55. package/dist/benchmark/performance-benchmark.js +0 -373
  56. package/dist/cli/commands/analytics-disable.d.ts +0 -9
  57. package/dist/cli/commands/analytics-disable.js +0 -72
  58. package/dist/cli/commands/analytics-enable-action.d.ts +0 -8
  59. package/dist/cli/commands/analytics-enable-action.js +0 -82
  60. package/dist/cli/commands/analytics-preview.d.ts +0 -9
  61. package/dist/cli/commands/analytics-preview.js +0 -106
  62. package/dist/cli/commands/analytics-status.d.ts +0 -9
  63. package/dist/cli/commands/analytics-status.js +0 -68
  64. package/dist/cli/commands/enforce.d.ts +0 -12
  65. package/dist/cli/commands/enforce.js +0 -78
  66. package/dist/cli/commands/govern.d.ts +0 -29
  67. package/dist/cli/commands/govern.js +0 -149
  68. package/dist/cli/commands/security-audit.d.ts +0 -23
  69. package/dist/cli/commands/security-audit.js +0 -219
  70. package/dist/cli/server.d.ts +0 -1
  71. package/dist/cli/server.js +0 -147
  72. package/dist/config/routing-mappings.d.ts +0 -26
  73. package/dist/config/routing-mappings.js +0 -151
  74. package/dist/core/bridge.mjs +0 -922
  75. package/dist/core/trace-context.d.ts +0 -12
  76. package/dist/core/trace-context.js +0 -33
  77. package/dist/enforcement/index.d.ts +0 -22
  78. package/dist/enforcement/index.js +0 -40
  79. package/dist/enforcement/loaders/index.d.ts +0 -36
  80. package/dist/enforcement/loaders/index.js +0 -39
  81. package/dist/enforcement/test-auto-healing.d.ts +0 -83
  82. package/dist/enforcement/test-auto-healing.js +0 -325
  83. package/dist/inference/index.d.ts +0 -10
  84. package/dist/inference/index.js +0 -5
  85. package/dist/infrastructure/iac-validator.d.ts +0 -150
  86. package/dist/infrastructure/iac-validator.js +0 -465
  87. package/dist/infrastructure/schemas/cloud-schemas.d.ts +0 -482
  88. package/dist/infrastructure/schemas/cloud-schemas.js +0 -488
  89. package/dist/integrations/base/ExampleIntegration.d.ts +0 -46
  90. package/dist/integrations/base/ExampleIntegration.js +0 -180
  91. package/dist/integrations/enforcement-gate.d.ts +0 -44
  92. package/dist/integrations/enforcement-gate.js +0 -348
  93. package/dist/mcps/connection/connection-manager.d.ts +0 -39
  94. package/dist/mcps/connection/connection-manager.js +0 -79
  95. package/dist/mcps/index.d.ts +0 -17
  96. package/dist/mcps/index.js +0 -65
  97. package/dist/mcps/orchestrator/index.d.ts +0 -6
  98. package/dist/mcps/orchestrator/index.js +0 -5
  99. package/dist/metrics/index.d.ts +0 -6
  100. package/dist/metrics/index.js +0 -6
  101. package/dist/orchestrator/self-direction-activation.d.ts +0 -108
  102. package/dist/orchestrator/self-direction-activation.js +0 -244
  103. package/dist/orchestrator/universal-registry-bridge.d.ts +0 -84
  104. package/dist/orchestrator/universal-registry-bridge.js +0 -246
  105. package/dist/performance/performance-budget-enforcer.d.ts +0 -157
  106. package/dist/performance/performance-budget-enforcer.js +0 -433
  107. package/dist/performance/performance-regression-tester.d.ts +0 -107
  108. package/dist/performance/performance-regression-tester.js +0 -341
  109. package/dist/postprocessor/analysis/CodeChangeAnalyzer.d.ts +0 -11
  110. package/dist/postprocessor/analysis/CodeChangeAnalyzer.js +0 -50
  111. package/dist/postprocessor/config/ProcessorConfigLoader.d.ts +0 -44
  112. package/dist/postprocessor/config/ProcessorConfigLoader.js +0 -16
  113. package/dist/postprocessor/integration.d.ts +0 -156
  114. package/dist/postprocessor/integration.js +0 -194
  115. package/dist/postprocessor/metamorphosis/index.d.ts +0 -2
  116. package/dist/postprocessor/metamorphosis/index.js +0 -1
  117. package/dist/postprocessor/redeploy/RetryHandler.d.ts +0 -49
  118. package/dist/postprocessor/redeploy/RetryHandler.js +0 -118
  119. package/dist/processors/implementations/session-capture-processor.d.ts +0 -14
  120. package/dist/processors/implementations/session-capture-processor.js +0 -37
  121. package/dist/public/XrayService.d.ts +0 -17
  122. package/dist/public/XrayService.js +0 -40
  123. package/dist/public/index.d.ts +0 -4
  124. package/dist/public/index.js +0 -2
  125. package/dist/security/comprehensive-security-audit.d.ts +0 -157
  126. package/dist/security/comprehensive-security-audit.js +0 -1004
  127. package/dist/security/index.d.ts +0 -13
  128. package/dist/security/index.js +0 -13
  129. package/dist/security/security-agent-coordinator.d.ts +0 -71
  130. package/dist/security/security-agent-coordinator.js +0 -203
  131. package/dist/security/security-hardening-system.d.ts +0 -238
  132. package/dist/security/security-hardening-system.js +0 -726
  133. package/dist/security/security-orchestration-layer.d.ts +0 -118
  134. package/dist/security/security-orchestration-layer.js +0 -495
  135. package/dist/testing/memory-regression-suite.d.ts +0 -105
  136. package/dist/testing/memory-regression-suite.js +0 -258
  137. package/dist/tools/assess-complexity-tool.d.ts +0 -28
  138. package/dist/tools/assess-complexity-tool.js +0 -44
  139. package/dist/tools/query-routing-tool.d.ts +0 -17
  140. package/dist/tools/query-routing-tool.js +0 -59
  141. package/dist/utils/batch-operations.d.ts +0 -25
  142. package/dist/utils/batch-operations.js +0 -292
  143. package/dist/utils/task-graph.d.ts +0 -29
  144. package/dist/utils/task-graph.js +0 -106
  145. package/dist/utils/test-template-generator.d.ts +0 -25
  146. package/dist/utils/test-template-generator.js +0 -178
  147. package/dist/utils/token-manager.d.ts +0 -48
  148. package/dist/utils/token-manager.js +0 -163
  149. package/dist/validation/agent-config-validator.d.ts +0 -110
  150. package/dist/validation/agent-config-validator.js +0 -280
  151. package/dist/validation/orchestration-flow-validator.d.ts +0 -87
  152. package/dist/validation/orchestration-flow-validator.js +0 -606
  153. package/src/mcps/connection/connection-manager.ts +0 -91
  154. package/src/mcps/index.ts +0 -80
  155. package/src/mcps/orchestrator/index.ts +0 -29
@@ -1,68 +0,0 @@
1
- /**
2
- * Analytics Status CLI Command
3
- *
4
- * Shows current consent and analytics status
5
- *
6
- * Usage: npx 0xray analytics status
7
- */
8
- import { program } from "commander";
9
- import { ConsentManager } from "../../analytics/consent-manager.js";
10
- import { getConfigDir } from "../../core/config-paths.js";
11
- export const analyticsStatusCommand = program
12
- .command("analytics status")
13
- .description("Show current analytics consent status")
14
- .option("-v, --verbose", "Show detailed information", false)
15
- .action(async (options) => {
16
- console.log("📊 0xRay Central Analytics Status\n");
17
- try {
18
- const consentManager = new ConsentManager();
19
- const status = await consentManager.getStatus();
20
- // Show main status
21
- const enabledEmoji = status.analyticsEnabled ? "✅ ENABLED" : "❌ DISABLED";
22
- console.log(`đŸŽ¯ Status: ${enabledEmoji}\n`);
23
- // Show project ID
24
- console.log(`📋 Project Information:`);
25
- console.log(` Project ID: ${status.projectId}`);
26
- console.log(` Consent Version: ${status.consentVersion}`);
27
- console.log(` Consent Date: ${status.consentDate.toISOString()}`);
28
- if (status.lastOptOut) {
29
- console.log(` Last Opt-Out: ${status.lastOptOut.toISOString()}`);
30
- }
31
- // Show category status
32
- console.log(`\n📂 Categories Status:`);
33
- const categories = consentManager.getCategories();
34
- categories.forEach(cat => {
35
- const emoji = cat.enabled ? "✅" : "❌";
36
- console.log(` ${emoji} ${cat.name.padEnd(15)} ${cat.description}`);
37
- });
38
- if (options.verbose) {
39
- // Show configuration file location
40
- const configDir = getConfigDir();
41
- console.log(`\n📁 Configuration Files:`);
42
- console.log(` Consent Config: ${configDir}/consent.json`);
43
- console.log(` Submission Queue: ${configDir}/analytics/submission-queue.json`);
44
- // Show detailed information
45
- console.log(`\n📊 Detailed Information:`);
46
- const enabledCats = categories.filter(c => c.enabled);
47
- console.log(` Enabled Categories: ${enabledCats.length}/${categories.length}`);
48
- console.log(` Analytics Active: ${status.analyticsEnabled}`);
49
- if (status.analyticsEnabled) {
50
- console.log(`\n💡 Your project is contributing to community learning!`);
51
- console.log(` â€ĸ View what's being submitted: npx 0xray analytics preview`);
52
- console.log(` â€ĸ Get community insights: npx 0xray analytics recommendations`);
53
- console.log(` â€ĸ Check performance: npx 0xray analytics`);
54
- }
55
- else {
56
- console.log(`\n💡 Analytics is currently disabled.`);
57
- console.log(` â€ĸ Enable anytime: npx 0xray analytics enable`);
58
- console.log(` â€ĸ Learn more: docs/architecture/central-analytics-store.md`);
59
- }
60
- }
61
- }
62
- catch (error) {
63
- console.error("❌ Failed to get analytics status:", error instanceof Error ? error.message : String(error));
64
- console.error("\n💡 Try: npx 0xray analytics status --help");
65
- process.exit(1);
66
- }
67
- });
68
- export default analyticsStatusCommand;
@@ -1,12 +0,0 @@
1
- interface EnforceOptions {
2
- phase: string;
3
- tool?: string;
4
- args?: string;
5
- result?: string;
6
- error?: string;
7
- files?: string;
8
- code?: string;
9
- focusAreas?: string;
10
- }
11
- export declare function enforceCommand(options: EnforceOptions): Promise<void>;
12
- export {};
@@ -1,78 +0,0 @@
1
- import { beforeToolHook, afterToolHook } from "../../integrations/enforcement-gate.js";
2
- import { frameworkLogger } from "../../core/framework-logger.js";
3
- import { mcpClientManager } from "../../mcps/mcp-client.js";
4
- export async function enforceCommand(options) {
5
- const phase = options.phase || "health";
6
- let parsedArgs = null;
7
- if (options.args) {
8
- try {
9
- parsedArgs = JSON.parse(options.args);
10
- }
11
- catch {
12
- parsedArgs = {};
13
- }
14
- }
15
- try {
16
- switch (phase) {
17
- case "pre": {
18
- const result = await beforeToolHook(options.tool || "unknown", parsedArgs);
19
- process.stdout.write(JSON.stringify(result) + "\n");
20
- break;
21
- }
22
- case "post": {
23
- let parsedResult = null;
24
- if (options.result) {
25
- try {
26
- parsedResult = JSON.parse(options.result);
27
- }
28
- catch { }
29
- }
30
- const result = await afterToolHook(options.tool || "unknown", parsedArgs, parsedResult, options.error || null);
31
- process.stdout.write(JSON.stringify(result) + "\n");
32
- break;
33
- }
34
- case "validate": {
35
- let files = [];
36
- if (options.files) {
37
- try {
38
- files = JSON.parse(options.files);
39
- }
40
- catch { }
41
- }
42
- const result = await mcpClientManager.callServerTool("enforcer", "run-pre-commit-validation", { files, operation: "commit" });
43
- process.stdout.write(JSON.stringify(result) + "\n");
44
- break;
45
- }
46
- case "codex-check": {
47
- let focusAreas = [];
48
- if (options.focusAreas) {
49
- try {
50
- focusAreas = JSON.parse(options.focusAreas);
51
- }
52
- catch { }
53
- }
54
- const result = await mcpClientManager.callServerTool("enforcer", "codex-enforcement", {
55
- operation: "write",
56
- newCode: options.code || "",
57
- focusAreas,
58
- });
59
- process.stdout.write(JSON.stringify(result) + "\n");
60
- break;
61
- }
62
- case "health": {
63
- const result = await mcpClientManager.callServerTool("enforcer", "get-enforcement-status", {});
64
- process.stdout.write(JSON.stringify(result) + "\n");
65
- break;
66
- }
67
- default:
68
- process.stderr.write(`Unknown phase: ${phase}\n`);
69
- process.exit(1);
70
- }
71
- }
72
- catch (err) {
73
- const errMsg = err instanceof Error ? err.message : String(err);
74
- await frameworkLogger.log("enforce-command", "execution-error", "error", { phase, error: errMsg });
75
- const fallback = { status: "error", phase, error: errMsg };
76
- process.stdout.write(JSON.stringify(fallback) + "\n");
77
- }
78
- }
@@ -1,29 +0,0 @@
1
- /**
2
- * xray govern — the primary CLI command for the v3 nucleus
3
- *
4
- * Usage:
5
- * xray govern [options]
6
- *
7
- * All existing direct commands still work (backward compat with deprecation notice).
8
- */
9
- interface GovernOptions {
10
- status?: boolean;
11
- audit?: boolean;
12
- mcp?: string;
13
- pluginInstall?: string;
14
- proposals?: string;
15
- skillInstall?: string;
16
- skillRegistry?: string;
17
- storyteller?: string;
18
- mcpList?: boolean;
19
- mcpStatus?: boolean;
20
- mcpInstall?: string;
21
- mcpRemove?: string;
22
- publishAgent?: boolean;
23
- archiveLogs?: boolean;
24
- credibleInit?: string;
25
- antigravityStatus?: boolean;
26
- [key: string]: unknown;
27
- }
28
- export declare function governCommand(options: GovernOptions): Promise<void>;
29
- export {};
@@ -1,149 +0,0 @@
1
- /**
2
- * xray govern — the primary CLI command for the v3 nucleus
3
- *
4
- * Usage:
5
- * xray govern [options]
6
- *
7
- * All existing direct commands still work (backward compat with deprecation notice).
8
- */
9
- import { resolve, join } from 'path';
10
- import { readFileSync, existsSync } from 'fs';
11
- import { spawn } from 'child_process';
12
- export async function governCommand(options) {
13
- if (options.status) {
14
- const { statusCommand } = await import('./status.js');
15
- await statusCommand();
16
- return;
17
- }
18
- if (options.audit) {
19
- const { securityAuditCommand } = await import('./security-audit.js');
20
- await securityAuditCommand();
21
- return;
22
- }
23
- if (options.mcp) {
24
- const serverMap = {
25
- governance: 'dist/mcps/governance.server.js',
26
- skills: 'dist/mcps/knowledge-skills/skill-invocation.server.js',
27
- };
28
- const relPath = serverMap[options.mcp];
29
- if (!relPath) {
30
- console.error(`Unknown MCP server: ${options.mcp}. Use: governance, skills`);
31
- process.exit(1);
32
- }
33
- const packageJsonPath = resolve(import.meta.url.replace(/^file:/, ''), '..', '..', 'package.json');
34
- const pkg = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
35
- const packageRoot = resolve(packageJsonPath, '..', pkg.xray?.dist ? join('', pkg.xray.dist) : 'dist', '..');
36
- const serverPath = resolve(join(packageRoot, relPath));
37
- if (!existsSync(serverPath)) {
38
- console.error(`MCP server not found at ${serverPath}. Is xray installed correctly?`);
39
- process.exit(1);
40
- }
41
- const env = { ...process.env };
42
- const child = spawn(process.execPath, [serverPath], { stdio: 'inherit', env });
43
- child.on('exit', (code) => process.exit(code ?? 0));
44
- return;
45
- }
46
- if (options.pluginInstall) {
47
- const { pluginInstallCommand } = await import('./plugin-commands.js');
48
- await pluginInstallCommand(options.pluginInstall);
49
- return;
50
- }
51
- if (options.proposals) {
52
- const { handleGovernRequest } = await import('../../nucleus/index.js');
53
- let proposals;
54
- try {
55
- proposals = JSON.parse(options.proposals);
56
- }
57
- catch {
58
- console.error('Invalid JSON in --proposals. Expected a JSON string with a "proposals" array.');
59
- console.error('Example: xray govern --proposals \'[{"type":"fix","title":"Test","description":"A test"}]\'');
60
- process.exit(1);
61
- }
62
- const result = await handleGovernRequest(proposals);
63
- console.log(JSON.stringify(result, null, 2));
64
- return;
65
- }
66
- if (options.skillInstall !== undefined) {
67
- const { skillInstallCommand } = await import('./skill-install.js');
68
- await skillInstallCommand(options.skillInstall || undefined);
69
- return;
70
- }
71
- if (options.skillRegistry !== undefined) {
72
- const { skillRegistryCommand } = await import('./skill-install.js');
73
- await skillRegistryCommand(options.skillRegistry || undefined);
74
- return;
75
- }
76
- if (options.storyteller) {
77
- const { storytellerCommand } = await import('./storyteller.js');
78
- await storytellerCommand(options.storyteller);
79
- return;
80
- }
81
- if (options.mcpList) {
82
- const { listMCPsCommand } = await import('./mcp-install.js');
83
- listMCPsCommand();
84
- return;
85
- }
86
- if (options.mcpStatus) {
87
- const { showMCPStatusCommand } = await import('./mcp-install.js');
88
- showMCPStatusCommand();
89
- return;
90
- }
91
- if (options.mcpInstall) {
92
- const { installMCPCommand } = await import('./mcp-install.js');
93
- await installMCPCommand(options.mcpInstall);
94
- return;
95
- }
96
- if (options.mcpRemove) {
97
- const { removeMCPCommand } = await import('./mcp-install.js');
98
- removeMCPCommand(options.mcpRemove);
99
- return;
100
- }
101
- if (options.publishAgent) {
102
- const { publishAgentCommand } = await import('./publish-agent.js');
103
- await publishAgentCommand();
104
- return;
105
- }
106
- if (options.archiveLogs) {
107
- const { archiveLogFiles } = await import('./archive-logs.js');
108
- const result = await archiveLogFiles(undefined, `govern-${Date.now()}`);
109
- console.log(`\nResults:`);
110
- console.log(` Archived: ${result.archived} files`);
111
- if (result.errors.length > 0) {
112
- console.log(` Errors: ${result.errors.length}`);
113
- result.errors.forEach((e) => console.log(` - ${e}`));
114
- process.exit(1);
115
- }
116
- return;
117
- }
118
- if (options.credibleInit !== undefined) {
119
- const { credibleInitCommand } = await import('./credible-init.js');
120
- await credibleInitCommand();
121
- return;
122
- }
123
- if (options.antigravityStatus) {
124
- const { antigravityStatusCommand } = await import('./antigravity-status.js');
125
- await antigravityStatusCommand();
126
- return;
127
- }
128
- console.log('xray govern — the governance kernel\n');
129
- console.log('Usage: xray govern [options]\n');
130
- console.log('Options:');
131
- console.log(' --status Show framework status');
132
- console.log(' --audit Run security audit');
133
- console.log(' --mcp <server> Run an MCP server (governance, skills)');
134
- console.log(' --plugin-install <name> Install a plugin');
135
- console.log(' --proposals <json> Run governance on JSON proposals');
136
- console.log(' --skill-install [source] Install skills from registry');
137
- console.log(' --skill-registry [action] Manage skill registry sources');
138
- console.log(' --storyteller <type> Write a story (reflection, saga, journey, narrative)');
139
- console.log(' --mcp-list List available MCP servers');
140
- console.log(' --mcp-status Show installed MCP servers');
141
- console.log(' --mcp-install <name> Install an MCP server');
142
- console.log(' --mcp-remove <name> Remove an MCP server');
143
- console.log(' --publish-agent Publish an agent to AgentStore');
144
- console.log(' --archive-logs Archive log files');
145
- console.log(' --credible-init [name] Initialize Credible Pod');
146
- console.log(' --antigravity-status Show installed skills status');
147
- console.log(' -h, --help Show this help\n');
148
- console.log('All existing commands still work: xray status, xray security-audit, etc.');
149
- }
@@ -1,23 +0,0 @@
1
- /**
2
- * Security Audit CLI Command
3
- *
4
- * Comprehensive security audit with vulnerability scanning,
5
- * compliance checking, and weighted voting for architectural decisions.
6
- *
7
- * Usage:
8
- * npx 0xray security-audit # Quick audit
9
- * npx 0xray security-audit --deep # Deep audit with all standards
10
- * npx 0xray security-audit --output ./reports/security.md
11
- * npx 0xray security-audit --no-remediation
12
- * npx 0xray security-audit --no-voting
13
- *
14
- * Options:
15
- * --deep Deep scan with all compliance standards (OWASP, CWE, NIST, ISO, PCI)
16
- * --output <path> Output report to file (JSON or Markdown)
17
- * --format <fmt> Output format: json, markdown (default: markdown)
18
- * --no-remediation Skip automated remediation analysis
19
- * --no-voting Disable weighted voting for architectural decisions
20
- * --project <path> Project path to audit (default: current directory)
21
- */
22
- export declare function securityAuditCommand(args?: string[]): Promise<void>;
23
- export default securityAuditCommand;
@@ -1,219 +0,0 @@
1
- /**
2
- * Security Audit CLI Command
3
- *
4
- * Comprehensive security audit with vulnerability scanning,
5
- * compliance checking, and weighted voting for architectural decisions.
6
- *
7
- * Usage:
8
- * npx 0xray security-audit # Quick audit
9
- * npx 0xray security-audit --deep # Deep audit with all standards
10
- * npx 0xray security-audit --output ./reports/security.md
11
- * npx 0xray security-audit --no-remediation
12
- * npx 0xray security-audit --no-voting
13
- *
14
- * Options:
15
- * --deep Deep scan with all compliance standards (OWASP, CWE, NIST, ISO, PCI)
16
- * --output <path> Output report to file (JSON or Markdown)
17
- * --format <fmt> Output format: json, markdown (default: markdown)
18
- * --no-remediation Skip automated remediation analysis
19
- * --no-voting Disable weighted voting for architectural decisions
20
- * --project <path> Project path to audit (default: current directory)
21
- */
22
- import { join } from "path";
23
- import { writeFileSync, existsSync, mkdirSync } from "fs";
24
- import { frameworkLogger } from "../../core/framework-logger.js";
25
- import { createSecurityAuditSystem, runQuickSecurityAudit, runDeepSecurityAudit, } from "../../security/comprehensive-security-audit.js";
26
- function parseArgs(args) {
27
- const options = {
28
- deep: false,
29
- output: null,
30
- format: "markdown",
31
- enableRemediation: true,
32
- enableVoting: true,
33
- projectPath: null,
34
- };
35
- for (let i = 0; i < args.length; i++) {
36
- const arg = args[i];
37
- switch (arg) {
38
- case "--deep":
39
- options.deep = true;
40
- break;
41
- case "--output":
42
- case "-o":
43
- options.output = args[++i] || null;
44
- break;
45
- case "--format":
46
- case "-f":
47
- const format = args[++i]?.toLowerCase();
48
- if (format === "json" || format === "markdown") {
49
- options.format = format;
50
- }
51
- break;
52
- case "--no-remediation":
53
- options.enableRemediation = false;
54
- break;
55
- case "--no-voting":
56
- options.enableVoting = false;
57
- break;
58
- case "--project":
59
- case "-p":
60
- options.projectPath = args[++i] || null;
61
- break;
62
- case "--help":
63
- case "-h":
64
- printHelp();
65
- process.exit(0);
66
- break;
67
- }
68
- }
69
- return options;
70
- }
71
- function printHelp() {
72
- console.log(`
73
- 0xRay Security Audit Command
74
-
75
- Comprehensive security audit with vulnerability scanning, compliance checking,
76
- and weighted voting for architectural decisions.
77
-
78
- Usage:
79
- npx 0xray security-audit [options]
80
-
81
- Options:
82
- --deep Deep scan with all compliance standards
83
- --output, -o Output report to file
84
- --format, -f Output format: json, markdown (default: markdown)
85
- --no-remediation Skip automated remediation analysis
86
- --no-voting Disable weighted voting for architectural decisions
87
- --project, -p Project path to audit
88
- --help, -h Show this help message
89
-
90
- Examples:
91
- npx 0xray security-audit
92
- npx 0xray security-audit --deep
93
- npx 0xray security-audit --output ./security-report.md
94
- npx 0xray security-audit --format json --output ./report.json
95
- `);
96
- }
97
- async function runSecurityAudit(options) {
98
- const projectPath = options.projectPath || process.cwd();
99
- const config = {
100
- projectPath,
101
- scanDepth: options.deep ? "deep" : "shallow",
102
- includeDependencies: true,
103
- complianceStandards: options.deep
104
- ? ["owasp-top-10", "cwe", "nist", "iso-27001", "pci-dss"]
105
- : ["owasp-top-10", "cwe"],
106
- enableAutoRemediation: options.enableRemediation,
107
- enableWeightedVoting: options.enableVoting,
108
- };
109
- await frameworkLogger.log("security-audit-cli", "audit-started", "info", {
110
- projectPath,
111
- deep: options.deep,
112
- format: options.format,
113
- });
114
- if (options.deep) {
115
- return runDeepSecurityAudit(projectPath, options.output || undefined);
116
- }
117
- return runQuickSecurityAudit(projectPath);
118
- }
119
- function formatReport(report, format) {
120
- if (format === "json") {
121
- return JSON.stringify(report, null, 2);
122
- }
123
- const system = createSecurityAuditSystem({
124
- projectPath: report.metadata.projectPath,
125
- enableWeightedVoting: false,
126
- });
127
- return system.generateMarkdownReport(report);
128
- }
129
- function printSummary(report) {
130
- const scoreEmoji = report.summary.securityScore >= 90
131
- ? "đŸŸĸ"
132
- : report.summary.securityScore >= 70
133
- ? "🟡"
134
- : report.summary.securityScore >= 50
135
- ? "🟠"
136
- : "🔴";
137
- console.log("");
138
- console.log("╔══════════════════════════════════════════════════════════╗");
139
- console.log("║ 0xRay Security Audit Report ║");
140
- console.log("╚══════════════════════════════════════════════════════════╝");
141
- console.log("");
142
- console.log(` 📊 Security Score: ${scoreEmoji} ${report.summary.securityScore}/100`);
143
- console.log(` 📁 Files Scanned: ${report.metadata.totalFilesScanned}`);
144
- console.log(` âąī¸ Duration: ${report.metadata.duration}ms`);
145
- console.log("");
146
- console.log(" Vulnerability Summary:");
147
- console.log(` 🚨 Critical: ${report.summary.bySeverity.critical}`);
148
- console.log(` 🔴 High: ${report.summary.bySeverity.high}`);
149
- console.log(` 🟡 Medium: ${report.summary.bySeverity.medium}`);
150
- console.log(` đŸŸĸ Low: ${report.summary.bySeverity.low}`);
151
- console.log(` â„šī¸ Info: ${report.summary.bySeverity.info}`);
152
- console.log("");
153
- if (report.compliance.length > 0) {
154
- console.log(" Compliance Results:");
155
- for (const result of report.compliance) {
156
- const status = result.passed ? "✅" : "❌";
157
- console.log(` ${status} ${result.standard}: ${result.score}/100`);
158
- }
159
- console.log("");
160
- }
161
- if (report.remediation.totalIssues > 0) {
162
- console.log(" Remediation Plan:");
163
- console.log(` Total Issues: ${report.remediation.totalIssues}`);
164
- console.log(` Automatable: ${report.remediation.automatable}`);
165
- console.log(` Manual Fix: ${report.remediation.manualRequired}`);
166
- console.log(` Est. Time: ${report.remediation.estimatedFixTime}`);
167
- console.log("");
168
- }
169
- if (report.agentConsensus) {
170
- console.log(" Agent Consensus:");
171
- console.log(` Agreement: ${report.agentConsensus.averageAgreement}%`);
172
- console.log(` Agents: ${report.agentConsensus.participatingAgents.join(", ")}`);
173
- console.log("");
174
- }
175
- console.log(` Audit ID: ${report.metadata.auditId}`);
176
- console.log(` Generated: ${report.metadata.timestamp.toISOString()}`);
177
- console.log("");
178
- }
179
- function saveReport(content, outputPath) {
180
- const dir = join(outputPath, "..");
181
- if (!existsSync(dir)) {
182
- mkdirSync(dir, { recursive: true });
183
- }
184
- writeFileSync(outputPath, content, "utf-8");
185
- }
186
- export async function securityAuditCommand(args = process.argv.slice(2)) {
187
- try {
188
- const options = parseArgs(args);
189
- const report = await runSecurityAudit(options);
190
- printSummary(report);
191
- if (options.output) {
192
- const content = formatReport(report, options.format);
193
- saveReport(content, options.output);
194
- console.log(` 📄 Report saved to: ${options.output}`);
195
- console.log("");
196
- }
197
- await frameworkLogger.log("security-audit-cli", "audit-completed", "info", {
198
- auditId: report.metadata.auditId,
199
- vulnerabilities: report.summary.totalVulnerabilities,
200
- securityScore: report.summary.securityScore,
201
- output: options.output,
202
- });
203
- process.exit(report.summary.bySeverity.critical > 0 ? 2 : 0);
204
- }
205
- catch (error) {
206
- await frameworkLogger.log("security-audit-cli", "audit-failed", "error", {
207
- error: String(error),
208
- });
209
- console.error("");
210
- console.error(" ❌ Security audit failed:");
211
- console.error(` ${error}`);
212
- console.error("");
213
- process.exit(1);
214
- }
215
- }
216
- export default securityAuditCommand;
217
- if (import.meta.url === `file://${process.argv[1]}`) {
218
- securityAuditCommand();
219
- }
@@ -1 +0,0 @@
1
- export {};