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 GitLab personal, deploy and runner tokens (#3926)
kevin3a5af9486254
diff --git a/server/redact.test.ts b/server/redact.test.tsindex c32e3213d1..05a563f39d 100644--- a/server/redact.test.ts+++ b/server/redact.test.ts@@ -149,6 +149,11 @@ describe("redactSecretsInText", () => {[`groq ${"gsk_"}${alpha}ABCD`, /gsk_/],[`meta ${"LLM|"}607358788850350|${alpha}`, /LLM\|6073/],[`huggingface ${"hf_"}${alpha}`, /hf_/],+ [`gitlab ${"glp" + "at-"}${alpha.slice(0, 20)}`, /glpat-[a-z]/],+ [`gitlab routable ${"glp" + "at-"}${alpha.slice(0, 27)}.01.0r03gxo7a`, /glpat-[a-z]|r03gxo7a/],+ [`gitlab deploy ${"gld" + "t-"}${alpha.slice(0, 20)}`, /gldt-[a-z]/],+ [`gitlab runner ${"glr" + "t-"}${alpha.slice(0, 20)}`, /glrt-[a-z]/],+ [`gitlab registered runner ${"glr" + "tr-"}${alpha.slice(0, 20)}`, /glrtr-[a-z]/],[`stripe ${"sk_" + "live_"}${alpha}`, /sk_live_[a-z]/],[`stripe test ${"sk_" + "test_"}${alpha}`, /sk_test_[a-z]/],[`stripe restricted ${"rk_" + "live_"}${alpha}`, /rk_live_[a-z]/],@@ -273,11 +278,11 @@ describe("holdsCredential", () => {it("knows a provider key or a private key block, never a name, a placeholder or code that reads one", () => {for (const text of ['{"apiKey": "sk-ant-api03-0123456789abcdefABCD"}', "GITHUB_TOKEN=ghp_0123456789abcdefghij0123", "-----BEGIN OPENSSH PRIVATE KEY-----\nabc\n",- "aws_access_key_id = AKIAABCDEFGHIJKLMNOP", `stripe.secret = "${"sk_" + "live_"}0123456789abcdefABCD"`,+ "aws_access_key_id = AKIAABCDEFGHIJKLMNOP", `git clone https://oauth2:${"glp" + "at-"}[email protected]/x.git`, `runner token ${"glr" + "tr-"}0123456789abcdefABCD`, `stripe.secret = "${"sk_" + "live_"}0123456789abcdefABCD"`,]) expect(holdsCredential(text), text).toBe(true);for (const text of ["token = os.environ['GITHUB_TOKEN']", "API_KEY=your-key-here", "Authorization: Bearer YOUR_TOKEN_HERE", "Keep credentials out of the repo.",- "-----BEGIN PUBLIC KEY-----",+ "-----BEGIN PUBLIC KEY-----", "GITLAB_TOKEN=glpat-your-token-here",]) expect(holdsCredential(text), text).toBe(false);});});diff --git a/shared/redact.ts b/shared/redact.tsindex 97ba27e52b..352ff7e6aa 100644--- a/shared/redact.ts+++ b/shared/redact.ts@@ -24,6 +24,7 @@ const KEY_PREFIXES: RegExp[] = [/\bhf_[A-Za-z0-9]{30,}/g, // hugging face/\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{20,}/g, // github classic/\bgithub_pat_[A-Za-z0-9_]{20,}/g, // github fine-grained+ /\bgl(?:pat|dt|rtr?)-[A-Za-z0-9_-]{20,}(?:\.[A-Za-z0-9_-]+)*/g, // gitlab personal, deploy and runner tokens (routable ones carry .-parts)/\bxox[abposr]-[A-Za-z0-9-]{20,}/g, // slack/\bAKIA[0-9A-Z]{16}\b/g, // aws access key id/\bAIza[0-9A-Za-z_-]{30,}/g, // google api key