kynjal-cli 4.0.0 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/appliance/gguf-engine.d.ts +91 -0
- package/dist/src/appliance/gguf-engine.d.ts.map +1 -0
- package/dist/src/appliance/gguf-engine.js +286 -525
- package/dist/src/appliance/gguf-engine.js.map +1 -1
- package/dist/src/appliance/ruvllm-bridge.d.ts +102 -0
- package/dist/src/appliance/ruvllm-bridge.d.ts.map +1 -0
- package/dist/src/appliance/ruvllm-bridge.js +203 -403
- package/dist/src/appliance/ruvllm-bridge.js.map +1 -1
- package/dist/src/appliance/rvfa-builder.d.ts +44 -0
- package/dist/src/appliance/rvfa-builder.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-builder.js +154 -208
- package/dist/src/appliance/rvfa-builder.js.map +1 -1
- package/dist/src/appliance/rvfa-distribution.d.ts +97 -0
- package/dist/src/appliance/rvfa-distribution.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-distribution.js +260 -423
- package/dist/src/appliance/rvfa-distribution.js.map +1 -1
- package/dist/src/appliance/rvfa-format.d.ts +111 -0
- package/dist/src/appliance/rvfa-format.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-format.js +128 -200
- package/dist/src/appliance/rvfa-format.js.map +1 -1
- package/dist/src/appliance/rvfa-runner.d.ts +69 -0
- package/dist/src/appliance/rvfa-runner.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-runner.js +168 -304
- package/dist/src/appliance/rvfa-runner.js.map +1 -1
- package/dist/src/appliance/rvfa-signing.d.ts +123 -0
- package/dist/src/appliance/rvfa-signing.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-signing.js +173 -295
- package/dist/src/appliance/rvfa-signing.js.map +1 -1
- package/dist/src/benchmarks/pretrain/index.d.ts +58 -0
- package/dist/src/benchmarks/pretrain/index.d.ts.map +1 -0
- package/dist/src/benchmarks/pretrain/index.js +331 -542
- package/dist/src/benchmarks/pretrain/index.js.map +1 -1
- package/dist/src/commands/agent.js +574 -697
- package/dist/src/commands/agent.js.map +1 -1
- package/dist/src/commands/analyze.js +1218 -1548
- package/dist/src/commands/analyze.js.map +1 -1
- package/dist/src/commands/appliance-advanced.js +158 -267
- package/dist/src/commands/appliance-advanced.js.map +1 -1
- package/dist/src/commands/appliance.js +318 -493
- package/dist/src/commands/appliance.js.map +1 -1
- package/dist/src/commands/benchmark.js +372 -523
- package/dist/src/commands/benchmark.js.map +1 -1
- package/dist/src/commands/claims.js +274 -364
- package/dist/src/commands/claims.js.map +1 -1
- package/dist/src/commands/cleanup.js +113 -157
- package/dist/src/commands/cleanup.js.map +1 -1
- package/dist/src/commands/completions.js +477 -118
- package/dist/src/commands/completions.js.map +1 -1
- package/dist/src/commands/config.js +237 -303
- package/dist/src/commands/config.js.map +1 -1
- package/dist/src/commands/daemon.js +487 -596
- package/dist/src/commands/daemon.js.map +1 -1
- package/dist/src/commands/deployment.js +194 -275
- package/dist/src/commands/deployment.js.map +1 -1
- package/dist/src/commands/doctor.js +504 -686
- package/dist/src/commands/doctor.js.map +1 -1
- package/dist/src/commands/embeddings.js +1293 -1543
- package/dist/src/commands/embeddings.js.map +1 -1
- package/dist/src/commands/guidance.js +449 -596
- package/dist/src/commands/guidance.js.map +1 -1
- package/dist/src/commands/hive-mind.js +854 -938
- package/dist/src/commands/hive-mind.js.map +1 -1
- package/dist/src/commands/hooks.js +3112 -3519
- package/dist/src/commands/hooks.js.map +1 -1
- package/dist/src/commands/index.d.ts +115 -0
- package/dist/src/commands/index.d.ts.map +1 -0
- package/dist/src/commands/index.js +126 -308
- package/dist/src/commands/index.js.map +1 -1
- package/dist/src/commands/init.js +788 -940
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/issues.js +383 -558
- package/dist/src/commands/issues.js.map +1 -1
- package/dist/src/commands/mcp.js +493 -605
- package/dist/src/commands/mcp.js.map +1 -1
- package/dist/src/commands/memory.js +833 -1026
- package/dist/src/commands/memory.js.map +1 -1
- package/dist/src/commands/migrate.js +282 -347
- package/dist/src/commands/migrate.js.map +1 -1
- package/dist/src/commands/neural.js +1289 -1563
- package/dist/src/commands/neural.js.map +1 -1
- package/dist/src/commands/performance.js +497 -643
- package/dist/src/commands/performance.js.map +1 -1
- package/dist/src/commands/plugins.js +668 -841
- package/dist/src/commands/plugins.js.map +1 -1
- package/dist/src/commands/process.js +392 -447
- package/dist/src/commands/process.js.map +1 -1
- package/dist/src/commands/progress.js +162 -256
- package/dist/src/commands/progress.js.map +1 -1
- package/dist/src/commands/providers.js +150 -220
- package/dist/src/commands/providers.js.map +1 -1
- package/dist/src/commands/route.js +520 -665
- package/dist/src/commands/route.js.map +1 -1
- package/dist/src/commands/ruvector/backup.js +505 -651
- package/dist/src/commands/ruvector/backup.js.map +1 -1
- package/dist/src/commands/ruvector/benchmark.js +349 -401
- package/dist/src/commands/ruvector/benchmark.js.map +1 -1
- package/dist/src/commands/ruvector/import.js +224 -266
- package/dist/src/commands/ruvector/import.js.map +1 -1
- package/dist/src/commands/ruvector/index.js +37 -75
- package/dist/src/commands/ruvector/index.js.map +1 -1
- package/dist/src/commands/ruvector/init.js +336 -359
- package/dist/src/commands/ruvector/init.js.map +1 -1
- package/dist/src/commands/ruvector/migrate.js +335 -322
- package/dist/src/commands/ruvector/migrate.js.map +1 -1
- package/dist/src/commands/ruvector/optimize.js +375 -431
- package/dist/src/commands/ruvector/optimize.js.map +1 -1
- package/dist/src/commands/ruvector/setup.js +703 -117
- package/dist/src/commands/ruvector/setup.js.map +1 -1
- package/dist/src/commands/ruvector/status.js +364 -419
- package/dist/src/commands/ruvector/status.js.map +1 -1
- package/dist/src/commands/security.js +485 -608
- package/dist/src/commands/security.js.map +1 -1
- package/dist/src/commands/session.js +504 -626
- package/dist/src/commands/session.js.map +1 -1
- package/dist/src/commands/start.js +267 -364
- package/dist/src/commands/start.js.map +1 -1
- package/dist/src/commands/status.js +380 -486
- package/dist/src/commands/status.js.map +1 -1
- package/dist/src/commands/swarm.js +408 -488
- package/dist/src/commands/swarm.js.map +1 -1
- package/dist/src/commands/task.js +423 -538
- package/dist/src/commands/task.js.map +1 -1
- package/dist/src/commands/transfer-store.js +322 -412
- package/dist/src/commands/transfer-store.js.map +1 -1
- package/dist/src/commands/update.js +196 -291
- package/dist/src/commands/update.js.map +1 -1
- package/dist/src/commands/workflow.js +386 -486
- package/dist/src/commands/workflow.js.map +1 -1
- package/dist/src/config-adapter.d.ts +15 -0
- package/dist/src/config-adapter.d.ts.map +1 -0
- package/dist/src/config-adapter.js +38 -39
- package/dist/src/config-adapter.js.map +1 -1
- package/dist/src/index.d.ts +77 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +309 -411
- package/dist/src/index.js.map +1 -1
- package/dist/src/infrastructure/in-memory-repositories.d.ts +68 -0
- package/dist/src/infrastructure/in-memory-repositories.d.ts.map +1 -0
- package/dist/src/infrastructure/in-memory-repositories.js +246 -507
- package/dist/src/infrastructure/in-memory-repositories.js.map +1 -1
- package/dist/src/init/claudemd-generator.d.ts +25 -0
- package/dist/src/init/claudemd-generator.d.ts.map +1 -0
- package/dist/src/init/claudemd-generator.js +368 -78
- package/dist/src/init/claudemd-generator.js.map +1 -1
- package/dist/src/init/executor.d.ts +41 -0
- package/dist/src/init/executor.d.ts.map +1 -0
- package/dist/src/init/executor.js +1307 -996
- package/dist/src/init/executor.js.map +1 -1
- package/dist/src/init/helpers-generator.d.ts +60 -0
- package/dist/src/init/helpers-generator.d.ts.map +1 -0
- package/dist/src/init/helpers-generator.js +657 -12
- package/dist/src/init/helpers-generator.js.map +1 -1
- package/dist/src/init/index.d.ts +1 -1
- package/dist/src/init/index.d.ts.map +1 -1
- package/dist/src/init/index.js +1 -1
- package/dist/src/init/index.js.map +1 -1
- package/dist/src/init/mcp-generator.js +33 -37
- package/dist/src/init/mcp-generator.js.map +1 -1
- package/dist/src/init/settings-generator.js +76 -77
- package/dist/src/init/settings-generator.js.map +1 -1
- package/dist/src/init/statusline-generator.js +801 -3
- package/dist/src/init/statusline-generator.js.map +1 -1
- package/dist/src/init/types.d.ts +1 -1
- package/dist/src/init/types.d.ts.map +1 -1
- package/dist/src/init/types.js +76 -59
- package/dist/src/init/types.js.map +1 -1
- package/dist/src/mcp-client.d.ts +92 -0
- package/dist/src/mcp-client.d.ts.map +1 -0
- package/dist/src/mcp-client.js +81 -125
- package/dist/src/mcp-client.js.map +1 -1
- package/dist/src/mcp-server.d.ts +161 -0
- package/dist/src/mcp-server.d.ts.map +1 -0
- package/dist/src/mcp-server.js +470 -757
- package/dist/src/mcp-server.js.map +1 -1
- package/dist/src/mcp-tools/agent-tools.js +391 -492
- package/dist/src/mcp-tools/agent-tools.js.map +1 -1
- package/dist/src/mcp-tools/agentdb-tools.js +332 -533
- package/dist/src/mcp-tools/agentdb-tools.js.map +1 -1
- package/dist/src/mcp-tools/analyze-tools.js +172 -236
- package/dist/src/mcp-tools/analyze-tools.js.map +1 -1
- package/dist/src/mcp-tools/auto-install.d.ts +83 -0
- package/dist/src/mcp-tools/auto-install.d.ts.map +1 -0
- package/dist/src/mcp-tools/auto-install.js +80 -142
- package/dist/src/mcp-tools/auto-install.js.map +1 -1
- package/dist/src/mcp-tools/browser-tools.js +252 -375
- package/dist/src/mcp-tools/browser-tools.js.map +1 -1
- package/dist/src/mcp-tools/claims-tools.js +473 -565
- package/dist/src/mcp-tools/claims-tools.js.map +1 -1
- package/dist/src/mcp-tools/config-tools.js +197 -272
- package/dist/src/mcp-tools/config-tools.js.map +1 -1
- package/dist/src/mcp-tools/coordination-tools.js +500 -572
- package/dist/src/mcp-tools/coordination-tools.js.map +1 -1
- package/dist/src/mcp-tools/daa-tools.js +286 -364
- package/dist/src/mcp-tools/daa-tools.js.map +1 -1
- package/dist/src/mcp-tools/embeddings-tools.js +582 -693
- package/dist/src/mcp-tools/embeddings-tools.js.map +1 -1
- package/dist/src/mcp-tools/github-tools.js +260 -311
- package/dist/src/mcp-tools/github-tools.js.map +1 -1
- package/dist/src/mcp-tools/hive-mind-tools.js +573 -640
- package/dist/src/mcp-tools/hive-mind-tools.js.map +1 -1
- package/dist/src/mcp-tools/hooks-tools.js +2215 -2648
- package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
- package/dist/src/mcp-tools/memory-tools.js +350 -505
- package/dist/src/mcp-tools/memory-tools.js.map +1 -1
- package/dist/src/mcp-tools/neural-tools.js +315 -412
- package/dist/src/mcp-tools/neural-tools.js.map +1 -1
- package/dist/src/mcp-tools/performance-tools.js +420 -480
- package/dist/src/mcp-tools/performance-tools.js.map +1 -1
- package/dist/src/mcp-tools/progress-tools.js +204 -278
- package/dist/src/mcp-tools/progress-tools.js.map +1 -1
- package/dist/src/mcp-tools/ruvllm-tools.js +163 -279
- package/dist/src/mcp-tools/ruvllm-tools.js.map +1 -1
- package/dist/src/mcp-tools/security-tools.js +297 -429
- package/dist/src/mcp-tools/security-tools.js.map +1 -1
- package/dist/src/mcp-tools/session-tools.js +185 -234
- package/dist/src/mcp-tools/session-tools.js.map +1 -1
- package/dist/src/mcp-tools/swarm-tools.js +207 -260
- package/dist/src/mcp-tools/swarm-tools.js.map +1 -1
- package/dist/src/mcp-tools/system-tools.js +276 -325
- package/dist/src/mcp-tools/system-tools.js.map +1 -1
- package/dist/src/mcp-tools/task-tools.js +270 -336
- package/dist/src/mcp-tools/task-tools.js.map +1 -1
- package/dist/src/mcp-tools/terminal-tools.js +148 -196
- package/dist/src/mcp-tools/terminal-tools.js.map +1 -1
- package/dist/src/mcp-tools/transfer-tools.js +186 -333
- package/dist/src/mcp-tools/transfer-tools.js.map +1 -1
- package/dist/src/mcp-tools/types.d.ts +31 -0
- package/dist/src/mcp-tools/types.d.ts.map +1 -0
- package/dist/src/mcp-tools/wasm-agent-tools.js +133 -280
- package/dist/src/mcp-tools/wasm-agent-tools.js.map +1 -1
- package/dist/src/mcp-tools/workflow-tools.js +405 -450
- package/dist/src/mcp-tools/workflow-tools.js.map +1 -1
- package/dist/src/memory/ewc-consolidation.d.ts +295 -0
- package/dist/src/memory/ewc-consolidation.d.ts.map +1 -0
- package/dist/src/memory/ewc-consolidation.js +190 -303
- package/dist/src/memory/ewc-consolidation.js.map +1 -1
- package/dist/src/memory/intelligence.d.ts +338 -0
- package/dist/src/memory/intelligence.d.ts.map +1 -0
- package/dist/src/memory/intelligence.js +569 -794
- package/dist/src/memory/intelligence.js.map +1 -1
- package/dist/src/memory/memory-bridge.d.ts +407 -0
- package/dist/src/memory/memory-bridge.d.ts.map +1 -0
- package/dist/src/memory/memory-bridge.js +1170 -1640
- package/dist/src/memory/memory-bridge.js.map +1 -1
- package/dist/src/memory/memory-initializer.d.ts +412 -0
- package/dist/src/memory/memory-initializer.d.ts.map +1 -0
- package/dist/src/memory/memory-initializer.js +1836 -1851
- package/dist/src/memory/memory-initializer.js.map +1 -1
- package/dist/src/memory/sona-optimizer.d.ts +227 -0
- package/dist/src/memory/sona-optimizer.d.ts.map +1 -0
- package/dist/src/memory/sona-optimizer.js +199 -329
- package/dist/src/memory/sona-optimizer.js.map +1 -1
- package/dist/src/output.d.ts +2 -2
- package/dist/src/output.d.ts.map +1 -1
- package/dist/src/output.js +242 -272
- package/dist/src/output.js.map +1 -1
- package/dist/src/parser.d.ts +51 -0
- package/dist/src/parser.d.ts.map +1 -0
- package/dist/src/parser.js +140 -187
- package/dist/src/parser.js.map +1 -1
- package/dist/src/plugins/manager.d.ts +133 -0
- package/dist/src/plugins/manager.d.ts.map +1 -0
- package/dist/src/plugins/manager.js +285 -521
- package/dist/src/plugins/manager.js.map +1 -1
- package/dist/src/plugins/store/discovery.d.ts +88 -0
- package/dist/src/plugins/store/discovery.d.ts.map +1 -0
- package/dist/src/plugins/store/discovery.js +271 -358
- package/dist/src/plugins/store/discovery.js.map +1 -1
- package/dist/src/plugins/store/index.d.ts +76 -0
- package/dist/src/plugins/store/index.d.ts.map +1 -0
- package/dist/src/plugins/store/index.js +48 -105
- package/dist/src/plugins/store/index.js.map +1 -1
- package/dist/src/plugins/store/search.d.ts +46 -0
- package/dist/src/plugins/store/search.d.ts.map +1 -0
- package/dist/src/plugins/store/search.js +69 -107
- package/dist/src/plugins/store/search.js.map +1 -1
- package/dist/src/plugins/store/types.d.ts +274 -0
- package/dist/src/plugins/store/types.d.ts.map +1 -0
- package/dist/src/plugins/tests/demo-plugin-store.js +113 -160
- package/dist/src/plugins/tests/demo-plugin-store.js.map +1 -1
- package/dist/src/plugins/tests/standalone-test.js +172 -223
- package/dist/src/plugins/tests/standalone-test.js.map +1 -1
- package/dist/src/plugins/tests/test-plugin-store.js +190 -228
- package/dist/src/plugins/tests/test-plugin-store.js.map +1 -1
- package/dist/src/production/circuit-breaker.d.ts +101 -0
- package/dist/src/production/circuit-breaker.d.ts.map +1 -0
- package/dist/src/production/circuit-breaker.js +62 -126
- package/dist/src/production/circuit-breaker.js.map +1 -1
- package/dist/src/production/error-handler.d.ts +92 -0
- package/dist/src/production/error-handler.d.ts.map +1 -0
- package/dist/src/production/error-handler.js +86 -156
- package/dist/src/production/error-handler.js.map +1 -1
- package/dist/src/production/monitoring.d.ts +161 -0
- package/dist/src/production/monitoring.d.ts.map +1 -0
- package/dist/src/production/monitoring.js +139 -220
- package/dist/src/production/monitoring.js.map +1 -1
- package/dist/src/production/rate-limiter.d.ts +80 -0
- package/dist/src/production/rate-limiter.d.ts.map +1 -0
- package/dist/src/production/rate-limiter.js +74 -93
- package/dist/src/production/rate-limiter.js.map +1 -1
- package/dist/src/production/retry.d.ts +48 -0
- package/dist/src/production/retry.d.ts.map +1 -0
- package/dist/src/production/retry.js +75 -167
- package/dist/src/production/retry.js.map +1 -1
- package/dist/src/prompt.d.ts +44 -0
- package/dist/src/prompt.d.ts.map +1 -0
- package/dist/src/prompt.js +436 -560
- package/dist/src/prompt.js.map +1 -1
- package/dist/src/runtime/headless.d.ts +60 -0
- package/dist/src/runtime/headless.d.ts.map +1 -0
- package/dist/src/runtime/headless.js +197 -286
- package/dist/src/runtime/headless.js.map +1 -1
- package/dist/src/ruvector/agent-wasm.d.ts +182 -0
- package/dist/src/ruvector/agent-wasm.d.ts.map +1 -0
- package/dist/src/ruvector/agent-wasm.js +156 -351
- package/dist/src/ruvector/agent-wasm.js.map +1 -1
- package/dist/src/ruvector/ast-analyzer.d.ts +67 -0
- package/dist/src/ruvector/ast-analyzer.d.ts.map +1 -0
- package/dist/src/ruvector/ast-analyzer.js +145 -232
- package/dist/src/ruvector/ast-analyzer.js.map +1 -1
- package/dist/src/ruvector/coverage-router.d.ts +160 -0
- package/dist/src/ruvector/coverage-router.d.ts.map +1 -0
- package/dist/src/ruvector/coverage-router.js +287 -419
- package/dist/src/ruvector/coverage-router.js.map +1 -1
- package/dist/src/ruvector/coverage-tools.js +56 -101
- package/dist/src/ruvector/coverage-tools.js.map +1 -1
- package/dist/src/ruvector/diff-classifier.d.ts +175 -0
- package/dist/src/ruvector/diff-classifier.d.ts.map +1 -0
- package/dist/src/ruvector/diff-classifier.js +324 -451
- package/dist/src/ruvector/diff-classifier.js.map +1 -1
- package/dist/src/ruvector/enhanced-model-router.d.ts +146 -0
- package/dist/src/ruvector/enhanced-model-router.d.ts.map +1 -0
- package/dist/src/ruvector/enhanced-model-router.js +260 -336
- package/dist/src/ruvector/enhanced-model-router.js.map +1 -1
- package/dist/src/ruvector/flash-attention.d.ts +195 -0
- package/dist/src/ruvector/flash-attention.d.ts.map +1 -0
- package/dist/src/ruvector/flash-attention.js +223 -254
- package/dist/src/ruvector/flash-attention.js.map +1 -1
- package/dist/src/ruvector/graph-analyzer.d.ts +187 -0
- package/dist/src/ruvector/graph-analyzer.d.ts.map +1 -0
- package/dist/src/ruvector/graph-analyzer.js +486 -680
- package/dist/src/ruvector/graph-analyzer.js.map +1 -1
- package/dist/src/ruvector/index.d.ts +40 -0
- package/dist/src/ruvector/index.d.ts.map +1 -0
- package/dist/src/ruvector/index.js +36 -106
- package/dist/src/ruvector/index.js.map +1 -1
- package/dist/src/ruvector/lora-adapter.d.ts +218 -0
- package/dist/src/ruvector/lora-adapter.d.ts.map +1 -0
- package/dist/src/ruvector/lora-adapter.js +155 -248
- package/dist/src/ruvector/lora-adapter.js.map +1 -1
- package/dist/src/ruvector/model-router.d.ts +220 -0
- package/dist/src/ruvector/model-router.d.ts.map +1 -0
- package/dist/src/ruvector/model-router.js +175 -248
- package/dist/src/ruvector/model-router.js.map +1 -1
- package/dist/src/ruvector/moe-router.d.ts +206 -0
- package/dist/src/ruvector/moe-router.d.ts.map +1 -0
- package/dist/src/ruvector/moe-router.js +228 -286
- package/dist/src/ruvector/moe-router.js.map +1 -1
- package/dist/src/ruvector/q-learning-router.d.ts +211 -0
- package/dist/src/ruvector/q-learning-router.d.ts.map +1 -0
- package/dist/src/ruvector/q-learning-router.js +257 -338
- package/dist/src/ruvector/q-learning-router.js.map +1 -1
- package/dist/src/ruvector/ruvllm-wasm.d.ts +179 -0
- package/dist/src/ruvector/ruvllm-wasm.d.ts.map +1 -0
- package/dist/src/ruvector/ruvllm-wasm.js +270 -434
- package/dist/src/ruvector/ruvllm-wasm.js.map +1 -1
- package/dist/src/ruvector/semantic-router.d.ts +77 -0
- package/dist/src/ruvector/semantic-router.d.ts.map +1 -0
- package/dist/src/ruvector/semantic-router.js +60 -67
- package/dist/src/ruvector/semantic-router.js.map +1 -1
- package/dist/src/ruvector/vector-db.d.ts +69 -0
- package/dist/src/ruvector/vector-db.d.ts.map +1 -0
- package/dist/src/ruvector/vector-db.js +119 -205
- package/dist/src/ruvector/vector-db.js.map +1 -1
- package/dist/src/services/agentic-flow-bridge.d.ts +50 -0
- package/dist/src/services/agentic-flow-bridge.d.ts.map +1 -0
- package/dist/src/services/agentic-flow-bridge.js +32 -105
- package/dist/src/services/agentic-flow-bridge.js.map +1 -1
- package/dist/src/services/claim-service.d.ts +204 -0
- package/dist/src/services/claim-service.d.ts.map +1 -0
- package/dist/src/services/claim-service.js +615 -940
- package/dist/src/services/claim-service.js.map +1 -1
- package/dist/src/services/container-worker-pool.d.ts +197 -0
- package/dist/src/services/container-worker-pool.d.ts.map +1 -0
- package/dist/src/services/container-worker-pool.js +398 -666
- package/dist/src/services/container-worker-pool.js.map +1 -1
- package/dist/src/services/headless-worker-executor.d.ts +304 -0
- package/dist/src/services/headless-worker-executor.d.ts.map +1 -0
- package/dist/src/services/headless-worker-executor.js +441 -467
- package/dist/src/services/headless-worker-executor.js.map +1 -1
- package/dist/src/services/index.d.ts +4 -4
- package/dist/src/services/index.d.ts.map +1 -1
- package/dist/src/services/index.js +4 -4
- package/dist/src/services/index.js.map +1 -1
- package/dist/src/services/registry-api.d.ts +58 -0
- package/dist/src/services/registry-api.d.ts.map +1 -0
- package/dist/src/services/registry-api.js +92 -200
- package/dist/src/services/registry-api.js.map +1 -1
- package/dist/src/services/ruvector-training.d.ts +222 -0
- package/dist/src/services/ruvector-training.d.ts.map +1 -0
- package/dist/src/services/ruvector-training.js +257 -337
- package/dist/src/services/ruvector-training.js.map +1 -1
- package/dist/src/services/worker-daemon.d.ts +228 -0
- package/dist/src/services/worker-daemon.d.ts.map +1 -0
- package/dist/src/services/worker-daemon.js +591 -849
- package/dist/src/services/worker-daemon.js.map +1 -1
- package/dist/src/services/worker-queue.d.ts +194 -0
- package/dist/src/services/worker-queue.d.ts.map +1 -0
- package/dist/src/services/worker-queue.js +331 -548
- package/dist/src/services/worker-queue.js.map +1 -1
- package/dist/src/suggest.d.ts +53 -0
- package/dist/src/suggest.d.ts.map +1 -0
- package/dist/src/suggest.js +45 -55
- package/dist/src/suggest.js.map +1 -1
- package/dist/src/transfer/anonymization/index.js +29 -37
- package/dist/src/transfer/anonymization/index.js.map +1 -1
- package/dist/src/transfer/deploy-seraphine.js +128 -155
- package/dist/src/transfer/deploy-seraphine.js.map +1 -1
- package/dist/src/transfer/export.d.ts +25 -0
- package/dist/src/transfer/export.d.ts.map +1 -0
- package/dist/src/transfer/export.js +84 -142
- package/dist/src/transfer/export.js.map +1 -1
- package/dist/src/transfer/index.d.ts +1 -1
- package/dist/src/transfer/index.d.ts.map +1 -1
- package/dist/src/transfer/index.js +0 -2
- package/dist/src/transfer/index.js.map +1 -1
- package/dist/src/transfer/ipfs/client.d.ts +109 -0
- package/dist/src/transfer/ipfs/client.d.ts.map +1 -0
- package/dist/src/transfer/ipfs/client.js +187 -337
- package/dist/src/transfer/ipfs/client.js.map +1 -1
- package/dist/src/transfer/ipfs/upload.d.ts +95 -0
- package/dist/src/transfer/ipfs/upload.d.ts.map +1 -0
- package/dist/src/transfer/ipfs/upload.js +288 -434
- package/dist/src/transfer/ipfs/upload.js.map +1 -1
- package/dist/src/transfer/models/seraphine.d.ts +72 -0
- package/dist/src/transfer/models/seraphine.d.ts.map +1 -0
- package/dist/src/transfer/models/seraphine.js +55 -55
- package/dist/src/transfer/models/seraphine.js.map +1 -1
- package/dist/src/transfer/serialization/cfp.d.ts +49 -0
- package/dist/src/transfer/serialization/cfp.d.ts.map +1 -0
- package/dist/src/transfer/serialization/cfp.js +30 -31
- package/dist/src/transfer/serialization/cfp.js.map +1 -1
- package/dist/src/transfer/storage/gcs.d.ts +82 -0
- package/dist/src/transfer/storage/gcs.d.ts.map +1 -0
- package/dist/src/transfer/storage/gcs.js +165 -232
- package/dist/src/transfer/storage/gcs.js.map +1 -1
- package/dist/src/transfer/store/discovery.d.ts +84 -0
- package/dist/src/transfer/store/discovery.d.ts.map +1 -0
- package/dist/src/transfer/store/discovery.js +239 -349
- package/dist/src/transfer/store/discovery.js.map +1 -1
- package/dist/src/transfer/store/download.d.ts +70 -0
- package/dist/src/transfer/store/download.d.ts.map +1 -0
- package/dist/src/transfer/store/download.js +243 -365
- package/dist/src/transfer/store/download.js.map +1 -1
- package/dist/src/transfer/store/index.d.ts +84 -0
- package/dist/src/transfer/store/index.d.ts.map +1 -0
- package/dist/src/transfer/store/index.js +63 -130
- package/dist/src/transfer/store/index.js.map +1 -1
- package/dist/src/transfer/store/publish.d.ts +76 -0
- package/dist/src/transfer/store/publish.d.ts.map +1 -0
- package/dist/src/transfer/store/publish.js +184 -258
- package/dist/src/transfer/store/publish.js.map +1 -1
- package/dist/src/transfer/store/registry.js +50 -72
- package/dist/src/transfer/store/registry.js.map +1 -1
- package/dist/src/transfer/store/search.d.ts +54 -0
- package/dist/src/transfer/store/search.d.ts.map +1 -0
- package/dist/src/transfer/store/search.js +64 -96
- package/dist/src/transfer/store/search.js.map +1 -1
- package/dist/src/transfer/store/tests/standalone-test.js +174 -231
- package/dist/src/transfer/store/tests/standalone-test.js.map +1 -1
- package/dist/src/transfer/test-seraphine.js +95 -130
- package/dist/src/transfer/test-seraphine.js.map +1 -1
- package/dist/src/transfer/tests/test-store.js +194 -239
- package/dist/src/transfer/tests/test-store.js.map +1 -1
- package/dist/src/transfer/types.d.ts +245 -0
- package/dist/src/transfer/types.d.ts.map +1 -0
- package/dist/src/types.d.ts +198 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +26 -55
- package/dist/src/types.js.map +1 -1
- package/dist/src/update/checker.d.ts +34 -0
- package/dist/src/update/checker.d.ts.map +1 -0
- package/dist/src/update/checker.js +106 -183
- package/dist/src/update/checker.js.map +1 -1
- package/dist/src/update/executor.d.ts +32 -0
- package/dist/src/update/executor.d.ts.map +1 -0
- package/dist/src/update/executor.js +135 -198
- package/dist/src/update/executor.js.map +1 -1
- package/dist/src/update/index.d.ts +33 -0
- package/dist/src/update/index.d.ts.map +1 -0
- package/dist/src/update/index.js +38 -85
- package/dist/src/update/index.js.map +1 -1
- package/dist/src/update/rate-limiter.d.ts +20 -0
- package/dist/src/update/rate-limiter.d.ts.map +1 -0
- package/dist/src/update/rate-limiter.js +19 -31
- package/dist/src/update/rate-limiter.js.map +1 -1
- package/dist/src/update/validator.d.ts +17 -0
- package/dist/src/update/validator.d.ts.map +1 -0
- package/dist/src/update/validator.js +38 -64
- package/dist/src/update/validator.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -4,302 +4,235 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Created with ❤️ by ruv.io
|
|
6
6
|
*/
|
|
7
|
-
var __assign = (this && this.__assign) || function () {
|
|
8
|
-
__assign = Object.assign || function(t) {
|
|
9
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
10
|
-
s = arguments[i];
|
|
11
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
12
|
-
t[p] = s[p];
|
|
13
|
-
}
|
|
14
|
-
return t;
|
|
15
|
-
};
|
|
16
|
-
return __assign.apply(this, arguments);
|
|
17
|
-
};
|
|
18
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
19
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
20
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
21
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
22
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
23
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
24
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
28
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
29
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
30
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
31
|
-
function step(op) {
|
|
32
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
33
|
-
while (_) try {
|
|
34
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
35
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
36
|
-
switch (op[0]) {
|
|
37
|
-
case 0: case 1: t = op; break;
|
|
38
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
39
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
40
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
41
|
-
default:
|
|
42
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
43
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
44
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
45
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
46
|
-
if (t[2]) _.ops.pop();
|
|
47
|
-
_.trys.pop(); continue;
|
|
48
|
-
}
|
|
49
|
-
op = body.call(thisArg, _);
|
|
50
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
51
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
7
|
import { output } from '../output.js';
|
|
55
8
|
// Scan subcommand
|
|
56
|
-
|
|
9
|
+
const scanCommand = {
|
|
57
10
|
name: 'scan',
|
|
58
11
|
description: 'Run security scan on target (code, dependencies, containers)',
|
|
59
12
|
options: [
|
|
60
|
-
{ name: 'target', short: 't', type: 'string', description: 'Target path or URL to scan',
|
|
61
|
-
{ name: 'depth', short: 'd', type: 'string', description: 'Scan depth: quick, standard, deep',
|
|
62
|
-
{ name: 'type', type: 'string', description: 'Scan type: code, deps, container, all',
|
|
63
|
-
{ name: 'output', short: 'o', type: 'string', description: 'Output format: text, json, sarif',
|
|
13
|
+
{ name: 'target', short: 't', type: 'string', description: 'Target path or URL to scan', default: '.' },
|
|
14
|
+
{ name: 'depth', short: 'd', type: 'string', description: 'Scan depth: quick, standard, deep', default: 'standard' },
|
|
15
|
+
{ name: 'type', type: 'string', description: 'Scan type: code, deps, container, all', default: 'all' },
|
|
16
|
+
{ name: 'output', short: 'o', type: 'string', description: 'Output format: text, json, sarif', default: 'text' },
|
|
64
17
|
{ name: 'fix', short: 'f', type: 'boolean', description: 'Auto-fix vulnerabilities where possible' },
|
|
65
18
|
],
|
|
66
19
|
examples: [
|
|
67
20
|
{ command: 'claude-flow security scan -t ./src', description: 'Scan source directory' },
|
|
68
21
|
{ command: 'claude-flow security scan --depth deep --fix', description: 'Deep scan with auto-fix' },
|
|
69
22
|
],
|
|
70
|
-
action:
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
case 4:
|
|
98
|
-
execSync = (_d.sent()).execSync;
|
|
99
|
-
// Phase 1: npm audit for dependency vulnerabilities
|
|
100
|
-
if (scanType === 'all' || scanType === 'deps') {
|
|
101
|
-
spinner.setText('Checking dependencies with npm audit...');
|
|
23
|
+
action: async (ctx) => {
|
|
24
|
+
const target = ctx.flags.target || '.';
|
|
25
|
+
const depth = ctx.flags.depth || 'standard';
|
|
26
|
+
const scanType = ctx.flags.type || 'all';
|
|
27
|
+
const fix = ctx.flags.fix;
|
|
28
|
+
output.writeln();
|
|
29
|
+
output.writeln(output.bold('Security Scan'));
|
|
30
|
+
output.writeln(output.dim('─'.repeat(50)));
|
|
31
|
+
const spinner = output.createSpinner({ text: `Scanning ${target}...`, spinner: 'dots' });
|
|
32
|
+
spinner.start();
|
|
33
|
+
const findings = [];
|
|
34
|
+
let criticalCount = 0, highCount = 0, mediumCount = 0, lowCount = 0;
|
|
35
|
+
try {
|
|
36
|
+
const fs = await import('fs');
|
|
37
|
+
const path = await import('path');
|
|
38
|
+
const { execSync } = await import('child_process');
|
|
39
|
+
// Phase 1: npm audit for dependency vulnerabilities
|
|
40
|
+
if (scanType === 'all' || scanType === 'deps') {
|
|
41
|
+
spinner.setText('Checking dependencies with npm audit...');
|
|
42
|
+
try {
|
|
43
|
+
const packageJsonPath = path.resolve(target, 'package.json');
|
|
44
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
45
|
+
const auditResult = execSync('npm audit --json 2>/dev/null || true', {
|
|
46
|
+
cwd: path.resolve(target),
|
|
47
|
+
encoding: 'utf-8',
|
|
48
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
49
|
+
});
|
|
102
50
|
try {
|
|
103
|
-
|
|
104
|
-
if (
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if (
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
lowCount++;
|
|
125
|
-
findings.push({
|
|
126
|
-
severity: sev === 'critical' ? output.error('CRITICAL') :
|
|
127
|
-
sev === 'high' ? output.warning('HIGH') :
|
|
128
|
-
sev === 'moderate' || sev === 'medium' ? output.warning('MEDIUM') : output.info('LOW'),
|
|
129
|
-
type: 'Dependency CVE',
|
|
130
|
-
location: "package.json:" + pkg,
|
|
131
|
-
description: title.substring(0, 35)
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
}
|
|
51
|
+
const audit = JSON.parse(auditResult);
|
|
52
|
+
if (audit.vulnerabilities) {
|
|
53
|
+
for (const [pkg, vuln] of Object.entries(audit.vulnerabilities)) {
|
|
54
|
+
const sev = vuln.severity || 'low';
|
|
55
|
+
const title = Array.isArray(vuln.via) && vuln.via[0]?.title ? vuln.via[0].title : 'Vulnerability';
|
|
56
|
+
if (sev === 'critical')
|
|
57
|
+
criticalCount++;
|
|
58
|
+
else if (sev === 'high')
|
|
59
|
+
highCount++;
|
|
60
|
+
else if (sev === 'moderate' || sev === 'medium')
|
|
61
|
+
mediumCount++;
|
|
62
|
+
else
|
|
63
|
+
lowCount++;
|
|
64
|
+
findings.push({
|
|
65
|
+
severity: sev === 'critical' ? output.error('CRITICAL') :
|
|
66
|
+
sev === 'high' ? output.warning('HIGH') :
|
|
67
|
+
sev === 'moderate' || sev === 'medium' ? output.warning('MEDIUM') : output.info('LOW'),
|
|
68
|
+
type: 'Dependency CVE',
|
|
69
|
+
location: `package.json:${pkg}`,
|
|
70
|
+
description: title.substring(0, 35),
|
|
71
|
+
});
|
|
135
72
|
}
|
|
136
|
-
catch ( /* JSON parse failed, no vulns */_e) { /* JSON parse failed, no vulns */ }
|
|
137
73
|
}
|
|
138
74
|
}
|
|
139
|
-
catch
|
|
75
|
+
catch { /* JSON parse failed, no vulns */ }
|
|
140
76
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
77
|
+
}
|
|
78
|
+
catch { /* npm audit failed */ }
|
|
79
|
+
}
|
|
80
|
+
// Phase 2: Scan for hardcoded secrets
|
|
81
|
+
if (scanType === 'all' || scanType === 'code') {
|
|
82
|
+
spinner.setText('Scanning for hardcoded secrets...');
|
|
83
|
+
const secretPatterns = [
|
|
84
|
+
{ pattern: /['"](?:sk-|sk_live_|sk_test_)[a-zA-Z0-9]{20,}['"]/g, type: 'API Key (Stripe/OpenAI)' },
|
|
85
|
+
{ pattern: /['"]AKIA[A-Z0-9]{16}['"]/g, type: 'AWS Access Key' },
|
|
86
|
+
{ pattern: /['"]ghp_[a-zA-Z0-9]{36}['"]/g, type: 'GitHub Token' },
|
|
87
|
+
{ pattern: /['"]xox[baprs]-[a-zA-Z0-9-]+['"]/g, type: 'Slack Token' },
|
|
88
|
+
{ pattern: /password\s*[:=]\s*['"][^'"]{8,}['"]/gi, type: 'Hardcoded Password' },
|
|
89
|
+
];
|
|
90
|
+
const scanDir = (dir, depthLimit) => {
|
|
91
|
+
if (depthLimit <= 0)
|
|
92
|
+
return;
|
|
93
|
+
try {
|
|
94
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
95
|
+
for (const entry of entries) {
|
|
96
|
+
if (entry.name.startsWith('.') || entry.name === 'node_modules' || entry.name === 'dist')
|
|
97
|
+
continue;
|
|
98
|
+
const fullPath = path.join(dir, entry.name);
|
|
99
|
+
if (entry.isDirectory()) {
|
|
100
|
+
scanDir(fullPath, depthLimit - 1);
|
|
101
|
+
}
|
|
102
|
+
else if (entry.isFile() && /\.(ts|js|json|env|yml|yaml)$/.test(entry.name) && !entry.name.endsWith('.d.ts')) {
|
|
103
|
+
try {
|
|
104
|
+
const content = fs.readFileSync(fullPath, 'utf-8');
|
|
105
|
+
const lines = content.split('\n');
|
|
106
|
+
for (let i = 0; i < lines.length; i++) {
|
|
107
|
+
for (const { pattern, type } of secretPatterns) {
|
|
108
|
+
if (pattern.test(lines[i])) {
|
|
109
|
+
highCount++;
|
|
110
|
+
findings.push({
|
|
111
|
+
severity: output.warning('HIGH'),
|
|
112
|
+
type: 'Hardcoded Secret',
|
|
113
|
+
location: `${path.relative(target, fullPath)}:${i + 1}`,
|
|
114
|
+
description: type,
|
|
115
|
+
});
|
|
116
|
+
pattern.lastIndex = 0;
|
|
182
117
|
}
|
|
183
118
|
}
|
|
184
|
-
catch ( /* file read error */_c) { /* file read error */ }
|
|
185
119
|
}
|
|
186
120
|
}
|
|
121
|
+
catch { /* file read error */ }
|
|
187
122
|
}
|
|
188
|
-
|
|
189
|
-
};
|
|
190
|
-
scanDepth = depth === 'deep' ? 10 : depth === 'standard' ? 5 : 3;
|
|
191
|
-
scanDir_1(path_1.resolve(target), scanDepth);
|
|
123
|
+
}
|
|
192
124
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
}
|
|
125
|
+
catch { /* dir read error */ }
|
|
126
|
+
};
|
|
127
|
+
const scanDepth = depth === 'deep' ? 10 : depth === 'standard' ? 5 : 3;
|
|
128
|
+
scanDir(path.resolve(target), scanDepth);
|
|
129
|
+
}
|
|
130
|
+
// Phase 3: Check for common security issues in code
|
|
131
|
+
if ((scanType === 'all' || scanType === 'code') && depth !== 'quick') {
|
|
132
|
+
spinner.setText('Analyzing code patterns...');
|
|
133
|
+
const codePatterns = [
|
|
134
|
+
{ pattern: /eval\s*\(/g, type: 'Eval Usage', severity: 'medium', desc: 'eval() can execute arbitrary code' },
|
|
135
|
+
{ pattern: /innerHTML\s*=/g, type: 'innerHTML', severity: 'medium', desc: 'XSS risk with innerHTML' },
|
|
136
|
+
{ pattern: /dangerouslySetInnerHTML/g, type: 'React XSS', severity: 'medium', desc: 'React XSS risk' },
|
|
137
|
+
{ pattern: /child_process.*exec[^S]/g, type: 'Command Injection', severity: 'high', desc: 'Possible command injection' },
|
|
138
|
+
{ pattern: /\$\{.*\}.*sql|sql.*\$\{/gi, type: 'SQL Injection', severity: 'high', desc: 'Possible SQL injection' },
|
|
139
|
+
];
|
|
140
|
+
const scanCodeDir = (dir, depthLimit) => {
|
|
141
|
+
if (depthLimit <= 0)
|
|
142
|
+
return;
|
|
143
|
+
try {
|
|
144
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
145
|
+
for (const entry of entries) {
|
|
146
|
+
if (entry.name.startsWith('.') || entry.name === 'node_modules' || entry.name === 'dist')
|
|
147
|
+
continue;
|
|
148
|
+
const fullPath = path.join(dir, entry.name);
|
|
149
|
+
if (entry.isDirectory()) {
|
|
150
|
+
scanCodeDir(fullPath, depthLimit - 1);
|
|
151
|
+
}
|
|
152
|
+
else if (entry.isFile() && /\.(ts|js|tsx|jsx)$/.test(entry.name) && !entry.name.endsWith('.d.ts')) {
|
|
153
|
+
try {
|
|
154
|
+
const content = fs.readFileSync(fullPath, 'utf-8');
|
|
155
|
+
const lines = content.split('\n');
|
|
156
|
+
for (let i = 0; i < lines.length; i++) {
|
|
157
|
+
for (const { pattern, type, severity, desc } of codePatterns) {
|
|
158
|
+
if (pattern.test(lines[i])) {
|
|
159
|
+
if (severity === 'high')
|
|
160
|
+
highCount++;
|
|
161
|
+
else
|
|
162
|
+
mediumCount++;
|
|
163
|
+
findings.push({
|
|
164
|
+
severity: severity === 'high' ? output.warning('HIGH') : output.warning('MEDIUM'),
|
|
165
|
+
type,
|
|
166
|
+
location: `${path.relative(target, fullPath)}:${i + 1}`,
|
|
167
|
+
description: desc,
|
|
168
|
+
});
|
|
169
|
+
pattern.lastIndex = 0;
|
|
237
170
|
}
|
|
238
171
|
}
|
|
239
|
-
catch ( /* file read error */_c) { /* file read error */ }
|
|
240
172
|
}
|
|
241
173
|
}
|
|
174
|
+
catch { /* file read error */ }
|
|
242
175
|
}
|
|
243
|
-
catch ( /* dir read error */_d) { /* dir read error */ }
|
|
244
|
-
};
|
|
245
|
-
scanDepth = depth === 'deep' ? 10 : 5;
|
|
246
|
-
scanCodeDir_1(path_1.resolve(target), scanDepth);
|
|
247
|
-
}
|
|
248
|
-
spinner.succeed('Scan complete');
|
|
249
|
-
// Display results
|
|
250
|
-
output.writeln();
|
|
251
|
-
if (findings.length > 0) {
|
|
252
|
-
output.printTable({
|
|
253
|
-
columns: [
|
|
254
|
-
{ key: 'severity', header: 'Severity', width: 12 },
|
|
255
|
-
{ key: 'type', header: 'Type', width: 18 },
|
|
256
|
-
{ key: 'location', header: 'Location', width: 25 },
|
|
257
|
-
{ key: 'description', header: 'Description', width: 35 },
|
|
258
|
-
],
|
|
259
|
-
data: findings.slice(0, 20)
|
|
260
|
-
});
|
|
261
|
-
if (findings.length > 20) {
|
|
262
|
-
output.writeln(output.dim("... and " + (findings.length - 20) + " more issues"));
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
else {
|
|
266
|
-
output.writeln(output.success('No security issues found!'));
|
|
267
|
-
}
|
|
268
|
-
output.writeln();
|
|
269
|
-
output.printBox([
|
|
270
|
-
"Target: " + target,
|
|
271
|
-
"Depth: " + depth,
|
|
272
|
-
"Type: " + scanType,
|
|
273
|
-
"",
|
|
274
|
-
"Critical: " + criticalCount + " High: " + highCount + " Medium: " + mediumCount + " Low: " + lowCount,
|
|
275
|
-
"Total Issues: " + findings.length,
|
|
276
|
-
].join('\n'), 'Scan Summary');
|
|
277
|
-
// Auto-fix if requested
|
|
278
|
-
if (fix && criticalCount + highCount > 0) {
|
|
279
|
-
output.writeln();
|
|
280
|
-
fixSpinner = output.createSpinner({ text: 'Attempting to fix vulnerabilities...', spinner: 'dots' });
|
|
281
|
-
fixSpinner.start();
|
|
282
|
-
try {
|
|
283
|
-
execSync('npm audit fix 2>/dev/null || true', { cwd: path_1.resolve(target), encoding: 'utf-8' });
|
|
284
|
-
fixSpinner.succeed('Applied available fixes (run scan again to verify)');
|
|
285
|
-
}
|
|
286
|
-
catch (_g) {
|
|
287
|
-
fixSpinner.fail('Some fixes could not be applied automatically');
|
|
288
176
|
}
|
|
289
177
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
output.printError("Error: " + error_1);
|
|
295
|
-
return [2 /*return*/, { success: false }];
|
|
296
|
-
case 6: return [2 /*return*/];
|
|
178
|
+
catch { /* dir read error */ }
|
|
179
|
+
};
|
|
180
|
+
const scanDepth = depth === 'deep' ? 10 : 5;
|
|
181
|
+
scanCodeDir(path.resolve(target), scanDepth);
|
|
297
182
|
}
|
|
298
|
-
|
|
299
|
-
|
|
183
|
+
spinner.succeed('Scan complete');
|
|
184
|
+
// Display results
|
|
185
|
+
output.writeln();
|
|
186
|
+
if (findings.length > 0) {
|
|
187
|
+
output.printTable({
|
|
188
|
+
columns: [
|
|
189
|
+
{ key: 'severity', header: 'Severity', width: 12 },
|
|
190
|
+
{ key: 'type', header: 'Type', width: 18 },
|
|
191
|
+
{ key: 'location', header: 'Location', width: 25 },
|
|
192
|
+
{ key: 'description', header: 'Description', width: 35 },
|
|
193
|
+
],
|
|
194
|
+
data: findings.slice(0, 20), // Show first 20
|
|
195
|
+
});
|
|
196
|
+
if (findings.length > 20) {
|
|
197
|
+
output.writeln(output.dim(`... and ${findings.length - 20} more issues`));
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
output.writeln(output.success('No security issues found!'));
|
|
202
|
+
}
|
|
203
|
+
output.writeln();
|
|
204
|
+
output.printBox([
|
|
205
|
+
`Target: ${target}`,
|
|
206
|
+
`Depth: ${depth}`,
|
|
207
|
+
`Type: ${scanType}`,
|
|
208
|
+
``,
|
|
209
|
+
`Critical: ${criticalCount} High: ${highCount} Medium: ${mediumCount} Low: ${lowCount}`,
|
|
210
|
+
`Total Issues: ${findings.length}`,
|
|
211
|
+
].join('\n'), 'Scan Summary');
|
|
212
|
+
// Auto-fix if requested
|
|
213
|
+
if (fix && criticalCount + highCount > 0) {
|
|
214
|
+
output.writeln();
|
|
215
|
+
const fixSpinner = output.createSpinner({ text: 'Attempting to fix vulnerabilities...', spinner: 'dots' });
|
|
216
|
+
fixSpinner.start();
|
|
217
|
+
try {
|
|
218
|
+
execSync('npm audit fix 2>/dev/null || true', { cwd: path.resolve(target), encoding: 'utf-8' });
|
|
219
|
+
fixSpinner.succeed('Applied available fixes (run scan again to verify)');
|
|
220
|
+
}
|
|
221
|
+
catch {
|
|
222
|
+
fixSpinner.fail('Some fixes could not be applied automatically');
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return { success: findings.length === 0 || (criticalCount === 0 && highCount === 0) };
|
|
226
|
+
}
|
|
227
|
+
catch (error) {
|
|
228
|
+
spinner.fail('Scan failed');
|
|
229
|
+
output.printError(`Error: ${error}`);
|
|
230
|
+
return { success: false };
|
|
231
|
+
}
|
|
232
|
+
},
|
|
300
233
|
};
|
|
301
234
|
// CVE subcommand
|
|
302
|
-
|
|
235
|
+
const cveCommand = {
|
|
303
236
|
name: 'cve',
|
|
304
237
|
description: 'Check and manage CVE vulnerabilities',
|
|
305
238
|
options: [
|
|
@@ -311,389 +244,335 @@ var cveCommand = {
|
|
|
311
244
|
{ command: 'claude-flow security cve --list', description: 'List all CVEs' },
|
|
312
245
|
{ command: 'claude-flow security cve -c CVE-2024-1234', description: 'Check specific CVE' },
|
|
313
246
|
],
|
|
314
|
-
action:
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
247
|
+
action: async (ctx) => {
|
|
248
|
+
const checkCve = ctx.flags.check;
|
|
249
|
+
output.writeln();
|
|
250
|
+
output.writeln(output.bold('CVE Database'));
|
|
251
|
+
output.writeln(output.dim('─'.repeat(50)));
|
|
252
|
+
if (checkCve) {
|
|
253
|
+
output.printBox([
|
|
254
|
+
`CVE ID: ${checkCve}`,
|
|
255
|
+
`Severity: CRITICAL (9.8)`,
|
|
256
|
+
`Status: Active`,
|
|
257
|
+
``,
|
|
258
|
+
`Description: Remote code execution vulnerability`,
|
|
259
|
+
`Affected: lodash < 4.17.21`,
|
|
260
|
+
`Fix: Upgrade to lodash >= 4.17.21`,
|
|
261
|
+
``,
|
|
262
|
+
`References:`,
|
|
263
|
+
` - https://nvd.nist.gov/vuln/detail/${checkCve}`,
|
|
264
|
+
` - https://github.com/advisories`,
|
|
265
|
+
].join('\n'), 'CVE Details');
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
output.writeln(output.warning('⚠ No real CVE database configured. Showing example data.'));
|
|
269
|
+
output.writeln(output.dim('Run "npm audit" or "claude-flow security scan" for real vulnerability detection.'));
|
|
318
270
|
output.writeln();
|
|
319
|
-
output.
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
}
|
|
336
|
-
else {
|
|
337
|
-
output.writeln(output.warning('⚠ No real CVE database configured. Showing example data.'));
|
|
338
|
-
output.writeln(output.dim('Run "npm audit" or "claude-flow security scan" for real vulnerability detection.'));
|
|
339
|
-
output.writeln();
|
|
340
|
-
output.printTable({
|
|
341
|
-
columns: [
|
|
342
|
-
{ key: 'id', header: 'CVE ID (Example)', width: 22 },
|
|
343
|
-
{ key: 'severity', header: 'Severity', width: 12 },
|
|
344
|
-
{ key: 'package', header: 'Package', width: 20 },
|
|
345
|
-
{ key: 'status', header: 'Status', width: 15 },
|
|
346
|
-
],
|
|
347
|
-
data: [
|
|
348
|
-
{ id: 'CVE-YYYY-NNNN', severity: output.error('CRITICAL'), package: 'example-pkg@1.0.0', status: output.warning('Example') },
|
|
349
|
-
{ id: 'CVE-YYYY-NNNN', severity: output.warning('HIGH'), package: 'example-pkg@2.0.0', status: output.success('Example') },
|
|
350
|
-
{ id: 'CVE-YYYY-NNNN', severity: output.info('MEDIUM'), package: 'example-pkg@3.0.0', status: output.success('Example') },
|
|
351
|
-
]
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
|
-
return [2 /*return*/, { success: true }];
|
|
355
|
-
});
|
|
356
|
-
}); }
|
|
271
|
+
output.printTable({
|
|
272
|
+
columns: [
|
|
273
|
+
{ key: 'id', header: 'CVE ID (Example)', width: 22 },
|
|
274
|
+
{ key: 'severity', header: 'Severity', width: 12 },
|
|
275
|
+
{ key: 'package', header: 'Package', width: 20 },
|
|
276
|
+
{ key: 'status', header: 'Status', width: 15 },
|
|
277
|
+
],
|
|
278
|
+
data: [
|
|
279
|
+
{ id: 'CVE-YYYY-NNNN', severity: output.error('CRITICAL'), package: 'example-pkg@1.0.0', status: output.warning('Example') },
|
|
280
|
+
{ id: 'CVE-YYYY-NNNN', severity: output.warning('HIGH'), package: 'example-pkg@2.0.0', status: output.success('Example') },
|
|
281
|
+
{ id: 'CVE-YYYY-NNNN', severity: output.info('MEDIUM'), package: 'example-pkg@3.0.0', status: output.success('Example') },
|
|
282
|
+
],
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
return { success: true };
|
|
286
|
+
},
|
|
357
287
|
};
|
|
358
288
|
// Threats subcommand
|
|
359
|
-
|
|
289
|
+
const threatsCommand = {
|
|
360
290
|
name: 'threats',
|
|
361
291
|
description: 'Threat modeling and analysis',
|
|
362
292
|
options: [
|
|
363
|
-
{ name: 'model', short: 'm', type: 'string', description: 'Threat model: stride, dread, pasta',
|
|
364
|
-
{ name: 'scope', short: 's', type: 'string', description: 'Analysis scope',
|
|
293
|
+
{ name: 'model', short: 'm', type: 'string', description: 'Threat model: stride, dread, pasta', default: 'stride' },
|
|
294
|
+
{ name: 'scope', short: 's', type: 'string', description: 'Analysis scope', default: '.' },
|
|
365
295
|
{ name: 'export', short: 'e', type: 'string', description: 'Export format: json, md, html' },
|
|
366
296
|
],
|
|
367
297
|
examples: [
|
|
368
298
|
{ command: 'claude-flow security threats --model stride', description: 'Run STRIDE analysis' },
|
|
369
299
|
{ command: 'claude-flow security threats -e md', description: 'Export as markdown' },
|
|
370
300
|
],
|
|
371
|
-
action:
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
{ category: 'Elevation', threat: 'Privilege escalation', risk: output.error('High'), mitigation: 'RBAC implementation' },
|
|
392
|
-
]
|
|
393
|
-
});
|
|
394
|
-
return [2 /*return*/, { success: true }];
|
|
301
|
+
action: async (ctx) => {
|
|
302
|
+
const model = ctx.flags.model || 'stride';
|
|
303
|
+
output.writeln();
|
|
304
|
+
output.writeln(output.bold(`Threat Model: ${model.toUpperCase()}`));
|
|
305
|
+
output.writeln(output.dim('─'.repeat(50)));
|
|
306
|
+
output.printTable({
|
|
307
|
+
columns: [
|
|
308
|
+
{ key: 'category', header: 'Category', width: 20 },
|
|
309
|
+
{ key: 'threat', header: 'Threat', width: 30 },
|
|
310
|
+
{ key: 'risk', header: 'Risk', width: 10 },
|
|
311
|
+
{ key: 'mitigation', header: 'Mitigation', width: 30 },
|
|
312
|
+
],
|
|
313
|
+
data: [
|
|
314
|
+
{ category: 'Spoofing', threat: 'API key theft', risk: output.error('High'), mitigation: 'Use secure key storage' },
|
|
315
|
+
{ category: 'Tampering', threat: 'Data manipulation', risk: output.warning('Medium'), mitigation: 'Input validation' },
|
|
316
|
+
{ category: 'Repudiation', threat: 'Action denial', risk: output.info('Low'), mitigation: 'Audit logging' },
|
|
317
|
+
{ category: 'Info Disclosure', threat: 'Data leakage', risk: output.error('High'), mitigation: 'Encryption at rest' },
|
|
318
|
+
{ category: 'DoS', threat: 'Resource exhaustion', risk: output.warning('Medium'), mitigation: 'Rate limiting' },
|
|
319
|
+
{ category: 'Elevation', threat: 'Privilege escalation', risk: output.error('High'), mitigation: 'RBAC implementation' },
|
|
320
|
+
],
|
|
395
321
|
});
|
|
396
|
-
|
|
322
|
+
return { success: true };
|
|
323
|
+
},
|
|
397
324
|
};
|
|
398
325
|
// Audit subcommand
|
|
399
|
-
|
|
326
|
+
const auditCommand = {
|
|
400
327
|
name: 'audit',
|
|
401
328
|
description: 'Security audit logging and compliance',
|
|
402
329
|
options: [
|
|
403
|
-
{ name: 'action', short: 'a', type: 'string', description: 'Action: log, list, export, clear',
|
|
404
|
-
{ name: 'limit', short: 'l', type: 'number', description: 'Number of entries to show',
|
|
330
|
+
{ name: 'action', short: 'a', type: 'string', description: 'Action: log, list, export, clear', default: 'list' },
|
|
331
|
+
{ name: 'limit', short: 'l', type: 'number', description: 'Number of entries to show', default: '20' },
|
|
405
332
|
{ name: 'filter', short: 'f', type: 'string', description: 'Filter by event type' },
|
|
406
333
|
],
|
|
407
334
|
examples: [
|
|
408
335
|
{ command: 'claude-flow security audit --action list', description: 'List audit logs' },
|
|
409
336
|
{ command: 'claude-flow security audit -a export', description: 'Export audit trail' },
|
|
410
337
|
],
|
|
411
|
-
action:
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
ts = stat.mtime.toISOString().replace('T', ' ').substring(0, 19);
|
|
437
|
-
auditEntries.push({
|
|
438
|
-
timestamp: ts,
|
|
439
|
-
event: file.includes('session') ? 'SESSION_UPDATE' :
|
|
440
|
-
file.includes('swarm') ? 'SWARM_ACTIVITY' :
|
|
441
|
-
file.includes('memory') ? 'MEMORY_WRITE' : 'CONFIG_CHANGE',
|
|
442
|
-
user: 'system',
|
|
443
|
-
status: output.success('Success')
|
|
444
|
-
});
|
|
445
|
-
}
|
|
446
|
-
catch ( /* skip */_d) { /* skip */ }
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
catch ( /* ignore */_e) { /* ignore */ }
|
|
450
|
-
}
|
|
451
|
-
now = new Date().toISOString().replace('T', ' ').substring(0, 19);
|
|
452
|
-
auditEntries.push({ timestamp: now, event: 'AUDIT_RUN', user: 'cli', status: output.success('Success') });
|
|
453
|
-
// Sort by timestamp desc
|
|
454
|
-
auditEntries.sort(function (a, b) { return b.timestamp.localeCompare(a.timestamp); });
|
|
455
|
-
if (auditEntries.length === 0) {
|
|
456
|
-
output.writeln(output.dim('No audit events found. Initialize a project first: claude-flow init'));
|
|
457
|
-
}
|
|
458
|
-
else {
|
|
459
|
-
output.printTable({
|
|
460
|
-
columns: [
|
|
461
|
-
{ key: 'timestamp', header: 'Timestamp', width: 22 },
|
|
462
|
-
{ key: 'event', header: 'Event', width: 20 },
|
|
463
|
-
{ key: 'user', header: 'User', width: 15 },
|
|
464
|
-
{ key: 'status', header: 'Status', width: 12 },
|
|
465
|
-
],
|
|
466
|
-
data: auditEntries.slice(0, parseInt(ctx.flags.limit || '20', 10))
|
|
338
|
+
action: async (ctx) => {
|
|
339
|
+
const action = ctx.flags.action || 'list';
|
|
340
|
+
output.writeln();
|
|
341
|
+
output.writeln(output.bold('Security Audit Log'));
|
|
342
|
+
output.writeln(output.dim('─'.repeat(60)));
|
|
343
|
+
// Generate real audit entries from .swarm/ state and session history
|
|
344
|
+
const { existsSync, readFileSync, readdirSync, statSync } = await import('fs');
|
|
345
|
+
const { join } = await import('path');
|
|
346
|
+
const auditEntries = [];
|
|
347
|
+
const swarmDir = join(process.cwd(), '.swarm');
|
|
348
|
+
// Check session files for real audit events
|
|
349
|
+
if (existsSync(swarmDir)) {
|
|
350
|
+
try {
|
|
351
|
+
const files = readdirSync(swarmDir).filter(f => f.endsWith('.json'));
|
|
352
|
+
for (const file of files.slice(-10)) {
|
|
353
|
+
try {
|
|
354
|
+
const stat = statSync(join(swarmDir, file));
|
|
355
|
+
const ts = stat.mtime.toISOString().replace('T', ' ').substring(0, 19);
|
|
356
|
+
auditEntries.push({
|
|
357
|
+
timestamp: ts,
|
|
358
|
+
event: file.includes('session') ? 'SESSION_UPDATE' :
|
|
359
|
+
file.includes('swarm') ? 'SWARM_ACTIVITY' :
|
|
360
|
+
file.includes('memory') ? 'MEMORY_WRITE' : 'CONFIG_CHANGE',
|
|
361
|
+
user: 'system',
|
|
362
|
+
status: output.success('Success')
|
|
467
363
|
});
|
|
468
364
|
}
|
|
469
|
-
|
|
365
|
+
catch { /* skip */ }
|
|
366
|
+
}
|
|
470
367
|
}
|
|
471
|
-
|
|
472
|
-
|
|
368
|
+
catch { /* ignore */ }
|
|
369
|
+
}
|
|
370
|
+
// Add current session entry
|
|
371
|
+
const now = new Date().toISOString().replace('T', ' ').substring(0, 19);
|
|
372
|
+
auditEntries.push({ timestamp: now, event: 'AUDIT_RUN', user: 'cli', status: output.success('Success') });
|
|
373
|
+
// Sort by timestamp desc
|
|
374
|
+
auditEntries.sort((a, b) => b.timestamp.localeCompare(a.timestamp));
|
|
375
|
+
if (auditEntries.length === 0) {
|
|
376
|
+
output.writeln(output.dim('No audit events found. Initialize a project first: claude-flow init'));
|
|
377
|
+
}
|
|
378
|
+
else {
|
|
379
|
+
output.printTable({
|
|
380
|
+
columns: [
|
|
381
|
+
{ key: 'timestamp', header: 'Timestamp', width: 22 },
|
|
382
|
+
{ key: 'event', header: 'Event', width: 20 },
|
|
383
|
+
{ key: 'user', header: 'User', width: 15 },
|
|
384
|
+
{ key: 'status', header: 'Status', width: 12 },
|
|
385
|
+
],
|
|
386
|
+
data: auditEntries.slice(0, parseInt(ctx.flags.limit || '20', 10)),
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
return { success: true };
|
|
390
|
+
},
|
|
473
391
|
};
|
|
474
392
|
// Secrets subcommand
|
|
475
|
-
|
|
393
|
+
const secretsCommand = {
|
|
476
394
|
name: 'secrets',
|
|
477
395
|
description: 'Detect and manage secrets in codebase',
|
|
478
396
|
options: [
|
|
479
|
-
{ name: 'action', short: 'a', type: 'string', description: 'Action: scan, list, rotate',
|
|
480
|
-
{ name: 'path', short: 'p', type: 'string', description: 'Path to scan',
|
|
397
|
+
{ name: 'action', short: 'a', type: 'string', description: 'Action: scan, list, rotate', default: 'scan' },
|
|
398
|
+
{ name: 'path', short: 'p', type: 'string', description: 'Path to scan', default: '.' },
|
|
481
399
|
{ name: 'ignore', short: 'i', type: 'string', description: 'Patterns to ignore' },
|
|
482
400
|
],
|
|
483
401
|
examples: [
|
|
484
402
|
{ command: 'claude-flow security secrets --action scan', description: 'Scan for secrets' },
|
|
485
403
|
{ command: 'claude-flow security secrets -a rotate', description: 'Rotate compromised secrets' },
|
|
486
404
|
],
|
|
487
|
-
action:
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
data: [
|
|
514
|
-
{ type: 'AWS Access Key', location: 'example/config.ts:15', risk: output.error('Critical'), action: 'Rotate immediately' },
|
|
515
|
-
{ type: 'GitHub Token', location: 'example/.env:8', risk: output.warning('High'), action: 'Remove from repo' },
|
|
516
|
-
{ type: 'JWT Secret', location: 'example/auth.ts:42', risk: output.warning('High'), action: 'Use env variable' },
|
|
517
|
-
{ type: 'DB Password', location: 'example/compose.yml:23', risk: output.warning('Medium'), action: 'Use secrets mgmt' },
|
|
518
|
-
]
|
|
519
|
-
});
|
|
520
|
-
return [2 /*return*/, { success: true }];
|
|
521
|
-
}
|
|
405
|
+
action: async (ctx) => {
|
|
406
|
+
const path = ctx.flags.path || '.';
|
|
407
|
+
output.writeln();
|
|
408
|
+
output.writeln(output.bold('Secret Detection'));
|
|
409
|
+
output.writeln(output.dim('─'.repeat(50)));
|
|
410
|
+
const spinner = output.createSpinner({ text: 'Scanning for secrets...', spinner: 'dots' });
|
|
411
|
+
spinner.start();
|
|
412
|
+
await new Promise(r => setTimeout(r, 800));
|
|
413
|
+
spinner.succeed('Scan complete');
|
|
414
|
+
output.writeln();
|
|
415
|
+
output.writeln(output.warning('⚠ No real secrets scan performed. Showing example findings.'));
|
|
416
|
+
output.writeln(output.dim('Run "claude-flow security scan --depth full" for real secret detection.'));
|
|
417
|
+
output.writeln();
|
|
418
|
+
output.printTable({
|
|
419
|
+
columns: [
|
|
420
|
+
{ key: 'type', header: 'Secret Type (Example)', width: 25 },
|
|
421
|
+
{ key: 'location', header: 'Location', width: 30 },
|
|
422
|
+
{ key: 'risk', header: 'Risk', width: 12 },
|
|
423
|
+
{ key: 'action', header: 'Recommended', width: 20 },
|
|
424
|
+
],
|
|
425
|
+
data: [
|
|
426
|
+
{ type: 'AWS Access Key', location: 'example/config.ts:15', risk: output.error('Critical'), action: 'Rotate immediately' },
|
|
427
|
+
{ type: 'GitHub Token', location: 'example/.env:8', risk: output.warning('High'), action: 'Remove from repo' },
|
|
428
|
+
{ type: 'JWT Secret', location: 'example/auth.ts:42', risk: output.warning('High'), action: 'Use env variable' },
|
|
429
|
+
{ type: 'DB Password', location: 'example/compose.yml:23', risk: output.warning('Medium'), action: 'Use secrets mgmt' },
|
|
430
|
+
],
|
|
522
431
|
});
|
|
523
|
-
|
|
432
|
+
return { success: true };
|
|
433
|
+
},
|
|
524
434
|
};
|
|
525
435
|
// Defend subcommand (AIDefence integration)
|
|
526
|
-
|
|
436
|
+
const defendCommand = {
|
|
527
437
|
name: 'defend',
|
|
528
438
|
description: 'AI manipulation defense - detect prompt injection, jailbreaks, and PII',
|
|
529
439
|
options: [
|
|
530
440
|
{ name: 'input', short: 'i', type: 'string', description: 'Input text to scan for threats' },
|
|
531
441
|
{ name: 'file', short: 'f', type: 'string', description: 'File to scan for threats' },
|
|
532
442
|
{ name: 'quick', short: 'Q', type: 'boolean', description: 'Quick scan (faster, less detailed)' },
|
|
533
|
-
{ name: 'learn', short: 'l', type: 'boolean', description: 'Enable learning mode',
|
|
443
|
+
{ name: 'learn', short: 'l', type: 'boolean', description: 'Enable learning mode', default: 'true' },
|
|
534
444
|
{ name: 'stats', short: 's', type: 'boolean', description: 'Show detection statistics' },
|
|
535
|
-
{ name: 'output', short: 'o', type: 'string', description: 'Output format: text, json',
|
|
445
|
+
{ name: 'output', short: 'o', type: 'string', description: 'Output format: text, json', default: 'text' },
|
|
536
446
|
],
|
|
537
447
|
examples: [
|
|
538
448
|
{ command: 'claude-flow security defend -i "ignore previous instructions"', description: 'Scan text for threats' },
|
|
539
449
|
{ command: 'claude-flow security defend -f ./prompts.txt', description: 'Scan file for threats' },
|
|
540
450
|
{ command: 'claude-flow security defend --stats', description: 'Show detection statistics' },
|
|
541
451
|
],
|
|
542
|
-
action:
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
output.writeln();
|
|
641
|
-
if (!(result.safe && !result.piiFound)) return [3 /*break*/, 15];
|
|
642
|
-
output.writeln(output.success('✅ No threats detected'));
|
|
643
|
-
return [3 /*break*/, 21];
|
|
644
|
-
case 15:
|
|
645
|
-
if (!(!result.safe && result.threats)) return [3 /*break*/, 20];
|
|
646
|
-
output.writeln(output.error("\u26A0\uFE0F " + result.threats.length + " threat(s) detected:"));
|
|
452
|
+
action: async (ctx) => {
|
|
453
|
+
const inputText = ctx.flags.input;
|
|
454
|
+
const filePath = ctx.flags.file;
|
|
455
|
+
const quickMode = ctx.flags.quick;
|
|
456
|
+
const showStats = ctx.flags.stats;
|
|
457
|
+
const outputFormat = ctx.flags.output || 'text';
|
|
458
|
+
const enableLearning = ctx.flags.learn !== false;
|
|
459
|
+
output.writeln();
|
|
460
|
+
output.writeln(output.bold('🛡️ AIDefence - AI Manipulation Defense System'));
|
|
461
|
+
output.writeln(output.dim('─'.repeat(55)));
|
|
462
|
+
// Dynamic import of aidefence (allows package to be optional)
|
|
463
|
+
let createAIDefence;
|
|
464
|
+
try {
|
|
465
|
+
const aidefence = await import('@claude-flow/aidefence');
|
|
466
|
+
createAIDefence = aidefence.createAIDefence;
|
|
467
|
+
}
|
|
468
|
+
catch {
|
|
469
|
+
output.error('AIDefence package not installed. Run: npm install @claude-flow/aidefence');
|
|
470
|
+
return { success: false, message: 'AIDefence not available' };
|
|
471
|
+
}
|
|
472
|
+
const defender = createAIDefence({ enableLearning });
|
|
473
|
+
// Show stats mode
|
|
474
|
+
if (showStats) {
|
|
475
|
+
const stats = await defender.getStats();
|
|
476
|
+
output.writeln();
|
|
477
|
+
output.printBox([
|
|
478
|
+
`Detection Count: ${stats.detectionCount}`,
|
|
479
|
+
`Avg Detection Time: ${stats.avgDetectionTimeMs.toFixed(3)}ms`,
|
|
480
|
+
`Learned Patterns: ${stats.learnedPatterns}`,
|
|
481
|
+
`Mitigation Strategies: ${stats.mitigationStrategies}`,
|
|
482
|
+
`Avg Mitigation Effectiveness: ${(stats.avgMitigationEffectiveness * 100).toFixed(1)}%`,
|
|
483
|
+
].join('\n'), 'Detection Statistics');
|
|
484
|
+
return { success: true };
|
|
485
|
+
}
|
|
486
|
+
// Get input to scan
|
|
487
|
+
let textToScan = inputText;
|
|
488
|
+
if (filePath) {
|
|
489
|
+
try {
|
|
490
|
+
const fs = await import('fs/promises');
|
|
491
|
+
textToScan = await fs.readFile(filePath, 'utf-8');
|
|
492
|
+
output.writeln(output.dim(`Reading file: ${filePath}`));
|
|
493
|
+
}
|
|
494
|
+
catch (err) {
|
|
495
|
+
output.error(`Failed to read file: ${filePath}`);
|
|
496
|
+
return { success: false, message: 'File not found' };
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
if (!textToScan) {
|
|
500
|
+
output.writeln('Usage: claude-flow security defend -i "<text>" or -f <file>');
|
|
501
|
+
output.writeln();
|
|
502
|
+
output.writeln('Options:');
|
|
503
|
+
output.printList([
|
|
504
|
+
'-i, --input Text to scan for AI manipulation attempts',
|
|
505
|
+
'-f, --file File path to scan',
|
|
506
|
+
'-q, --quick Quick scan mode (faster)',
|
|
507
|
+
'-s, --stats Show detection statistics',
|
|
508
|
+
'--learn Enable pattern learning (default: true)',
|
|
509
|
+
]);
|
|
510
|
+
return { success: true };
|
|
511
|
+
}
|
|
512
|
+
const spinner = output.createSpinner({ text: 'Scanning for threats...', spinner: 'dots' });
|
|
513
|
+
spinner.start();
|
|
514
|
+
// Perform scan
|
|
515
|
+
const startTime = performance.now();
|
|
516
|
+
const result = quickMode
|
|
517
|
+
? { ...defender.quickScan(textToScan), threats: [], piiFound: false, detectionTimeMs: 0, inputHash: '', safe: !defender.quickScan(textToScan).threat }
|
|
518
|
+
: await defender.detect(textToScan);
|
|
519
|
+
const scanTime = performance.now() - startTime;
|
|
520
|
+
spinner.stop();
|
|
521
|
+
// JSON output
|
|
522
|
+
if (outputFormat === 'json') {
|
|
523
|
+
output.writeln(JSON.stringify({
|
|
524
|
+
safe: result.safe,
|
|
525
|
+
threats: result.threats || [],
|
|
526
|
+
piiFound: result.piiFound,
|
|
527
|
+
detectionTimeMs: scanTime,
|
|
528
|
+
}, null, 2));
|
|
529
|
+
return { success: true };
|
|
530
|
+
}
|
|
531
|
+
// Text output
|
|
532
|
+
output.writeln();
|
|
533
|
+
if (result.safe && !result.piiFound) {
|
|
534
|
+
output.writeln(output.success('✅ No threats detected'));
|
|
535
|
+
}
|
|
536
|
+
else {
|
|
537
|
+
if (!result.safe && result.threats) {
|
|
538
|
+
output.writeln(output.error(`⚠️ ${result.threats.length} threat(s) detected:`));
|
|
539
|
+
output.writeln();
|
|
540
|
+
for (const threat of result.threats) {
|
|
541
|
+
const severityColor = {
|
|
542
|
+
critical: output.error,
|
|
543
|
+
high: output.warning,
|
|
544
|
+
medium: output.info,
|
|
545
|
+
low: output.dim,
|
|
546
|
+
}[threat.severity] || output.dim;
|
|
547
|
+
output.writeln(` ${severityColor(`[${threat.severity.toUpperCase()}]`)} ${threat.type}`);
|
|
548
|
+
output.writeln(` ${output.dim(threat.description)}`);
|
|
549
|
+
output.writeln(` Confidence: ${(threat.confidence * 100).toFixed(1)}%`);
|
|
647
550
|
output.writeln();
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
high: output.warning,
|
|
653
|
-
medium: output.info,
|
|
654
|
-
low: output.dim
|
|
655
|
-
}[threat.severity] || output.dim;
|
|
656
|
-
output.writeln(" " + severityColor("[" + threat.severity.toUpperCase() + "]") + " " + threat.type);
|
|
657
|
-
output.writeln(" " + output.dim(threat.description));
|
|
658
|
-
output.writeln(" Confidence: " + (threat.confidence * 100).toFixed(1) + "%");
|
|
659
|
-
output.writeln();
|
|
660
|
-
}
|
|
661
|
-
criticalThreats = result.threats.filter(function (t) { return t.severity === 'critical'; });
|
|
662
|
-
if (!(criticalThreats.length > 0 && enableLearning)) return [3 /*break*/, 20];
|
|
551
|
+
}
|
|
552
|
+
// Show mitigation recommendations
|
|
553
|
+
const criticalThreats = result.threats.filter(t => t.severity === 'critical');
|
|
554
|
+
if (criticalThreats.length > 0 && enableLearning) {
|
|
663
555
|
output.writeln(output.bold('Recommended Mitigations:'));
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
return [4 /*yield*/, defender.getBestMitigation(threat.type)];
|
|
670
|
-
case 17:
|
|
671
|
-
mitigation = _e.sent();
|
|
672
|
-
if (mitigation) {
|
|
673
|
-
output.writeln(" " + threat.type + ": " + output.bold(mitigation.strategy) + " (" + (mitigation.effectiveness * 100).toFixed(0) + "% effective)");
|
|
556
|
+
for (const threat of criticalThreats) {
|
|
557
|
+
const mitigation = await defender.getBestMitigation(threat.type);
|
|
558
|
+
if (mitigation) {
|
|
559
|
+
output.writeln(` ${threat.type}: ${output.bold(mitigation.strategy)} (${(mitigation.effectiveness * 100).toFixed(0)}% effective)`);
|
|
560
|
+
}
|
|
674
561
|
}
|
|
675
|
-
_e.label = 18;
|
|
676
|
-
case 18:
|
|
677
|
-
_d++;
|
|
678
|
-
return [3 /*break*/, 16];
|
|
679
|
-
case 19:
|
|
680
562
|
output.writeln();
|
|
681
|
-
|
|
682
|
-
case 20:
|
|
683
|
-
if (result.piiFound) {
|
|
684
|
-
output.writeln(output.warning('⚠️ PII detected (emails, SSNs, API keys, etc.)'));
|
|
685
|
-
output.writeln();
|
|
686
|
-
}
|
|
687
|
-
_e.label = 21;
|
|
688
|
-
case 21:
|
|
689
|
-
output.writeln(output.dim("Detection time: " + scanTime.toFixed(3) + "ms"));
|
|
690
|
-
return [2 /*return*/, { success: result.safe }];
|
|
563
|
+
}
|
|
691
564
|
}
|
|
692
|
-
|
|
693
|
-
|
|
565
|
+
if (result.piiFound) {
|
|
566
|
+
output.writeln(output.warning('⚠️ PII detected (emails, SSNs, API keys, etc.)'));
|
|
567
|
+
output.writeln();
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
output.writeln(output.dim(`Detection time: ${scanTime.toFixed(3)}ms`));
|
|
571
|
+
return { success: result.safe };
|
|
572
|
+
},
|
|
694
573
|
};
|
|
695
574
|
// Main security command
|
|
696
|
-
export
|
|
575
|
+
export const securityCommand = {
|
|
697
576
|
name: 'security',
|
|
698
577
|
description: 'Security scanning, CVE detection, threat modeling, AI defense',
|
|
699
578
|
subcommands: [scanCommand, cveCommand, threatsCommand, auditCommand, secretsCommand, defendCommand],
|
|
@@ -702,28 +581,26 @@ export var securityCommand = {
|
|
|
702
581
|
{ command: 'claude-flow security cve --list', description: 'List known CVEs' },
|
|
703
582
|
{ command: 'claude-flow security threats', description: 'Run threat analysis' },
|
|
704
583
|
],
|
|
705
|
-
action:
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
});
|
|
726
|
-
}); }
|
|
584
|
+
action: async () => {
|
|
585
|
+
output.writeln();
|
|
586
|
+
output.writeln(output.bold('RuFlo Security Suite'));
|
|
587
|
+
output.writeln(output.dim('Comprehensive security scanning and vulnerability management'));
|
|
588
|
+
output.writeln();
|
|
589
|
+
output.writeln('Subcommands:');
|
|
590
|
+
output.printList([
|
|
591
|
+
'scan - Run security scans on code, deps, containers',
|
|
592
|
+
'cve - Check and manage CVE vulnerabilities',
|
|
593
|
+
'threats - Threat modeling (STRIDE, DREAD, PASTA)',
|
|
594
|
+
'audit - Security audit logging and compliance',
|
|
595
|
+
'secrets - Detect and manage secrets in codebase',
|
|
596
|
+
'defend - AI manipulation defense (prompt injection, jailbreaks, PII)',
|
|
597
|
+
]);
|
|
598
|
+
output.writeln();
|
|
599
|
+
output.writeln('Use --help with subcommands for more info');
|
|
600
|
+
output.writeln();
|
|
601
|
+
output.writeln(output.dim('Created with ❤️ by ruv.io'));
|
|
602
|
+
return { success: true };
|
|
603
|
+
},
|
|
727
604
|
};
|
|
728
605
|
export default securityCommand;
|
|
729
606
|
//# sourceMappingURL=security.js.map
|