diff --git a/src/agent-audit.test.ts b/src/agent-audit.test.ts index 3b6eb7fd..9382b244 100644 --- a/src/agent-audit.test.ts +++ b/src/agent-audit.test.ts @@ -99,3 +99,26 @@ describe("auditMcpStdio", () => { assert.deepEqual(auditMcpStdio("not json"), []); }); }); + +describe("OpenCode `mcp` container coverage", () => { + it("flags a cleartext http:// remote server nested under `mcp`", () => { + const cfg = JSON.stringify({ + mcp: { + local: { type: "remote", url: "http://mcp.internal:8080" }, + good: { type: "remote", url: "https://mcp.ok" }, + }, + }); + const hits = auditMcpServers(cfg); + assert.equal(hits.length, 1); + assert.match(hits[0], /^local → http:\/\//); + }); + + it("flags an inline-code stdio server nested under `mcp`", () => { + const cfg = JSON.stringify({ + mcp: { evil: { command: "node", args: ["-e", "doBadThings()"] } }, + }); + const hits = auditMcpStdio(cfg); + assert.equal(hits.length, 1); + assert.equal(hits[0].server, "evil"); + }); +}); diff --git a/src/agent-audit.ts b/src/agent-audit.ts index 907b02fc..7787fb4d 100644 --- a/src/agent-audit.ts +++ b/src/agent-audit.ts @@ -39,6 +39,7 @@ export function auditMcpServers(json: string): string[] { const containers = [ (obj as { mcpServers?: Record })?.mcpServers, (obj as { servers?: Record })?.servers, + (obj as { mcp?: Record })?.mcp, // OpenCode nests servers under `mcp` ].filter((c): c is Record => !!c && typeof c === "object"); for (const servers of containers) { for (const [name, def] of Object.entries(servers)) { @@ -110,6 +111,7 @@ export function auditMcpStdio(json: string): StdioMcpFinding[] { const containers = [ (obj as { mcpServers?: Record })?.mcpServers, (obj as { servers?: Record })?.servers, + (obj as { mcp?: Record })?.mcp, // OpenCode nests servers under `mcp` ].filter((c): c is Record => !!c && typeof c === "object"); const out: StdioMcpFinding[] = []; for (const servers of containers) { @@ -154,6 +156,13 @@ const CONFIG_FILES = [ ".vscode/mcp.json", ".claude/settings.json", ".claude/settings.local.json", + // OpenCode (project config carries an `mcp` block) + Codex CLI. secrets-in-config + // is format-agnostic (findSecrets reads raw text); the JSON-shaped MCP checks + // simply no-op on the TOML files. + "opencode.json", + "opencode.jsonc", + ".codex/config.toml", + ".codex/config.json", ]; const HOOK_DIRS = [".git/hooks", ".githooks", ".husky"]; diff --git a/src/scan-transcripts.test.ts b/src/scan-transcripts.test.ts index c457e4ff..f957e2af 100644 --- a/src/scan-transcripts.test.ts +++ b/src/scan-transcripts.test.ts @@ -66,4 +66,17 @@ describe("scanTranscripts", () => { rmSync(dir, { recursive: true, force: true }); } }); + + it("scans the Codex CLI .codex dir", async () => { + const dir = makeRepo(); + try { + mkdirSync(join(dir, ".codex"), { recursive: true }); + writeFileSync(join(dir, ".codex", "session.jsonl"), '{"text":"AKIA0123456789ABCDEF"}\n'); + const hits = await scanTranscripts(dir); + assert.equal(hits.length, 1); + assert.ok(hits[0].file.includes(".codex")); + } finally { + rmSync(dir, { recursive: true, force: true }); + } + }); }); diff --git a/src/scan-transcripts.ts b/src/scan-transcripts.ts index ac5b4395..a977d07c 100644 --- a/src/scan-transcripts.ts +++ b/src/scan-transcripts.ts @@ -14,6 +14,7 @@ import { findSecrets, type SecretFinding } from "./utils/redactSecrets.js"; * Scans: * - `/.claude/` — project-local Claude Code state * - `/.opencode/` — OpenCode local state + * - `/.codex/` — Codex CLI local state * - `~/.claude/projects//` — global Claude Code project cache * - `~/.claude/projects/-/` — same, with normalized slashes * @@ -72,17 +73,18 @@ export async function scanTranscripts(cwd: string = process.cwd()): Promise