(content: string)
| 310 | let redactRules: RegExp[] | null = null |
| 311 | |
| 312 | export function redactSecrets(content: string): string { |
| 313 | redactRules ??= SECRET_RULES.map( |
| 314 | r => new RegExp(r.source, (r.flags ?? '').replace('g', '') + 'g'), |
| 315 | ) |
| 316 | for (const re of redactRules) { |
| 317 | // Replace only the captured group, not the full match — patterns include |
| 318 | // boundary chars (space, quote, ;) outside the group that must survive. |
| 319 | content = content.replace(re, (match, g1) => |
| 320 | typeof g1 === 'string' ? match.replace(g1, '[REDACTED]') : '[REDACTED]', |
| 321 | ) |
| 322 | } |
| 323 | return content |
| 324 | } |
| 325 |
nothing calls this directly
no outgoing calls
no test coverage detected