(value: string)
| 164 | } |
| 165 | |
| 166 | function redactSecretString(value: string): string { |
| 167 | // Apply the shared comprehensive redactor (OpenCode parity: adds |
| 168 | // github_pat_/ghp_/hf_/AKIA/Slack/Google/JWT and generic key=value forms that |
| 169 | // the bespoke version leaked) AND then the original looser patterns as a |
| 170 | // SUPERSET — the shared `sk-` pattern requires 32+ chars (real key length), |
| 171 | // so keep the looser `sk-{12,}` here too so short/synthetic sk- tokens are |
| 172 | // still caught. Redaction is safer over-broad than under. |
| 173 | return redactSecretText(value) |
| 174 | .replace(/Bearer\s+[A-Za-z0-9._~+\-/=]+/g, "Bearer <REDACTED>") |
| 175 | .replace(/sk-[A-Za-z0-9_-]{12,}/g, "sk-<REDACTED>") |
| 176 | .replace(/api[_-]?key=([^\s&]+)/gi, "api_key=<REDACTED>") |
| 177 | .replace(/token=([^\s&]+)/gi, "token=<REDACTED>"); |
| 178 | } |
| 179 | |
| 180 | /** |
| 181 | * Sanitize paths, usernames, and obvious secret material before writing issue |
no test coverage detected