Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(redact): require PyPI's 85-character minimum for pypi- tokens

kevin09856b05bd3e
diff --git a/server/redact.test.ts b/server/redact.test.ts
index aa00279f01..d91bf41eff 100644
--- a/server/redact.test.ts
+++ b/server/redact.test.ts
@@ -291,13 +291,13 @@ describe("redactSecretsInText", () => {
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 [
- `TWINE_PASSWORD: ${"py" + "pi-"}AgENdGVzdC5weXBpLm9yZwIkMDAwMDAwMDAtMDAwMC0wMDAwLTAwMDAtMDAwMDAwMDAwMDAw`,
+ `TWINE_PASSWORD: ${"py" + "pi-"}AgENdGVzdC5weXBpLm9yZwIkMDAwMDAwMDAtMDAwMC0wMDAwLTAwMDAtMDAwMDAwMDAwMDAwAAIqWzMsImFiY2RlZiJdAAAGIA`,
'{"apiKey": "sk-ant-api03-0123456789abcdefABCD"}', "GITHUB_TOKEN=ghp_0123456789abcdefghij0123", "-----BEGIN OPENSSH PRIVATE KEY-----\nabc\n",
"aws_access_key_id = AKIAABCDEFGHIJKLMNOP", `git clone https://oauth2:${"glp" + "at-"}[email protected]/x.git`, `runner token ${"glr" + "tr-"}0123456789abcdefABCD`, `SLACK_APP_TOKEN: ${"xa" + "pp-"}1-A0123456789-1234567890123-abcdef0123456789`, `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-----", "GITLAB_TOKEN=glpat-your-token-here",
+ "-----BEGIN PUBLIC KEY-----", "GITLAB_TOKEN=glpat-your-token-here", `release notes mention ${"py" + "pi-"}AgE${"x".repeat(60)}`,
]) expect(holdsCredential(text), text).toBe(false);
});
});
diff --git a/shared/redact.ts b/shared/redact.ts
index 70fdfc8e36..1bfc9581f0 100644
--- a/shared/redact.ts
+++ b/shared/redact.ts
@@ -22,7 +22,7 @@ const KEY_PREFIXES: RegExp[] = [
/\bcsk-[A-Za-z0-9]{32,}/g, // cerebras
/\bLLM\|\d{6,}\|[A-Za-z0-9_-]{16,}/g, // meta model api
/\bhf_[A-Za-z0-9]{30,}/g, // hugging face
- /\bpypi-AgE[A-Za-z0-9_-]{50,}/g, // pypi and testpypi api tokens (macaroons)
+ /\bpypi-AgE[A-Za-z0-9_-]{82,}/g, // pypi and testpypi api tokens (macaroons)
/\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)