-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add requestLogger middleware #70
base: dev
Are you sure you want to change the base?
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
`Request URL: ${req.originalUrl} ||` + | ||
` Response Status Code: ${res.statusCode} ||` + | ||
` Sender IP: ${senderIp} ||` + | ||
` Request Timestamp: ${new Date(reqTime).toISOString()} ||` + | ||
` Response Timestamp: ${new Date(resTime).toISOString()} ||` + | ||
` Request Method: ${req.method} ||` + | ||
` Response Time: ${resTime - reqTime}ms ||` + | ||
` User Agent: ${userAgent}` |
Check warning
Code scanning / CodeQL
Log injection Medium
user-provided value
Log entry depends on a
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 2 months ago
To fix the log injection issue, we need to sanitize the userAgent
value before logging it. Specifically, we should remove any newline characters from the userAgent
string to prevent log injection attacks. This can be done using the String.prototype.replace
method to remove any newline characters (\n
and \r
).
-
Copy modified lines R8-R9
@@ -7,3 +7,4 @@ | ||
const senderIp = req.ip | ||
const userAgent = req.headers['user-agent'] || 'Unknown' | ||
let userAgent = req.headers['user-agent'] || 'Unknown' | ||
userAgent = userAgent.replace(/\n|\r/g, "") | ||
|
No description provided.