diff --git a/.harness/mcp-policy.json b/.harness/mcp-policy.json new file mode 100644 index 0000000000..8800170722 --- /dev/null +++ b/.harness/mcp-policy.json @@ -0,0 +1,41 @@ +{ + "$comment": "ADR-150 iter 30 — MCP governance policy for ruflo's claude-flow MCP server. Closes the 'no-policy' HIGH finding from `harness mcp-scan`. Configured to reflect ruflo's ACTUAL MCP-layer posture: the claude-flow MCP server exposes 314 tools that operate via higher-level abstractions (memory_*, hooks_*, agentdb_*) — NOT raw shell, network, or filesystem. Those primitives are reached via native Claude Code tools (Bash / Write / Edit / WebFetch) which are governed by Claude Code's own permission system, not this MCP policy. Hence: this policy denies all three at the MCP layer.", + + "schema": 1, + "policyVersion": 1, + "harnessId": "claude-flow", + "rationale": "ADR-022 default-deny posture. The claude-flow MCP server's tools are pure-data operations (read/write via AgentDB, route via embeddings, dispatch via hooks). Shell / network / file-write are NOT in this server's tool surface — they happen at the native-Claude-Code layer, outside this policy's jurisdiction.", + + "defaultDeny": true, + + "allowShell": false, + "allowNetwork": false, + "allowFileWrite": false, + + "requireApprovalForDangerous": true, + "auditLog": true, + + "toolTimeoutMs": 600000, + "maxToolCallsPerTurn": 200, + + "dangerousPatterns": [ + "Bash\\(rm\\b", + "Bash\\(sudo\\b", + "Bash\\(chmod\\s+777\\b", + "Bash\\(curl.+\\|\\s*(sh|bash)\\b", + "Bash\\(wget.+\\|\\s*(sh|bash)\\b", + "Bash\\(ssh\\b", + "Bash\\(git\\s+push.*--force\\b", + "Bash\\(npm\\s+publish\\b" + ], + + "approvedServers": [ + "claude-flow" + ], + + "references": { + "adr": "v3/docs/adr/ADR-150-metaharness-integration-surfaces.md", + "constraint": "Ruflo remains operational if every MetaHarness package is removed.", + "upstream": "github.com/ruvnet/agent-harness-generator/blob/main/dist/mcp-scan.js" + } +} diff --git a/plugins/ruflo-metaharness/scripts/smoke.sh b/plugins/ruflo-metaharness/scripts/smoke.sh index b7818c7ed2..ddb9887c60 100755 --- a/plugins/ruflo-metaharness/scripts/smoke.sh +++ b/plugins/ruflo-metaharness/scripts/smoke.sh @@ -191,6 +191,33 @@ grep -q "execCli(\[\s*'-y'\s*,\s*'metaharness@latest'" "$F" 2>/dev/null || \ grep -q "cwd: opts" "$F" || miss="$miss no-cwd-passthrough" [[ -z "$miss" ]] && ok || bad "$miss" +step "17t. .harness/mcp-policy.json present + default-deny (iter 30 — closes no-policy HIGH)" +F="$ROOT/../../.harness/mcp-policy.json" +miss="" +[[ -f "$F" ]] || miss="$miss missing-policy-file" +node -e "JSON.parse(require('fs').readFileSync('$F','utf-8'))" 2>/dev/null || miss="$miss invalid-json" +# Required fields per metaharness mcp-scan source +node -e " +const j = JSON.parse(require('fs').readFileSync('$F','utf-8')); +const must = { defaultDeny: true, auditLog: true, requireApprovalForDangerous: true }; +for (const [k, v] of Object.entries(must)) { + if (j[k] !== v) { console.error('missing or wrong:', k, '=', j[k]); process.exit(1); } +} +// toolTimeoutMs must be positive +if (!Number.isFinite(j.toolTimeoutMs) || j.toolTimeoutMs <= 0) { + console.error('toolTimeoutMs not positive'); process.exit(1); +} +// maxToolCallsPerTurn must be positive (clears 'no-call-budget' finding) +if (!Number.isFinite(j.maxToolCallsPerTurn) || j.maxToolCallsPerTurn <= 0) { + console.error('maxToolCallsPerTurn not positive'); process.exit(1); +} +// ADR-150 anchor present +if (!JSON.stringify(j).includes('ADR-150')) { + console.error('no ADR-150 anchor in policy'); process.exit(1); +} +" 2>/dev/null || miss="$miss policy-shape-invalid" +[[ -z "$miss" ]] && ok || bad "$miss" + step "17s. mint.mjs cwd-based scaffolding (iter 27 fix for upstream --target bug)" F="$ROOT/scripts/mint.mjs" miss=""