(request)
| 180 | } |
| 181 | |
| 182 | function getRemoteIPFromRequest(request) { |
| 183 | let remoteIP = null; |
| 184 | if (request.headers) { |
| 185 | // Check for forwarded IP headers (proxy/load balancer scenarios) |
| 186 | const headerRemoteIP = request.headers['x-forwarded-for'] || |
| 187 | request.headers['x-real-ip'] || |
| 188 | request.headers['x-client-ip'] || |
| 189 | request.headers['cf-connecting-ip']; // Cloudflare |
| 190 | |
| 191 | // x-forwarded-for can contain multiple IPs, take the first one |
| 192 | if (headerRemoteIP) { |
| 193 | remoteIP = headerRemoteIP.includes(',') ? headerRemoteIP.split(',')[0].trim() : headerRemoteIP; |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | // Fallback to connection remote address if no forwarded headers |
| 198 | if (!remoteIP) { |
| 199 | const connIP = (request.connection && request.connection.remoteAddress) || |
| 200 | (request.socket && request.socket.remoteAddress) || |
| 201 | (request.ip); |
| 202 | if (connIP) { |
| 203 | remoteIP = connIP; |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | return remoteIP; |
| 208 | } |
| 209 | |
| 210 | // eslint-disable-next-line max-len |
| 211 | // https://github.com/awslabs/glue-extensions-for-iceberg/blob/52bdb2908216a85859fd76a45981d0326d016a2f/spark/src/main/scala/software/amazon/glue/s3a/audit/S3LogVerbs.java |
no outgoing calls
no test coverage detected