@claude-flow/cli 3.32.29 → 3.32.30
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/.claude/helpers/helpers.manifest.json +2 -2
- package/catalog-manifest.json +2 -2
- package/dist/src/init/claudemd-generator.js +53 -2
- package/dist/src/mcp-tools/capability-brain.js +22 -22
- package/dist/src/mcp-tools/guidance-tools.js +1 -1
- package/node_modules/@claude-flow/codex/.agents/skills/memory-management/SKILL.md +45 -0
- package/node_modules/@claude-flow/codex/.agents/skills/security-audit/SKILL.md +46 -0
- package/node_modules/@claude-flow/codex/.agents/skills/sparc-methodology/SKILL.md +46 -0
- package/node_modules/@claude-flow/codex/.agents/skills/swarm-orchestration/SKILL.md +53 -0
- package/node_modules/@claude-flow/codex/README.md +1044 -0
- package/node_modules/@claude-flow/codex/dist/cli.d.ts +9 -0
- package/node_modules/@claude-flow/codex/dist/cli.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/cli.js +686 -0
- package/node_modules/@claude-flow/codex/dist/cli.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/cli.d.ts +17 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/cli.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/cli.js +278 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/cli.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/index.d.ts +8 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/index.js +7 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/index.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/orchestrator.d.ts +143 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/orchestrator.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/orchestrator.js +621 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/orchestrator.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/generators/agents-md.d.ts +12 -0
- package/node_modules/@claude-flow/codex/dist/generators/agents-md.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/generators/agents-md.js +730 -0
- package/node_modules/@claude-flow/codex/dist/generators/agents-md.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/generators/config-toml.d.ts +74 -0
- package/node_modules/@claude-flow/codex/dist/generators/config-toml.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/generators/config-toml.js +922 -0
- package/node_modules/@claude-flow/codex/dist/generators/config-toml.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/generators/index.d.ts +9 -0
- package/node_modules/@claude-flow/codex/dist/generators/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/generators/index.js +9 -0
- package/node_modules/@claude-flow/codex/dist/generators/index.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/generators/skill-md.d.ts +20 -0
- package/node_modules/@claude-flow/codex/dist/generators/skill-md.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/generators/skill-md.js +951 -0
- package/node_modules/@claude-flow/codex/dist/generators/skill-md.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/build-evidence.d.ts +46 -0
- package/node_modules/@claude-flow/codex/dist/harness/build-evidence.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/build-evidence.js +126 -0
- package/node_modules/@claude-flow/codex/dist/harness/build-evidence.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/contract.d.ts +153 -0
- package/node_modules/@claude-flow/codex/dist/harness/contract.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/contract.js +44 -0
- package/node_modules/@claude-flow/codex/dist/harness/contract.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-fenced-lease-reference.d.ts +33 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-fenced-lease-reference.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-fenced-lease-reference.js +175 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-fenced-lease-reference.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-inbox-reference.d.ts +42 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-inbox-reference.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-inbox-reference.js +140 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-inbox-reference.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-run-receipt-reference.d.ts +19 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-run-receipt-reference.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-run-receipt-reference.js +79 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-run-receipt-reference.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/index.d.ts +9 -0
- package/node_modules/@claude-flow/codex/dist/harness/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/index.js +9 -0
- package/node_modules/@claude-flow/codex/dist/harness/index.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/portable-case-fold.d.ts +8 -0
- package/node_modules/@claude-flow/codex/dist/harness/portable-case-fold.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/portable-case-fold.js +10 -0
- package/node_modules/@claude-flow/codex/dist/harness/portable-case-fold.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/repository-state.d.ts +68 -0
- package/node_modules/@claude-flow/codex/dist/harness/repository-state.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/repository-state.js +403 -0
- package/node_modules/@claude-flow/codex/dist/harness/repository-state.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/unsigned-integer.d.ts +3 -0
- package/node_modules/@claude-flow/codex/dist/harness/unsigned-integer.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/unsigned-integer.js +14 -0
- package/node_modules/@claude-flow/codex/dist/harness/unsigned-integer.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/index.d.ts +53 -0
- package/node_modules/@claude-flow/codex/dist/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/index.js +54 -0
- package/node_modules/@claude-flow/codex/dist/index.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/initializer.d.ts +98 -0
- package/node_modules/@claude-flow/codex/dist/initializer.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/initializer.js +795 -0
- package/node_modules/@claude-flow/codex/dist/initializer.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/loop/cli.d.ts +3 -0
- package/node_modules/@claude-flow/codex/dist/loop/cli.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/loop/cli.js +123 -0
- package/node_modules/@claude-flow/codex/dist/loop/cli.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/loop/index.d.ts +58 -0
- package/node_modules/@claude-flow/codex/dist/loop/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/loop/index.js +230 -0
- package/node_modules/@claude-flow/codex/dist/loop/index.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/mcp-config.d.ts +28 -0
- package/node_modules/@claude-flow/codex/dist/mcp-config.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/mcp-config.js +121 -0
- package/node_modules/@claude-flow/codex/dist/mcp-config.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/migrations/index.d.ts +114 -0
- package/node_modules/@claude-flow/codex/dist/migrations/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/migrations/index.js +880 -0
- package/node_modules/@claude-flow/codex/dist/migrations/index.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/templates/index.d.ts +92 -0
- package/node_modules/@claude-flow/codex/dist/templates/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/templates/index.js +284 -0
- package/node_modules/@claude-flow/codex/dist/templates/index.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/types.d.ts +240 -0
- package/node_modules/@claude-flow/codex/dist/types.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/types.js +8 -0
- package/node_modules/@claude-flow/codex/dist/types.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/validators/index.d.ts +42 -0
- package/node_modules/@claude-flow/codex/dist/validators/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/validators/index.js +929 -0
- package/node_modules/@claude-flow/codex/dist/validators/index.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/worktrees/coordinator.d.ts +37 -0
- package/node_modules/@claude-flow/codex/dist/worktrees/coordinator.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/worktrees/coordinator.js +137 -0
- package/node_modules/@claude-flow/codex/dist/worktrees/coordinator.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/worktrees/index.d.ts +2 -0
- package/node_modules/@claude-flow/codex/dist/worktrees/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/worktrees/index.js +2 -0
- package/node_modules/@claude-flow/codex/dist/worktrees/index.js.map +1 -0
- package/node_modules/@claude-flow/codex/package.json +122 -0
- package/node_modules/@claude-flow/plugin-agent-federation/README.md +49 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/agent-card.d.ts +130 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/agent-card.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/agent-card.js +239 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/agent-card.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/consume.d.ts +34 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/consume.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/consume.js +69 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/consume.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/well-known.d.ts +46 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/well-known.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/well-known.js +84 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/well-known.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/claim-checker.d.ts +27 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/claim-checker.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/claim-checker.js +46 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/claim-checker.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-breaker-service.d.ts +192 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-breaker-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-breaker-service.js +253 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-breaker-service.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-coordinator.d.ts +211 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-coordinator.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-coordinator.js +501 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-coordinator.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/inbound-dispatcher.d.ts +114 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/inbound-dispatcher.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/inbound-dispatcher.js +356 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/inbound-dispatcher.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/policy-engine.d.ts +41 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/policy-engine.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/policy-engine.js +184 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/policy-engine.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/spend-reporter.d.ts +150 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/spend-reporter.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/spend-reporter.js +128 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/spend-reporter.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/trust-evaluator.d.ts +74 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/trust-evaluator.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/trust-evaluator.js +179 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/trust-evaluator.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/bin.d.ts +13 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/bin.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/bin.js +189 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/bin.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/cli-commands.d.ts +7 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/cli-commands.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/cli-commands.js +317 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/cli-commands.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-envelope.d.ts +45 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-envelope.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-envelope.js +71 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-envelope.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-node.d.ts +104 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-node.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-node.js +152 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-node.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-session.d.ts +55 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-session.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-session.js +105 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-session.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/trust-level.d.ts +17 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/trust-level.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/trust-level.js +35 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/trust-level.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/audit-service.d.ts +69 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/audit-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/audit-service.js +149 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/audit-service.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/discovery-service.d.ts +68 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/discovery-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/discovery-service.js +161 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/discovery-service.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/handshake-service.d.ts +58 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/handshake-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/handshake-service.js +122 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/handshake-service.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/pii-pipeline-service.d.ts +65 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/pii-pipeline-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/pii-pipeline-service.js +208 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/pii-pipeline-service.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/routing-service.d.ts +51 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/routing-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/routing-service.js +147 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/routing-service.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-firewall-service.d.ts +71 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-firewall-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-firewall-service.js +194 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-firewall-service.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-mesh-service.d.ts +156 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-mesh-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-mesh-service.js +292 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-mesh-service.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-witness-service.d.ts +98 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-witness-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-witness-service.js +122 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-witness-service.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-budget.d.ts +89 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-budget.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-budget.js +165 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-budget.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-node-state.d.ts +92 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-node-state.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-node-state.js +100 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-node-state.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/wg-config.d.ts +70 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/wg-config.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/wg-config.js +104 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/wg-config.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/index.d.ts +23 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/index.js +24 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/index.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/mcp-tools.d.ts +10 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/mcp-tools.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/mcp-tools.js +439 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/mcp-tools.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/plugin.d.ts +19 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/plugin.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/plugin.js +515 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/plugin.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/transport/midstream-aware-loader.d.ts +72 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/transport/midstream-aware-loader.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/transport/midstream-aware-loader.js +269 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/transport/midstream-aware-loader.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/version.d.ts +3 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/version.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/version.js +3 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/version.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/package.json +64 -0
- package/node_modules/@claude-flow/security/README.md +292 -0
- package/node_modules/@claude-flow/security/dist/CVE-REMEDIATION.d.ts +97 -0
- package/node_modules/@claude-flow/security/dist/CVE-REMEDIATION.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/CVE-REMEDIATION.js +537 -0
- package/node_modules/@claude-flow/security/dist/CVE-REMEDIATION.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/application/index.d.ts +7 -0
- package/node_modules/@claude-flow/security/dist/application/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/application/index.js +7 -0
- package/node_modules/@claude-flow/security/dist/application/index.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/application/services/security-application-service.d.ts +71 -0
- package/node_modules/@claude-flow/security/dist/application/services/security-application-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/application/services/security-application-service.js +153 -0
- package/node_modules/@claude-flow/security/dist/application/services/security-application-service.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/authorization/propagator.d.ts +148 -0
- package/node_modules/@claude-flow/security/dist/authorization/propagator.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/authorization/propagator.js +182 -0
- package/node_modules/@claude-flow/security/dist/authorization/propagator.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/credential-generator.d.ts +176 -0
- package/node_modules/@claude-flow/security/dist/credential-generator.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/credential-generator.js +272 -0
- package/node_modules/@claude-flow/security/dist/credential-generator.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/domain/entities/security-context.d.ts +68 -0
- package/node_modules/@claude-flow/security/dist/domain/entities/security-context.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/domain/entities/security-context.js +132 -0
- package/node_modules/@claude-flow/security/dist/domain/entities/security-context.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/domain/index.d.ts +8 -0
- package/node_modules/@claude-flow/security/dist/domain/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/domain/index.js +8 -0
- package/node_modules/@claude-flow/security/dist/domain/index.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/domain/services/security-domain-service.d.ts +71 -0
- package/node_modules/@claude-flow/security/dist/domain/services/security-domain-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/domain/services/security-domain-service.js +237 -0
- package/node_modules/@claude-flow/security/dist/domain/services/security-domain-service.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/index.d.ts +129 -0
- package/node_modules/@claude-flow/security/dist/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/index.js +176 -0
- package/node_modules/@claude-flow/security/dist/index.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/input-validator.d.ts +306 -0
- package/node_modules/@claude-flow/security/dist/input-validator.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/input-validator.js +393 -0
- package/node_modules/@claude-flow/security/dist/input-validator.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/keychain-adapter.d.ts +48 -0
- package/node_modules/@claude-flow/security/dist/keychain-adapter.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/keychain-adapter.js +0 -0
- package/node_modules/@claude-flow/security/dist/keychain-adapter.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/mcp-composition-inspector.d.ts +133 -0
- package/node_modules/@claude-flow/security/dist/mcp-composition-inspector.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/mcp-composition-inspector.js +254 -0
- package/node_modules/@claude-flow/security/dist/mcp-composition-inspector.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/oauth/browser.d.ts +31 -0
- package/node_modules/@claude-flow/security/dist/oauth/browser.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/oauth/browser.js +55 -0
- package/node_modules/@claude-flow/security/dist/oauth/browser.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/oauth/callback-server.d.ts +37 -0
- package/node_modules/@claude-flow/security/dist/oauth/callback-server.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/oauth/callback-server.js +86 -0
- package/node_modules/@claude-flow/security/dist/oauth/callback-server.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/oauth/client.d.ts +57 -0
- package/node_modules/@claude-flow/security/dist/oauth/client.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/oauth/client.js +120 -0
- package/node_modules/@claude-flow/security/dist/oauth/client.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/oauth/pkce.d.ts +25 -0
- package/node_modules/@claude-flow/security/dist/oauth/pkce.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/oauth/pkce.js +36 -0
- package/node_modules/@claude-flow/security/dist/oauth/pkce.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/password-hasher.d.ts +128 -0
- package/node_modules/@claude-flow/security/dist/password-hasher.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/password-hasher.js +190 -0
- package/node_modules/@claude-flow/security/dist/password-hasher.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/path-validator.d.ts +148 -0
- package/node_modules/@claude-flow/security/dist/path-validator.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/path-validator.js +421 -0
- package/node_modules/@claude-flow/security/dist/path-validator.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/plugins/integrity-verifier.d.ts +125 -0
- package/node_modules/@claude-flow/security/dist/plugins/integrity-verifier.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/plugins/integrity-verifier.js +186 -0
- package/node_modules/@claude-flow/security/dist/plugins/integrity-verifier.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/canonical.d.ts +5 -0
- package/node_modules/@claude-flow/security/dist/policy/canonical.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/canonical.js +30 -0
- package/node_modules/@claude-flow/security/dist/policy/canonical.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/engine.d.ts +34 -0
- package/node_modules/@claude-flow/security/dist/policy/engine.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/engine.js +285 -0
- package/node_modules/@claude-flow/security/dist/policy/engine.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/envelope.d.ts +9 -0
- package/node_modules/@claude-flow/security/dist/policy/envelope.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/envelope.js +90 -0
- package/node_modules/@claude-flow/security/dist/policy/envelope.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/evaluator.d.ts +4 -0
- package/node_modules/@claude-flow/security/dist/policy/evaluator.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/evaluator.js +119 -0
- package/node_modules/@claude-flow/security/dist/policy/evaluator.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/index.d.ts +7 -0
- package/node_modules/@claude-flow/security/dist/policy/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/index.js +7 -0
- package/node_modules/@claude-flow/security/dist/policy/index.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/product-plane.d.ts +238 -0
- package/node_modules/@claude-flow/security/dist/policy/product-plane.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/product-plane.js +1022 -0
- package/node_modules/@claude-flow/security/dist/policy/product-plane.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/types.d.ts +169 -0
- package/node_modules/@claude-flow/security/dist/policy/types.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/types.js +2 -0
- package/node_modules/@claude-flow/security/dist/policy/types.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/safe-executor.d.ts +180 -0
- package/node_modules/@claude-flow/security/dist/safe-executor.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/safe-executor.js +390 -0
- package/node_modules/@claude-flow/security/dist/safe-executor.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/token-generator.d.ts +224 -0
- package/node_modules/@claude-flow/security/dist/token-generator.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/token-generator.js +351 -0
- package/node_modules/@claude-flow/security/dist/token-generator.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/tool-output-guardrail.d.ts +126 -0
- package/node_modules/@claude-flow/security/dist/tool-output-guardrail.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/tool-output-guardrail.js +257 -0
- package/node_modules/@claude-flow/security/dist/tool-output-guardrail.js.map +1 -0
- package/node_modules/@claude-flow/security/package.json +44 -0
- package/package.json +24 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-validator.d.ts","sourceRoot":"","sources":["../src/path-validator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAKH,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,eAAe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O,CAAC,MAAM,CAAC;IAQxE;;;;OAIG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAQ/B;;OAEG;IACH,kBAAkB,IAAI,SAAS,MAAM,EAAE;IAIvC;;OAEG;IACH,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;CAU5C;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,MAAM,GAAG,aAAa,CAS7E;AAED;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAAC,WAAW,EAAE,MAAM,GAAG,aAAa,CASjF"}
|
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path Validator - HIGH-2 Remediation
|
|
3
|
+
*
|
|
4
|
+
* Fixes path traversal vulnerabilities by:
|
|
5
|
+
* - Validating all file paths against allowed prefixes
|
|
6
|
+
* - Using path.resolve() for canonicalization
|
|
7
|
+
* - Blocking traversal patterns (../, etc.)
|
|
8
|
+
* - Enforcing path length limits
|
|
9
|
+
*
|
|
10
|
+
* Security Properties:
|
|
11
|
+
* - Path canonicalization
|
|
12
|
+
* - Prefix validation
|
|
13
|
+
* - Symlink resolution (optional)
|
|
14
|
+
* - Traversal pattern detection
|
|
15
|
+
*
|
|
16
|
+
* @module v3/security/path-validator
|
|
17
|
+
*/
|
|
18
|
+
import * as path from 'path';
|
|
19
|
+
import * as fs from 'fs/promises';
|
|
20
|
+
export class PathValidatorError extends Error {
|
|
21
|
+
code;
|
|
22
|
+
path;
|
|
23
|
+
constructor(message, code, path) {
|
|
24
|
+
super(message);
|
|
25
|
+
this.code = code;
|
|
26
|
+
this.path = path;
|
|
27
|
+
this.name = 'PathValidatorError';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Dangerous path patterns that indicate traversal attempts.
|
|
32
|
+
*/
|
|
33
|
+
const TRAVERSAL_PATTERNS = [
|
|
34
|
+
/\.\.\//, // ../
|
|
35
|
+
/\.\.\\/, // ..\
|
|
36
|
+
/\.\./, // .. anywhere
|
|
37
|
+
/%2e%2e/i, // URL-encoded ..
|
|
38
|
+
/%252e%252e/i, // Double URL-encoded ..
|
|
39
|
+
/\.%2e/i, // Mixed encoding
|
|
40
|
+
/%2e\./i, // Mixed encoding
|
|
41
|
+
/\0/, // Null byte
|
|
42
|
+
/%00/, // URL-encoded null
|
|
43
|
+
];
|
|
44
|
+
/**
|
|
45
|
+
* Default blocked file extensions (sensitive files).
|
|
46
|
+
*/
|
|
47
|
+
const DEFAULT_BLOCKED_EXTENSIONS = [
|
|
48
|
+
'.env',
|
|
49
|
+
'.pem',
|
|
50
|
+
'.key',
|
|
51
|
+
'.crt',
|
|
52
|
+
'.pfx',
|
|
53
|
+
'.p12',
|
|
54
|
+
'.jks',
|
|
55
|
+
'.keystore',
|
|
56
|
+
'.secret',
|
|
57
|
+
'.credentials',
|
|
58
|
+
];
|
|
59
|
+
/**
|
|
60
|
+
* Default blocked file names (sensitive files).
|
|
61
|
+
*/
|
|
62
|
+
const DEFAULT_BLOCKED_NAMES = [
|
|
63
|
+
'id_rsa',
|
|
64
|
+
'id_dsa',
|
|
65
|
+
'id_ecdsa',
|
|
66
|
+
'id_ed25519',
|
|
67
|
+
'.htpasswd',
|
|
68
|
+
'.htaccess',
|
|
69
|
+
'shadow',
|
|
70
|
+
'passwd',
|
|
71
|
+
'authorized_keys',
|
|
72
|
+
'known_hosts',
|
|
73
|
+
'.git',
|
|
74
|
+
'.gitconfig',
|
|
75
|
+
'.npmrc',
|
|
76
|
+
'.docker',
|
|
77
|
+
];
|
|
78
|
+
/**
|
|
79
|
+
* Path validator that prevents traversal attacks.
|
|
80
|
+
*
|
|
81
|
+
* This class validates file paths to ensure they stay within
|
|
82
|
+
* allowed directories and don't access sensitive files.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* const validator = new PathValidator({
|
|
87
|
+
* allowedPrefixes: ['/workspaces/project']
|
|
88
|
+
* });
|
|
89
|
+
*
|
|
90
|
+
* const result = await validator.validate('/workspaces/project/src/file.ts');
|
|
91
|
+
* if (result.isValid) {
|
|
92
|
+
* // Safe to use result.resolvedPath
|
|
93
|
+
* }
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
export class PathValidator {
|
|
97
|
+
config;
|
|
98
|
+
resolvedPrefixes;
|
|
99
|
+
constructor(config) {
|
|
100
|
+
this.config = {
|
|
101
|
+
allowedPrefixes: config.allowedPrefixes,
|
|
102
|
+
blockedExtensions: config.blockedExtensions ?? DEFAULT_BLOCKED_EXTENSIONS,
|
|
103
|
+
blockedNames: config.blockedNames ?? DEFAULT_BLOCKED_NAMES,
|
|
104
|
+
maxPathLength: config.maxPathLength ?? 4096,
|
|
105
|
+
resolveSymlinks: config.resolveSymlinks ?? true,
|
|
106
|
+
allowNonExistent: config.allowNonExistent ?? true,
|
|
107
|
+
allowHidden: config.allowHidden ?? false,
|
|
108
|
+
};
|
|
109
|
+
if (this.config.allowedPrefixes.length === 0) {
|
|
110
|
+
throw new PathValidatorError('At least one allowed prefix must be specified', 'EMPTY_PREFIXES');
|
|
111
|
+
}
|
|
112
|
+
// Pre-resolve all prefixes
|
|
113
|
+
this.resolvedPrefixes = this.config.allowedPrefixes.map(p => path.resolve(p));
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Validates a path against security rules.
|
|
117
|
+
*
|
|
118
|
+
* @param inputPath - The path to validate
|
|
119
|
+
* @returns Validation result with resolved path
|
|
120
|
+
*/
|
|
121
|
+
async validate(inputPath) {
|
|
122
|
+
const errors = [];
|
|
123
|
+
// Check for empty path
|
|
124
|
+
if (!inputPath || inputPath.trim() === '') {
|
|
125
|
+
return {
|
|
126
|
+
isValid: false,
|
|
127
|
+
resolvedPath: '',
|
|
128
|
+
relativePath: '',
|
|
129
|
+
matchedPrefix: '',
|
|
130
|
+
errors: ['Path is empty'],
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
// Check path length
|
|
134
|
+
if (inputPath.length > this.config.maxPathLength) {
|
|
135
|
+
return {
|
|
136
|
+
isValid: false,
|
|
137
|
+
resolvedPath: '',
|
|
138
|
+
relativePath: '',
|
|
139
|
+
matchedPrefix: '',
|
|
140
|
+
errors: [`Path exceeds maximum length of ${this.config.maxPathLength}`],
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
// Check for traversal patterns
|
|
144
|
+
for (const pattern of TRAVERSAL_PATTERNS) {
|
|
145
|
+
if (pattern.test(inputPath)) {
|
|
146
|
+
return {
|
|
147
|
+
isValid: false,
|
|
148
|
+
resolvedPath: '',
|
|
149
|
+
relativePath: '',
|
|
150
|
+
matchedPrefix: '',
|
|
151
|
+
errors: ['Path traversal pattern detected'],
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
// Resolve the path
|
|
156
|
+
let resolvedPath;
|
|
157
|
+
try {
|
|
158
|
+
resolvedPath = path.resolve(inputPath);
|
|
159
|
+
// Optionally resolve symlinks
|
|
160
|
+
if (this.config.resolveSymlinks) {
|
|
161
|
+
try {
|
|
162
|
+
resolvedPath = await fs.realpath(resolvedPath);
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
// Path doesn't exist yet - use resolved path
|
|
166
|
+
if (error.code !== 'ENOENT' || !this.config.allowNonExistent) {
|
|
167
|
+
if (error.code === 'ENOENT') {
|
|
168
|
+
errors.push('Path does not exist');
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
errors.push(`Failed to resolve path: ${error.message}`);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
catch (error) {
|
|
178
|
+
return {
|
|
179
|
+
isValid: false,
|
|
180
|
+
resolvedPath: '',
|
|
181
|
+
relativePath: '',
|
|
182
|
+
matchedPrefix: '',
|
|
183
|
+
errors: [`Invalid path: ${error.message}`],
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
// Check against allowed prefixes
|
|
187
|
+
let matchedPrefix = '';
|
|
188
|
+
let relativePath = '';
|
|
189
|
+
let prefixMatched = false;
|
|
190
|
+
for (const prefix of this.resolvedPrefixes) {
|
|
191
|
+
if (resolvedPath === prefix || resolvedPath.startsWith(prefix + path.sep)) {
|
|
192
|
+
prefixMatched = true;
|
|
193
|
+
matchedPrefix = prefix;
|
|
194
|
+
relativePath = resolvedPath.slice(prefix.length);
|
|
195
|
+
if (relativePath.startsWith(path.sep)) {
|
|
196
|
+
relativePath = relativePath.slice(1);
|
|
197
|
+
}
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if (!prefixMatched) {
|
|
202
|
+
return {
|
|
203
|
+
isValid: false,
|
|
204
|
+
resolvedPath,
|
|
205
|
+
relativePath: '',
|
|
206
|
+
matchedPrefix: '',
|
|
207
|
+
errors: ['Path is outside allowed directories'],
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
// Check for hidden files
|
|
211
|
+
const pathParts = resolvedPath.split(path.sep);
|
|
212
|
+
if (!this.config.allowHidden) {
|
|
213
|
+
for (const part of pathParts) {
|
|
214
|
+
if (part.startsWith('.') && part !== '.' && part !== '..') {
|
|
215
|
+
errors.push('Hidden files/directories are not allowed');
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
// Check blocked file names
|
|
221
|
+
const basename = path.basename(resolvedPath);
|
|
222
|
+
if (this.config.blockedNames.includes(basename)) {
|
|
223
|
+
errors.push(`File name "${basename}" is blocked`);
|
|
224
|
+
}
|
|
225
|
+
// Check blocked extensions
|
|
226
|
+
const ext = path.extname(resolvedPath).toLowerCase();
|
|
227
|
+
if (this.config.blockedExtensions.includes(ext)) {
|
|
228
|
+
errors.push(`File extension "${ext}" is blocked`);
|
|
229
|
+
}
|
|
230
|
+
// Also check for double extensions (e.g., .tar.gz, .config.json)
|
|
231
|
+
const fullname = basename.toLowerCase();
|
|
232
|
+
for (const blockedExt of this.config.blockedExtensions) {
|
|
233
|
+
if (fullname.endsWith(blockedExt)) {
|
|
234
|
+
errors.push(`File extension "${blockedExt}" is blocked`);
|
|
235
|
+
break;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return {
|
|
239
|
+
isValid: errors.length === 0,
|
|
240
|
+
resolvedPath,
|
|
241
|
+
relativePath,
|
|
242
|
+
matchedPrefix,
|
|
243
|
+
errors,
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Validates and returns resolved path, throwing on failure.
|
|
248
|
+
*
|
|
249
|
+
* @param inputPath - The path to validate
|
|
250
|
+
* @returns Resolved path if valid
|
|
251
|
+
* @throws PathValidatorError if validation fails
|
|
252
|
+
*/
|
|
253
|
+
async validateOrThrow(inputPath) {
|
|
254
|
+
const result = await this.validate(inputPath);
|
|
255
|
+
if (!result.isValid) {
|
|
256
|
+
throw new PathValidatorError(result.errors.join('; '), 'VALIDATION_FAILED', inputPath);
|
|
257
|
+
}
|
|
258
|
+
return result.resolvedPath;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Synchronous validation (without symlink resolution).
|
|
262
|
+
*
|
|
263
|
+
* @param inputPath - The path to validate
|
|
264
|
+
* @returns Validation result
|
|
265
|
+
*/
|
|
266
|
+
validateSync(inputPath) {
|
|
267
|
+
const errors = [];
|
|
268
|
+
if (!inputPath || inputPath.trim() === '') {
|
|
269
|
+
return {
|
|
270
|
+
isValid: false,
|
|
271
|
+
resolvedPath: '',
|
|
272
|
+
relativePath: '',
|
|
273
|
+
matchedPrefix: '',
|
|
274
|
+
errors: ['Path is empty'],
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
if (inputPath.length > this.config.maxPathLength) {
|
|
278
|
+
return {
|
|
279
|
+
isValid: false,
|
|
280
|
+
resolvedPath: '',
|
|
281
|
+
relativePath: '',
|
|
282
|
+
matchedPrefix: '',
|
|
283
|
+
errors: [`Path exceeds maximum length of ${this.config.maxPathLength}`],
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
for (const pattern of TRAVERSAL_PATTERNS) {
|
|
287
|
+
if (pattern.test(inputPath)) {
|
|
288
|
+
return {
|
|
289
|
+
isValid: false,
|
|
290
|
+
resolvedPath: '',
|
|
291
|
+
relativePath: '',
|
|
292
|
+
matchedPrefix: '',
|
|
293
|
+
errors: ['Path traversal pattern detected'],
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
const resolvedPath = path.resolve(inputPath);
|
|
298
|
+
let matchedPrefix = '';
|
|
299
|
+
let relativePath = '';
|
|
300
|
+
let prefixMatched = false;
|
|
301
|
+
for (const prefix of this.resolvedPrefixes) {
|
|
302
|
+
if (resolvedPath === prefix || resolvedPath.startsWith(prefix + path.sep)) {
|
|
303
|
+
prefixMatched = true;
|
|
304
|
+
matchedPrefix = prefix;
|
|
305
|
+
relativePath = resolvedPath.slice(prefix.length);
|
|
306
|
+
if (relativePath.startsWith(path.sep)) {
|
|
307
|
+
relativePath = relativePath.slice(1);
|
|
308
|
+
}
|
|
309
|
+
break;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
if (!prefixMatched) {
|
|
313
|
+
return {
|
|
314
|
+
isValid: false,
|
|
315
|
+
resolvedPath,
|
|
316
|
+
relativePath: '',
|
|
317
|
+
matchedPrefix: '',
|
|
318
|
+
errors: ['Path is outside allowed directories'],
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
const pathParts = resolvedPath.split(path.sep);
|
|
322
|
+
if (!this.config.allowHidden) {
|
|
323
|
+
for (const part of pathParts) {
|
|
324
|
+
if (part.startsWith('.') && part !== '.' && part !== '..') {
|
|
325
|
+
errors.push('Hidden files/directories are not allowed');
|
|
326
|
+
break;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
const basename = path.basename(resolvedPath);
|
|
331
|
+
if (this.config.blockedNames.includes(basename)) {
|
|
332
|
+
errors.push(`File name "${basename}" is blocked`);
|
|
333
|
+
}
|
|
334
|
+
const ext = path.extname(resolvedPath).toLowerCase();
|
|
335
|
+
if (this.config.blockedExtensions.includes(ext)) {
|
|
336
|
+
errors.push(`File extension "${ext}" is blocked`);
|
|
337
|
+
}
|
|
338
|
+
return {
|
|
339
|
+
isValid: errors.length === 0,
|
|
340
|
+
resolvedPath,
|
|
341
|
+
relativePath,
|
|
342
|
+
matchedPrefix,
|
|
343
|
+
errors,
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Securely joins path segments within allowed directories.
|
|
348
|
+
*
|
|
349
|
+
* @param prefix - Base directory (must be in allowedPrefixes)
|
|
350
|
+
* @param segments - Path segments to join
|
|
351
|
+
* @returns Validated resolved path
|
|
352
|
+
*/
|
|
353
|
+
async securePath(prefix, ...segments) {
|
|
354
|
+
// Join the segments
|
|
355
|
+
const joined = path.join(prefix, ...segments);
|
|
356
|
+
// Validate the result
|
|
357
|
+
return this.validateOrThrow(joined);
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Adds a prefix to the allowed list at runtime.
|
|
361
|
+
*
|
|
362
|
+
* @param prefix - Prefix to add
|
|
363
|
+
*/
|
|
364
|
+
addPrefix(prefix) {
|
|
365
|
+
const resolved = path.resolve(prefix);
|
|
366
|
+
if (!this.resolvedPrefixes.includes(resolved)) {
|
|
367
|
+
this.config.allowedPrefixes.push(prefix);
|
|
368
|
+
this.resolvedPrefixes.push(resolved);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Returns the current allowed prefixes.
|
|
373
|
+
*/
|
|
374
|
+
getAllowedPrefixes() {
|
|
375
|
+
return [...this.resolvedPrefixes];
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Checks if a path is within allowed prefixes (quick check).
|
|
379
|
+
*/
|
|
380
|
+
isWithinAllowed(inputPath) {
|
|
381
|
+
try {
|
|
382
|
+
const resolved = path.resolve(inputPath);
|
|
383
|
+
return this.resolvedPrefixes.some(prefix => resolved === prefix || resolved.startsWith(prefix + path.sep));
|
|
384
|
+
}
|
|
385
|
+
catch {
|
|
386
|
+
return false;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Factory function to create a path validator for a project directory.
|
|
392
|
+
*
|
|
393
|
+
* @param projectRoot - Root directory of the project
|
|
394
|
+
* @returns Configured PathValidator
|
|
395
|
+
*/
|
|
396
|
+
export function createProjectPathValidator(projectRoot) {
|
|
397
|
+
const srcDir = path.join(projectRoot, 'src');
|
|
398
|
+
const testDir = path.join(projectRoot, 'tests');
|
|
399
|
+
const docsDir = path.join(projectRoot, 'docs');
|
|
400
|
+
return new PathValidator({
|
|
401
|
+
allowedPrefixes: [srcDir, testDir, docsDir],
|
|
402
|
+
allowHidden: false,
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Factory function to create a path validator for the entire project.
|
|
407
|
+
*
|
|
408
|
+
* @param projectRoot - Root directory of the project
|
|
409
|
+
* @returns Configured PathValidator
|
|
410
|
+
*/
|
|
411
|
+
export function createFullProjectPathValidator(projectRoot) {
|
|
412
|
+
return new PathValidator({
|
|
413
|
+
allowedPrefixes: [projectRoot],
|
|
414
|
+
allowHidden: true, // Allow .gitignore, etc.
|
|
415
|
+
blockedNames: [
|
|
416
|
+
...DEFAULT_BLOCKED_NAMES,
|
|
417
|
+
'node_modules', // Block access to node_modules
|
|
418
|
+
],
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
//# sourceMappingURL=path-validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-validator.js","sourceRoot":"","sources":["../src/path-validator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KA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AAC,IAAI,CAC/B,MAAM,CAAC,EAAE,CAAC,QAAQ,KAAK,MAAM,IAAI,QAAQ,CAAC,UAAU,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CACxE,CAAC;QACJ,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,UAAU,0BAA0B,CAAC,WAAmB;IAC5D,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IAC7C,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAChD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAE/C,OAAO,IAAI,aAAa,CAAC;QACvB,eAAe,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC;QAC3C,WAAW,EAAE,KAAK;KACnB,CAAC,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,8BAA8B,CAAC,WAAmB;IAChE,OAAO,IAAI,aAAa,CAAC;QACvB,eAAe,EAAE,CAAC,WAAW,CAAC;QAC9B,WAAW,EAAE,IAAI,EAAE,yBAAyB;QAC5C,YAAY,EAAE;YACZ,GAAG,qBAAqB;YACxB,cAAc,EAAE,+BAA+B;SAChD;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PluginIntegrityVerifier — install-layer security for plugin supply chain.
|
|
3
|
+
*
|
|
4
|
+
* Implements P1 of ADR-145 (ruvnet/ruflo#2254): Stage-1 Ed25519 signature
|
|
5
|
+
* verification at `plugins install`. Stage-2 (semantic-intent scan against
|
|
6
|
+
* SCH attacks) lands in P2; per-namespace write ACLs land in P3-P4.
|
|
7
|
+
*
|
|
8
|
+
* Threat model
|
|
9
|
+
* ------------
|
|
10
|
+
* Ruflo's plugin install path fetches manifests from IPFS via Pinata with
|
|
11
|
+
* NO signature verification and NO intent analysis. Two attacks land today:
|
|
12
|
+
*
|
|
13
|
+
* - DDIPE (arXiv:2604.03081): malicious logic embedded in plugin docs and
|
|
14
|
+
* config templates. 11.6-33.5% bypass rate across 4 frameworks/5 models;
|
|
15
|
+
* 2.5% evade both detection and alignment. Stage-1 signing blocks the
|
|
16
|
+
* static-payload variants.
|
|
17
|
+
*
|
|
18
|
+
* - SCH (arXiv:2605.14460): malicious intent wrapped as natural-language
|
|
19
|
+
* "compliance rules" in plugin descriptions. The agent generates the
|
|
20
|
+
* harmful code at runtime — no static payload exists. 77.67% breach
|
|
21
|
+
* success, 0.00% scanner detection. Stage-2 (P2) catches this; Stage-1
|
|
22
|
+
* does not.
|
|
23
|
+
*
|
|
24
|
+
* Scope (P1)
|
|
25
|
+
* ----------
|
|
26
|
+
* - Ed25519 signature verification of a detached signature over the manifest.
|
|
27
|
+
* - Trust-anchor allowlist: the publisher's signing key fingerprint must be
|
|
28
|
+
* in `trust-anchors.json`, gated on CODEOWNERS review.
|
|
29
|
+
* - Backwards compatible: default mode is warn-only. `CLAUDE_FLOW_STRICT_PLUGINS=true`
|
|
30
|
+
* makes verification a hard gate.
|
|
31
|
+
*
|
|
32
|
+
* Non-goals (P1)
|
|
33
|
+
* --------------
|
|
34
|
+
* - Semantic intent scan (SCH defence). Lands in P2 with a pattern-rule
|
|
35
|
+
* fallback for environments without LLM credentials.
|
|
36
|
+
* - Sandboxing the plugin runtime. Orthogonal blast-radius concern.
|
|
37
|
+
*
|
|
38
|
+
* Reference: ADR-145, arXiv:2605.14460 (SCH), arXiv:2604.03081 (DDIPE),
|
|
39
|
+
* arXiv:2604.16548 (Mnemonic Sovereignty survey).
|
|
40
|
+
*/
|
|
41
|
+
export interface PluginManifest {
|
|
42
|
+
readonly id: string;
|
|
43
|
+
readonly version: string;
|
|
44
|
+
/** Anything else; only `id` + `version` matter for the integrity hash. */
|
|
45
|
+
readonly [extra: string]: unknown;
|
|
46
|
+
}
|
|
47
|
+
export interface SignedPluginManifest {
|
|
48
|
+
readonly manifest: PluginManifest;
|
|
49
|
+
/** Hex-encoded SHA-256 of the canonical JSON serialisation of manifest. */
|
|
50
|
+
readonly manifestHash: string;
|
|
51
|
+
/** Hex-encoded detached Ed25519 signature over `manifestHash` bytes. */
|
|
52
|
+
readonly signature: string;
|
|
53
|
+
/** Hex-encoded Ed25519 public key of the signer. */
|
|
54
|
+
readonly publicKey: string;
|
|
55
|
+
}
|
|
56
|
+
export interface TrustAnchor {
|
|
57
|
+
/** Hex-encoded Ed25519 public key the publisher signs with. */
|
|
58
|
+
readonly publicKey: string;
|
|
59
|
+
/** Human-readable owner — for audit, not for trust decisions. */
|
|
60
|
+
readonly owner: string;
|
|
61
|
+
/** Optional ISO 8601 date after which this anchor is no longer trusted. */
|
|
62
|
+
readonly expiresAt?: string;
|
|
63
|
+
/** Optional plugin id glob this anchor is authoritative for (e.g. `@claude-flow/*`). */
|
|
64
|
+
readonly scope?: string;
|
|
65
|
+
}
|
|
66
|
+
export interface TrustAnchors {
|
|
67
|
+
readonly version: 1;
|
|
68
|
+
readonly anchors: ReadonlyArray<TrustAnchor>;
|
|
69
|
+
}
|
|
70
|
+
export type VerificationStatus = 'pass' | 'signature-missing' | 'signature-invalid' | 'manifest-hash-mismatch' | 'unknown-signer' | 'signer-expired' | 'signer-out-of-scope';
|
|
71
|
+
export interface VerificationResult {
|
|
72
|
+
readonly status: VerificationStatus;
|
|
73
|
+
readonly pluginId: string;
|
|
74
|
+
readonly signerFingerprint?: string;
|
|
75
|
+
/** Verification timestamp — useful for telemetry correlation. */
|
|
76
|
+
readonly ts: number;
|
|
77
|
+
/** Operator-facing detail; do not parse — log only. */
|
|
78
|
+
readonly detail?: string;
|
|
79
|
+
}
|
|
80
|
+
export interface VerifierConfig {
|
|
81
|
+
readonly trustAnchors: TrustAnchors;
|
|
82
|
+
/**
|
|
83
|
+
* When true, `verify` returns the actual failure status. When false (legacy
|
|
84
|
+
* mode), `verify` returns the failure status BUT callers may choose to
|
|
85
|
+
* proceed with a warning — the strictness gate lives at the caller, not
|
|
86
|
+
* here, so the verifier itself is always pure.
|
|
87
|
+
*/
|
|
88
|
+
readonly strict?: boolean;
|
|
89
|
+
/** Optional now-provider for tests. */
|
|
90
|
+
readonly now?: () => number;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Canonical JSON serialisation for hashing. Deterministic key ordering at
|
|
94
|
+
* every nesting level. Pure; identical input → identical output bytes.
|
|
95
|
+
*/
|
|
96
|
+
export declare function canonicalize(value: unknown): string;
|
|
97
|
+
/** Hex-encoded SHA-256 of the canonical-JSON manifest. */
|
|
98
|
+
export declare function hashManifest(manifest: PluginManifest): string;
|
|
99
|
+
/** Short fingerprint for telemetry — first 16 hex chars of the key. */
|
|
100
|
+
export declare function fingerprint(publicKey: string): string;
|
|
101
|
+
/**
|
|
102
|
+
* Find the trust anchor that vouches for a manifest. Returns the matched
|
|
103
|
+
* anchor (with anchor.publicKey === signer.publicKey) or null.
|
|
104
|
+
*
|
|
105
|
+
* Scope-matching uses a minimal glob: `*` at the end of the scope string
|
|
106
|
+
* matches any suffix. Empty/missing scope matches every plugin id.
|
|
107
|
+
*/
|
|
108
|
+
export declare function findAnchor(anchors: ReadonlyArray<TrustAnchor>, pluginId: string, signerPublicKey: string, now: number): TrustAnchor | null;
|
|
109
|
+
/**
|
|
110
|
+
* `PluginIntegrityVerifier` — Stage-1 verifier (signature + trust anchor).
|
|
111
|
+
*
|
|
112
|
+
* Pure-ish: holds the trust-anchor list and clock, no other state. Safe to
|
|
113
|
+
* construct per-invocation or share.
|
|
114
|
+
*/
|
|
115
|
+
export declare class PluginIntegrityVerifier {
|
|
116
|
+
private readonly config;
|
|
117
|
+
constructor(config: VerifierConfig);
|
|
118
|
+
/**
|
|
119
|
+
* Verify a signed manifest. Returns the verification status; the caller
|
|
120
|
+
* decides what to do with `signature-missing` / `manifest-hash-mismatch`
|
|
121
|
+
* etc. based on its strict-mode policy.
|
|
122
|
+
*/
|
|
123
|
+
verify(signed: SignedPluginManifest): Promise<VerificationResult>;
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=integrity-verifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integrity-verifier.d.ts","sourceRoot":"","sources":["../../src/plugins/integrity-verifier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAKH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,0EAA0E;IAC1E,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;CACnC;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,2EAA2E;IAC3E,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,wEAAwE;IACxE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,oDAAoD;IACpD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,WAAW;IAC1B,+DAA+D;IAC/D,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,iEAAiE;IACjE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,2EAA2E;IAC3E,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,wFAAwF;IACxF,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IACpB,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;CAC9C;AAED,MAAM,MAAM,kBAAkB,GAC1B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