Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(redact): mask Notion integration tokens (ntn_)
kevin93272f3076e8fb40
diff --git a/server/redact.test.ts b/server/redact.test.tsindex 430e089e2a..71d2fd97c7 100644--- a/server/redact.test.ts+++ b/server/redact.test.ts@@ -181,6 +181,17 @@ describe("redactSecretsInText", () => {}});+ it("masks Notion integration tokens", () => {+ // ntn_ plus 46 letters and digits, assembled at runtime like the cases above.+ const token = `${"nt" + "n_"}${"0123456789A"}${"bcdefghijklmnopqrstuvwxyzABCDEFGHIJ"}`;+ expect(redactSecretsInText(`notion ${token} connected`)).toBe(`notion «redacted ${token.length} chars» connected`);+ expect(holdsCredential(`header Notion ${token}`)).toBe(true);+ for (const ordinary of ["ntn_example", `${"nt" + "n_"}${"a".repeat(39)}`, `example_${"nt" + "n_"}${"a".repeat(46)}`]) {+ expect(redactSecretsInText(ordinary)).toBe(ordinary);+ expect(holdsCredential(ordinary)).toBe(false);+ }+ });+it.each([["xai-", 20],["gsk_", 40],diff --git a/shared/redact.ts b/shared/redact.tsindex f5c276d43e..d0fa47f644 100644--- a/shared/redact.ts+++ b/shared/redact.ts@@ -31,6 +31,7 @@ const KEY_PREFIXES: RegExp[] = [/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g, // aws access key id, long-term (AKIA) or temporary STS (ASIA)/\bAIza[0-9A-Za-z_-]{30,}/g, // google api key/\bnpm_[A-Za-z0-9]{20,}/g, // npm+ /\bntn_[A-Za-z0-9]{46}(?![A-Za-z0-9_-])/g, // notion integration tokens/\bwhsec_[A-Za-z0-9_-]{20,}/g, // webhook secrets, alone or in an automation's address/\bSG\.[A-Za-z0-9_-]{22}\.[A-Za-z0-9_-]{43}(?![A-Za-z0-9_-])/g, // sendgrid api keys/\bbak_[A-Za-z0-9_-]{20,}/g, // Bot API keys