diff --git a/apps/gittensory-ui/src/lib/miner-commands.ts b/apps/gittensory-ui/src/lib/miner-commands.ts index 1a52e809a4..d24de2dc85 100644 --- a/apps/gittensory-ui/src/lib/miner-commands.ts +++ b/apps/gittensory-ui/src/lib/miner-commands.ts @@ -92,7 +92,10 @@ function sanitizeMinerCommand(command: string): string { (_, prefix) => `${prefix}`, ) .replace( - /\b(?:wallet|hotkey|coldkey|mnemonic|raw[-_\s]?trust|private[-_\s]?reviewability|trust[-_\s]?score)\b(?:\s*[:=]\s*(?:"[^"]*"|'[^']*'|[^\s"'`,;)]+))?/gi, + // Only redact actual `term=value` / `term: value` secret leakage. The assignment is required so + // that legitimate login/repo names containing these words (e.g. a repo named "wallet-adapter" or + // login "trust-score" -- already validated upstream) are not corrupted into broken commands. + /\b(?:wallet|hotkey|coldkey|mnemonic|raw[-_\s]?trust|private[-_\s]?reviewability|trust[-_\s]?score)\b\s*[:=]\s*(?:"[^"]*"|'[^']*'|[^\s"'`,;)]+)/gi, "[redacted]", ); } diff --git a/test/unit/miner-dashboard-commands.test.ts b/test/unit/miner-dashboard-commands.test.ts index 35ff31c41e..80bd7c60df 100644 --- a/test/unit/miner-dashboard-commands.test.ts +++ b/test/unit/miner-dashboard-commands.test.ts @@ -88,4 +88,24 @@ describe("miner dashboard command actions", () => { /\/Users|\/home|wallet|hotkey|raw trust|private reviewability/i, ); }); + + it("keeps legitimate repo/login names that contain sensitive words", () => { + const commands = buildMinerCommandActions({ + login: "trust-score", + repoFullName: "metamask/wallet-adapter", + }); + + const preflight = commands.find((command) => command.id === "preflight"); + expect(preflight).toMatchObject({ + command: + "gittensory-mcp preflight --login trust-score --repo metamask/wallet-adapter --base origin/main --json", + copyable: true, + state: "ready", + }); + // The real names survive; nothing is redacted out of a runnable command. + expect(preflight?.command).not.toContain("[redacted]"); + + const plan = commands.find((command) => command.id === "plan"); + expect(plan).toMatchObject({ command: "gittensory-mcp agent plan --login trust-score --json", copyable: true }); + }); });