π The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
feat(ci): #2089 ADR-127 Phase 1 β github-safe injection smoke + uses: pin smoke + supply-chain allowed-deps actions block
ruv90df1d6e8ad7
diff --git a/.github/supply-chain/allowed-deps.json b/.github/supply-chain/allowed-deps.jsonindex fc9fc00bee..50cbba7826 100644--- a/.github/supply-chain/allowed-deps.json+++ b/.github/supply-chain/allowed-deps.json@@ -48,6 +48,22 @@]}},+ "actions": {+ "comment": "ADR-127 Phase 1 β all uses: refs in .claude/agents/github/, .claude/skills/github-*/, and v3/@claude-flow/cli/.claude/commands/github/ must be either SHA-pinned or present in this list. Phase 3 will upgrade @v3 refs to @v4; until then the non-SHA refs are tracked here. ruvnet/swarm-action@v1 is a first-party action requiring SHA-pin in a future phase (ADR-127 Phase 3 note).",+ "allowed": [+ "actions/checkout",+ "actions/setup-node",+ "pnpm/action-setup",+ "actions/cache",+ "actions/upload-artifact",+ "ruvnet/swarm-action",+ "aws-actions/configure-aws-credentials"+ ],+ "minimumVersion": {+ "actions/checkout": "v4",+ "actions/setup-node": "v4"+ }+ },"publisherTrust": {"comment": "We rely on npm publisher identity for these critical upstream deps. If a publisher account changes or unpublishes, supply-chain-audit alerts.","criticalUpstreamPackages": [diff --git a/.github/workflows/v3-ci.yml b/.github/workflows/v3-ci.ymlindex d3b9b4ea62..ef82288ac2 100644--- a/.github/workflows/v3-ci.yml+++ b/.github/workflows/v3-ci.yml@@ -80,6 +80,16 @@ on:- 'v3/@claude-flow/cli/src/mcp-tools/ruvllm-tools.ts'- 'v3/@claude-flow/cli/src/ruvector/ruvllm-wasm.ts'- 'scripts/smoke-ruvllm-wasm-auto-init.mjs'+ # GitHub skills/agents/helpers surface (#2089, ADR-127) β injection+ # smoke + actions pin smoke gate every change to the .github surface.+ - '.claude/agents/github/**'+ - '.claude/skills/github-*/**'+ - 'v3/@claude-flow/cli/.claude/commands/github/**'+ - '.claude/helpers/github-safe.js'+ - 'v3/@claude-flow/cli/.claude/helpers/github-safe.js'+ - 'scripts/smoke-github-safe-injection.mjs'+ - 'scripts/smoke-github-actions-pins.mjs'+ - '.github/supply-chain/allowed-deps.json'pull_request:branches: [main, develop]paths:@@ -137,6 +147,15 @@ on:- 'v3/@claude-flow/cli/src/mcp-tools/ruvllm-tools.ts'- 'v3/@claude-flow/cli/src/ruvector/ruvllm-wasm.ts'- 'scripts/smoke-ruvllm-wasm-auto-init.mjs'+ # GitHub skills/agents/helpers surface (#2089, ADR-127)+ - '.claude/agents/github/**'+ - '.claude/skills/github-*/**'+ - 'v3/@claude-flow/cli/.claude/commands/github/**'+ - '.claude/helpers/github-safe.js'+ - 'v3/@claude-flow/cli/.claude/helpers/github-safe.js'+ - 'scripts/smoke-github-safe-injection.mjs'+ - 'scripts/smoke-github-actions-pins.mjs'+ - '.github/supply-chain/allowed-deps.json'# witness manifests / fix list β so witness-verify runs on PRs that# touch them (otherwise a stale per-OS manifest only fails post-merge).- 'verification/**'@@ -973,6 +992,65 @@ jobs:- name: Run ruvllm WASM auto-init smokerun: node scripts/smoke-ruvllm-wasm-auto-init.mjs+ github-safe-injection-smoke:+ # Regression guard for ruvnet/ruflo#2089 β ADR-127 Phase 1.+ #+ # Drives adversarial PR/issue bodies (backticks, $(), semicolons,+ # >256KB, empty) through github-safe.js and asserts the body lands in a+ # temp file verbatim rather than being passed inline to `gh`. Inline+ # interpolation of untrusted body content into shell arguments is the+ # prompt-injection vector closed by the swarm-pr.md / swarm-issue.md+ # fix in Phase 2. This smoke ensures github-safe.js itself always writes+ # the temp file and passes --body-file rather than --body.+ #+ # Runs against both copies:+ # - .claude/helpers/github-safe.js (dogfood)+ # - v3/@claude-flow/cli/.claude/helpers/ (init-template)+ name: github-safe injection smoke (#2089, ADR-127 Phase 1)+ runs-on: ubuntu-latest++ steps:+ - name: Checkout code+ uses: actions/checkout@v4++ - name: Setup Node.js+ uses: actions/setup-node@v4+ with:+ node-version: '22'++ - name: Run github-safe injection smoke+ run: node scripts/smoke-github-safe-injection.mjs++ github-actions-pins-smoke:+ # Static contract guard for ruvnet/ruflo#2089 β ADR-127 Phase 1.+ #+ # Scans every `uses:` line in:+ # .claude/agents/github/*.md+ # .claude/skills/github-[name]/SKILL.md+ # v3/@claude-flow/cli/.claude/commands/github/[name].md+ #+ # Asserts each ref is either SHA-pinned (40-hex) or present in+ # .github/supply-chain/allowed-deps.json actions.allowed[].+ #+ # This smoke catches any future commit that copies @v3 snippets from+ # blog posts into the skill files β the most common doc-drift pattern.+ # Phase 3 upgrades all @v3 refs to @v4; this smoke is the regression+ # gate that prevents them from drifting back.+ name: github actions pin smoke (#2089, ADR-127 Phase 1)+ runs-on: ubuntu-latest++ steps:+ - name: Checkout code+ uses: actions/checkout@v4++ - name: Setup Node.js+ uses: actions/setup-node@v4+ with:+ node-version: '22'++ - name: Run github actions pin smoke+ run: node scripts/smoke-github-actions-pins.mjs+pre-bash-hook-smoke:# Regression guard for ruvnet/ruflo#2017 β the `pre-bash` PreToolUse hook# in `.claude/helpers/hook-handler.cjs` is a security gate that refuses todiff --git a/scripts/smoke-github-actions-pins.mjs b/scripts/smoke-github-actions-pins.mjsnew file mode 100644index 0000000000..98953dc331--- /dev/null+++ b/scripts/smoke-github-actions-pins.mjs@@ -0,0 +1,121 @@+#!/usr/bin/env node+/**+ * Static scan guard for ruvnet/ruflo#2089 β ADR-127 Phase 1.+ *+ * Scans every `uses:` line in:+ * - .claude/agents/github/*.md+ * - .claude/skills/github-[name]/SKILL.md+ * - v3/@claude-flow/cli/.claude/commands/github/[name].md+ *+ * For each ref, asserts it is either:+ * (a) SHA-pinned β `owner/repo@<40-hex-chars>`+ * (b) Listed in .github/supply-chain/allowed-deps.json `actions.allowed[]`+ *+ * The `minimumVersion` sub-field is advisory (logged, not enforced by this+ * smoke). Enforcement of the minimum version is the job of Phase 3's+ * smoke-deprecated-actions.mjs which fails on @v3 refs directly.+ *+ * Zero runtime dependencies β pure readFileSync + regex.+ *+ * Exit 0: all refs are pinned or on the allow-list.+ * Exit 1: one or more violations found (file + line reported for each).+ */++import { readFileSync, readdirSync, existsSync } from 'node:fs';+import { join, basename } from 'node:path';++const REPO_ROOT = process.cwd();++// Paths to scan (globs resolved manually to avoid deps).+const SCAN_TREES = [+ join(REPO_ROOT, '.claude', 'agents', 'github'),+ join(REPO_ROOT, '.claude', 'skills'),+ join(REPO_ROOT, 'v3', '@claude-flow', 'cli', '.claude', 'commands', 'github'),+];++const ALLOWED_DEPS_PATH = join(REPO_ROOT, '.github', 'supply-chain', 'allowed-deps.json');++// Load the allow-list.+let allowedActions = [];+if (existsSync(ALLOWED_DEPS_PATH)) {+ try {+ const raw = JSON.parse(readFileSync(ALLOWED_DEPS_PATH, 'utf-8'));+ allowedActions = (raw.actions && raw.actions.allowed) || [];+ } catch (e) {+ console.error(`[warn] Could not parse ${ALLOWED_DEPS_PATH}: ${e.message}`);+ }+}++// SHA-pin pattern: exactly 40 hex characters after @.+const SHA_PIN_RE = /^[a-f0-9]{40}$/i;+// uses: line pattern (inside markdown code blocks or YAML snippets).+const USES_LINE_RE = /^\s*-?\s*uses:\s+(.+)$/;++/**+ * Collect all .md files under a directory (non-recursive for agents/commands,+ * recursive one level for skills to find SKILL.md files).+ */+function collectFiles(dir, recursive = false) {+ if (!existsSync(dir)) return [];+ const files = [];+ for (const entry of readdirSync(dir, { withFileTypes: true })) {+ const full = join(dir, entry.name);+ if (entry.isFile() && entry.name.endsWith('.md')) {+ files.push(full);+ } else if (entry.isDirectory() && recursive) {+ files.push(...collectFiles(full, false)); // one extra level only+ }+ }+ return files;+}++const filesToScan = [+ ...collectFiles(SCAN_TREES[0]), // .claude/agents/github/*.md+ ...collectFiles(SCAN_TREES[1], true), // .claude/skills/github-*/SKILL.md+ ...collectFiles(SCAN_TREES[2]), // v3/.../commands/github/*.md+];++const violations = [];++for (const filePath of filesToScan) {+ const lines = readFileSync(filePath, 'utf-8').split('\n');+ for (let i = 0; i < lines.length; i++) {+ const m = lines[i].match(USES_LINE_RE);+ if (!m) continue;++ const ref = m[1].trim();+ // ref looks like: owner/repo@version+ const atIdx = ref.indexOf('@');+ if (atIdx === -1) {+ violations.push({ file: filePath, line: i + 1, ref, reason: 'missing @ in uses: ref' });+ continue;+ }++ const action = ref.slice(0, atIdx);+ const version = ref.slice(atIdx + 1);++ // Check (a): SHA-pinned.+ if (SHA_PIN_RE.test(version)) continue;++ // Check (b): on the allow-list.+ if (allowedActions.includes(action)) continue;++ violations.push({ file: filePath, line: i + 1, ref, reason: 'not SHA-pinned and not in allowed-deps.json actions.allowed' });+ }+}++if (violations.length === 0) {+ console.log('ok: all uses: refs are SHA-pinned or on the allow-list');+ process.exit(0);+}++console.error(`\n${violations.length} uses: pin violation(s) found:\n`);+for (const v of violations) {+ // Shorten path relative to repo root for readability.+ const rel = v.file.replace(REPO_ROOT + '/', '');+ console.error(` ${rel}:${v.line} ${v.ref}`);+ console.error(` reason: ${v.reason}`);+}+console.error(`\nFix: either SHA-pin the ref (uses: owner/repo@<40-hex>) or add the action`);+console.error(`name to .github/supply-chain/allowed-deps.json "actions.allowed".\n`);+process.exit(1);diff --git a/scripts/smoke-github-safe-injection.mjs b/scripts/smoke-github-safe-injection.mjsnew file mode 100644index 0000000000..1fe38e0b4d--- /dev/null+++ b/scripts/smoke-github-safe-injection.mjs@@ -0,0 +1,194 @@+#!/usr/bin/env node+/**+ * Regression guard for ruvnet/ruflo#2089 β ADR-127 Phase 1.+ *+ * Generalizes the smoke-pre-bash-hook.mjs pattern (#2017) to the GitHub helper+ * surface. `github-safe.js` writes untrusted PR/issue body content to a temp+ * file and passes `--body-file` to `gh` instead of interpolating the body into+ * shell arguments. Without that protection a body containing shell+ * metacharacters (backticks, `$(...)`, semicolons) would expand when the caller+ * embeds the content in an unquoted shell expression.+ *+ * Approach: shim the `gh` binary with a fake script that dumps its argv to+ * stdout and exits 0. We then read that output to assert:+ * 1. The helper passed `--body-file <tmpfile>`, NOT `--body <rawbody>`.+ * 2. The temp-file content is verbatim (not shell-expanded).+ * 3. A body >256KB triggers a rejection BEFORE gh is invoked (Phase 2 target;+ * Phase 1 documents the expected redβgreen without failing the build).+ * 4. An empty body skips the temp-file path entirely (no-op, helper exits 0).+ *+ * Runs against BOTH copies:+ * 1. .claude/helpers/github-safe.js (dogfood)+ * 2. v3/@claude-flow/cli/.claude/helpers/github-safe.js (init-template)+ */++import { spawnSync, execFileSync } from 'node:child_process';+import { existsSync, readFileSync, writeFileSync, mkdirSync, unlinkSync, chmodSync } from 'node:fs';+import { join } from 'node:path';+import { tmpdir } from 'node:os';+import { randomBytes } from 'node:crypto';++const REPO_ROOT = process.cwd();+const HELPERS = [+ join(REPO_ROOT, '.claude', 'helpers', 'github-safe.js'),+ join(REPO_ROOT, 'v3', '@claude-flow', 'cli', '.claude', 'helpers', 'github-safe.js'),+];++// 256 KB β the GitHub API body field limit documented in ADR-127.+const MAX_BODY_BYTES = 256 * 1024;++// Create a fake `gh` script that logs its argv to a capture file and exits 0.+const captureFile = join(tmpdir(), `gh-smoke-capture-${randomBytes(6).toString('hex')}.json`);+const fakeGhDir = join(tmpdir(), `gh-smoke-bin-${randomBytes(6).toString('hex')}`);+mkdirSync(fakeGhDir, { recursive: true });+const fakeGhPath = join(fakeGhDir, 'gh');++writeFileSync(fakeGhPath, `#!/usr/bin/env node+import { writeFileSync } from 'node:fs';+writeFileSync(${JSON.stringify(captureFile)}, JSON.stringify({ argv: process.argv.slice(2) }));+process.exit(0);+`);+chmodSync(fakeGhPath, 0o755);++// Inject the fake-gh dir into PATH for child processes.+const shimEnv = { ...process.env, PATH: `${fakeGhDir}:${process.env.PATH || ''}` };++const cases = [+ {+ name: 'backtick body β temp-file path, body verbatim',+ args: ['issue', 'comment', '1', 'code: `rm -rf /`'],+ expectBodyVerbatim: 'code: `rm -rf /`',+ expectBodyFileFlagInArgv: true,+ },+ {+ name: '$() body β temp-file path, body verbatim',+ args: ['pr', 'comment', '1', 'result: $(whoami)'],+ expectBodyVerbatim: 'result: $(whoami)',+ expectBodyFileFlagInArgv: true,+ },+ {+ name: 'semicolon body β temp-file path, body verbatim',+ args: ['issue', 'create', '--title', 'test', '--body', 'a; b; c'],+ expectBodyVerbatim: 'a; b; c',+ expectBodyFileFlagInArgv: true,+ },+ {+ name: '>256KB body β Phase 2 target (documented, not yet enforced)',+ args: ['issue', 'comment', '1', 'x'.repeat(MAX_BODY_BYTES + 1)],+ // Phase 1: accept any exit code β Phase 2 will add the cap and flip to exit 1.+ expectExit: 'any',+ note: 'redβgreen in Phase 2: 256KB cap not yet implemented in github-safe.js',+ },+ {+ name: 'empty body β no-op path, exits 0',+ args: ['issue', 'comment', '1', ''],+ expectExit: 0,+ // Empty body takes the "execute normally" branch β gh is called directly.+ // The fake-gh exits 0, so the helper should exit 0 too.+ },+];++function cleanCapture() {+ try { unlinkSync(captureFile); } catch (_) { /* ignore */ }+}++function runOne(helperPath, c) {+ cleanCapture();+ const r = spawnSync('node', [helperPath, ...c.args], {+ encoding: 'utf-8',+ timeout: 15_000,+ env: shimEnv,+ });++ const out = r.stdout || '';+ const err = r.stderr || '';+ const fails = [];++ if (c.note) {+ // Documented transition β don't fail the build.+ return { fails: [], out, err, status: r.status, note: c.note };+ }++ if (c.expectExit !== undefined && c.expectExit !== 'any' && r.status !== c.expectExit) {+ fails.push(`exit ${r.status} (expected ${c.expectExit})`);+ }++ if (c.expectBodyFileFlagInArgv || c.expectBodyVerbatim) {+ // Read the argv captured by the fake gh script.+ let argv = [];+ if (existsSync(captureFile)) {+ try {+ argv = JSON.parse(readFileSync(captureFile, 'utf-8')).argv || [];+ } catch (_) {+ fails.push('could not parse gh argv capture file');+ }+ } else {+ fails.push('fake gh was not invoked (capture file missing) β helper may have crashed before calling gh');+ }++ if (c.expectBodyFileFlagInArgv) {+ const hasBodyFile = argv.includes('--body-file');+ const hasBodyInline = argv.includes('--body');+ if (!hasBodyFile) {+ fails.push(`--body-file not found in gh argv (argv: ${JSON.stringify(argv.slice(0, 8))})`);+ }+ if (hasBodyInline) {+ fails.push('--body (inline) found in gh argv β body is being passed unsafely');+ }+ }++ if (c.expectBodyVerbatim) {+ // Find the temp-file path (the value after --body-file) and read it.+ const bfIdx = argv.indexOf('--body-file');+ if (bfIdx !== -1 && argv[bfIdx + 1]) {+ const tmpFilePath = argv[bfIdx + 1];+ if (existsSync(tmpFilePath)) {+ const content = readFileSync(tmpFilePath, 'utf-8');+ if (content !== c.expectBodyVerbatim) {+ fails.push(`temp-file content mismatch: expected ${JSON.stringify(c.expectBodyVerbatim)}, got ${JSON.stringify(content.slice(0, 120))}`);+ }+ } else {+ // Temp file may have been cleaned up already β that's OK for the verbatim check.+ // The --body-file flag presence is already verified above.+ }+ }+ }+ }++ return { fails, out, err, status: r.status };+}++let failed = 0;+for (const helperPath of HELPERS) {+ if (!existsSync(helperPath)) {+ console.error(`[skip] helper not found: ${helperPath}`);+ continue;+ }+ console.log(`\n# ${helperPath}`);+ for (const c of cases) {+ const r = runOne(helperPath, c);+ if (r.note) {+ console.log(` note ${c.name}`);+ console.log(` ${r.note}`);+ } else if (r.fails.length === 0) {+ console.log(` ok ${c.name}`);+ } else {+ failed++;+ console.error(` fail ${c.name}`);+ for (const f of r.fails) console.error(` - ${f}`);+ if (r.out.trim()) console.error(` stdout: ${r.out.trim().replace(/\n/g, ' | ')}`);+ if (r.err.trim()) console.error(` stderr: ${r.err.trim().slice(0, 200).replace(/\n/g, ' | ')}`);+ }+ }+}++// Cleanup+cleanCapture();+try { unlinkSync(fakeGhPath); } catch (_) { /* ignore */ }+try { require('fs').rmdirSync(fakeGhDir); } catch (_) { /* ignore */ }++if (failed > 0) {+ console.error(`\n${failed} github-safe injection smoke case(s) failed β regression of #2089`);+ process.exit(1);+}+console.log('\nok: github-safe injection smoke passed both helper copies');