Skip to content
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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Sale notifications #509

wants to merge 5 commits into from

Conversation

ravirajput10
Copy link
Contributor

@ravirajput10 ravirajput10 commented Oct 17, 2024

Fixes #364

@ravirajput10 ravirajput10 self-assigned this Oct 17, 2024
@@ -14,7 +14,7 @@
metadata,
});
} else {
console.error(severityError, message, metadata);
console.error(severityInfo, message, metadata);

Check warning

Code scanning / CodeQL

Log injection Medium

Log entry depends on a
user-provided value
.

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.

Suggested changeset 1
apps/web/services/logger.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/apps/web/services/logger.ts b/apps/web/services/logger.ts
--- a/apps/web/services/logger.ts
+++ b/apps/web/services/logger.ts
@@ -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);
     }
EOF
@@ -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);
}
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Send an email to the admins when a sale is made
1 participant