-
Notifications
You must be signed in to change notification settings - Fork 155
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
Sale notifications #509
base: main
Are you sure you want to change the base?
Sale notifications #509
Conversation
@@ -14,7 +14,7 @@ | |||
metadata, | |||
}); | |||
} else { | |||
console.error(severityError, message, metadata); | |||
console.error(severityInfo, message, metadata); |
Check warning
Code scanning / CodeQL
Log injection Medium
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 4 months ago
To fix the log injection issue, we need to sanitize the user input before logging it. Specifically, we should remove any newline characters from the message
parameter to prevent log injection. This can be done using the String.prototype.replace
method to replace newline characters with an empty string.
We will apply this sanitization in the info
, warn
, and error
functions in the apps/web/services/logger.ts
file to ensure that all log messages are sanitized before being logged.
-
Copy modified lines R10-R11 -
Copy modified line R15 -
Copy modified line R19 -
Copy modified lines R27-R28 -
Copy modified line R32 -
Copy modified line R36 -
Copy modified lines R48-R49 -
Copy modified line R53 -
Copy modified line R57
@@ -9,2 +9,4 @@ | ||
) => { | ||
// Sanitize message to remove newline characters | ||
const sanitizedMessage = message.replace(/\n|\r/g, ""); | ||
if (process.env.NODE_ENV === "production") { | ||
@@ -12,3 +14,3 @@ | ||
severity: severityInfo, | ||
message, | ||
message: sanitizedMessage, | ||
metadata, | ||
@@ -16,3 +18,3 @@ | ||
} else { | ||
console.error(severityInfo, message, metadata); | ||
console.error(severityInfo, sanitizedMessage, metadata); | ||
} | ||
@@ -24,2 +26,4 @@ | ||
) => { | ||
// Sanitize message to remove newline characters | ||
const sanitizedMessage = message.replace(/\n|\r/g, ""); | ||
if (process.env.NODE_ENV === "production") { | ||
@@ -27,3 +31,3 @@ | ||
severity: severityWarn, | ||
message, | ||
message: sanitizedMessage, | ||
metadata, | ||
@@ -31,3 +35,3 @@ | ||
} else { | ||
console.error(severityError, message, metadata); | ||
console.error(severityError, sanitizedMessage, metadata); | ||
} | ||
@@ -43,2 +47,4 @@ | ||
) => { | ||
// Sanitize message to remove newline characters | ||
const sanitizedMessage = message.replace(/\n|\r/g, ""); | ||
if (process.env.NODE_ENV === "production") { | ||
@@ -46,3 +52,3 @@ | ||
severity: severityError, | ||
message, | ||
message: sanitizedMessage, | ||
metadata, | ||
@@ -50,3 +56,3 @@ | ||
} else { | ||
console.error(severityError, message, metadata); | ||
console.error(severityError, sanitizedMessage, metadata); | ||
} |
Fixes #364