Lines 1101-1141javascript
1101 // Generic OpenAI keys incl. newer sk-proj-/sk-svcacct- formats (allow - and _).
1102 { kind: "api_key", re: /\bsk-[A-Za-z0-9][A-Za-z0-9_-]{18,}\b/g, keepTail: 4 },
1103 { kind: "github_token", re: /\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{20,}\b/g, keepTail: 4 },
1104 { kind: "github_token", re: /\bgithub_pat_[A-Za-z0-9_]{20,}\b/g, keepTail: 4 },
1105 { kind: "supabase_key", re: /\bsb(?:p|s|secret)_[A-Za-z0-9_-]{20,}\b/g, keepTail: 4 },
1106 { kind: "jwt", re: /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, keepTail: 4 },
1107 { kind: "private_key", re: /\bAKIA[0-9A-Z]{16}\b/g, keepTail: 4 },
1108 // AWS access key id
1109 { kind: "url_credential", re: /\b([a-z][a-z0-9+.-]*):\/\/[^/\s:@]+:([^/\s@]+)@/gi }
1111var ENV_ASSIGN = /\b([A-Za-z0-9_]*(?:KEY|TOKEN|SECRET|PASSWORD|PASSWD|PWD|CREDENTIAL|PRIVATE)[A-Za-z0-9_]*)\s*=\s*("?)([^"\s]{6,})\2/gi;
1112function fingerprint(value) {
1114 for (let i = 0; i < value.length; i++) {
1115 h ^= value.charCodeAt(i);
1116 h = Math.imul(h, 16777619);
1118 return (h >>> 0).toString(16).padStart(8, "0");
1120function mask(secret, kind, keepTail = 0) {
1121 if (kind === "private_key") return "-----BEGIN PRIVATE KEY----- \u2022\u2022\u2022 [redacted]";
1122 const tail = keepTail > 0 ? secret.slice(-keepTail) : "";
1123 const prefixMatch = secret.match(/^(sk-ant-|sk-|ghp_|gho_|ghu_|ghs_|ghr_|github_pat_|sbp_|sbs_|AKIA)/);
1124 const prefix = prefixMatch ? prefixMatch[0] : "";
1125 return `${prefix}${"\u2022".repeat(8)}${tail}`;
1129 counter = (counter + 1) % 1e6;
1130 return `red_${fingerprint(String(counter) + ":" + Date.now())}`;
1132function redactString(input, fieldPath = "$") {
1133 if (!input) return { text: input, redactions: [] };
1135 const redactions = [];
1136 const apply = (re, kind, keepTail = 0, group) => {
1137 text = text.replace(re, (match, ...args) => {
1138 const secret = group != null ? args[group - 1] : match;
1139 if (!secret) return match;
1140 const replacement = mask(secret, kind, keepTail);