(request: HttpClientRequest.HttpClientRequest)
| 164 | }) |
| 165 | |
| 166 | const secretValues = (request: HttpClientRequest.HttpClientRequest) => { |
| 167 | const values = new Set<string>() |
| 168 | const add = (value: string) => { |
| 169 | if (value.length < 4) return |
| 170 | values.add(value) |
| 171 | values.add(encodeURIComponent(value)) |
| 172 | } |
| 173 | |
| 174 | Object.entries(request.headers).forEach(([name, value]) => { |
| 175 | if (!isSensitiveHeaderName(name)) return |
| 176 | add(value) |
| 177 | const bearer = /^Bearer\s+(.+)$/i.exec(value)?.[1] |
| 178 | if (bearer) add(bearer) |
| 179 | }) |
| 180 | |
| 181 | if (!URL.canParse(request.url)) return values |
| 182 | new URL(request.url).searchParams.forEach((value, key) => { |
| 183 | if (isSensitiveQueryName(key)) add(value) |
| 184 | }) |
| 185 | return values |
| 186 | } |
| 187 | |
| 188 | // Two passes: structural (redact `"name": "value"` and `name=value` patterns |
| 189 | // for any field name that looks sensitive) plus literal (replace any actual |
no test coverage detected