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 SendGrid API keys (SG.…)
kevin93277dea8644ee98
diff --git a/server/redact.test.ts b/server/redact.test.tsindex ede14c2868..cd5ec69707 100644--- a/server/redact.test.ts+++ b/server/redact.test.ts@@ -168,6 +168,17 @@ describe("redactSecretsInText", () => {}});+ it("masks SendGrid API keys", () => {+ // SG.<22-char key id>.<43-char secret>, assembled at runtime like the cases above.+ const key = `${"S" + "G."}${"abcdefghij0123456789_-"}.${"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghij0123456"}`;+ expect(redactSecretsInText(`sendgrid ${key} sent`)).toBe(`sendgrid «redacted ${key.length} chars» sent`);+ expect(holdsCredential(`mail via ${key}`)).toBe(true);+ for (const ordinary of ["SG.example.com", `${"S" + "G."}${"a".repeat(22)}.${"b".repeat(20)}`, "Use the SG. prefix for the key"]) {+ 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 2b90e8c0fb..8d97bda669 100644--- a/shared/redact.ts+++ b/shared/redact.ts@@ -31,6 +31,7 @@ const KEY_PREFIXES: RegExp[] = [/\bAIza[0-9A-Za-z_-]{30,}/g, // google api key/\bnpm_[A-Za-z0-9]{20,}/g, // npm/\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/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, // jwt];const KEY_PREFIX_TESTS = KEY_PREFIXES.map((re) => new RegExp(re.source));