-
Notifications
You must be signed in to change notification settings - Fork 2
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
Pass mutations #311
Pass mutations #311
Conversation
✅ Deploy Preview for flickmatch canceled.
|
@@ -53,6 +53,7 @@ | |||
@RequestParam("razorpay_payment_id") String paymentId, | |||
@RequestParam("razorpay_signature") String signature) { | |||
|
|||
log.info("Processing callback for order " + orderId); |
Check failure
Code scanning / CodeQL
Log Injection High
This autofix suggestion was applied.
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 3 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 orderId
to prevent log forging. This can be done using the replace
method to replace newline characters with an empty string. Additionally, we should ensure that the orderId
is clearly marked in the log entry to avoid any confusion.
-
Copy modified lines R56-R57 -
Copy modified line R81 -
Copy modified line R98 -
Copy modified line R131 -
Copy modified line R134
@@ -55,3 +55,4 @@ | ||
|
||
log.info("Processing callback for order " + orderId); | ||
String sanitizedOrderId = orderId.replace("\n", "").replace("\r", ""); | ||
log.info("Processing callback for order {}", sanitizedOrderId); | ||
String uniqueEventId; | ||
@@ -79,3 +80,3 @@ | ||
|
||
log.info("OrderId: {}, PaymentId: {}, Signature: {}", orderId, paymentId, signature); | ||
log.info("OrderId: {}, PaymentId: {}, Signature: {}", sanitizedOrderId, paymentId, signature); | ||
log.info("Secret key: {}", secret); | ||
@@ -96,3 +97,3 @@ | ||
if (orderId.matches("\\w+")) { | ||
log.info("Invalid signature for orderId : " + orderId); | ||
log.info("Invalid signature for orderId : {}", sanitizedOrderId); | ||
} else { | ||
@@ -129,6 +130,6 @@ | ||
if (flag==1) { | ||
headers.add("Location", "https://play.flickmatch.in/event/" + uniqueEventId); | ||
headers.add("Location", "https://play.flickmatch.in/event/" + sanitizedOrderId); | ||
} | ||
else { | ||
headers.add("Location", "https://play.flickmatch.in/match-queues#"+uniqueEventId); | ||
headers.add("Location", "https://play.flickmatch.in/match-queues#" + sanitizedOrderId); | ||
} |
@@ -72,6 +76,11 @@ | |||
// https://razorpay.com/docs/payments/server-integration/java/payment-gateway/build-integration/#generate-signature-on-your-server | |||
|
|||
boolean status = Utils.verifyPaymentSignature(options, secret); | |||
|
|||
log.info("OrderId: {}, PaymentId: {}, Signature: {}", orderId, paymentId, signature); |
Check failure
Code scanning / CodeQL
Log Injection High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 3 months ago
To fix the log injection issue, we need to sanitize the orderId
before logging it. The best way to do this is to remove any potentially harmful characters, such as newlines, from the orderId
. We can use the replace
method to replace newline characters with an empty string. This ensures that the log entry remains a single line and prevents log injection.
-
Copy modified lines R80-R81
@@ -79,3 +79,4 @@ | ||
|
||
log.info("OrderId: {}, PaymentId: {}, Signature: {}", orderId, paymentId, signature); | ||
String sanitizedOrderId = orderId.replace("\n", "").replace("\r", ""); | ||
log.info("OrderId: {}, PaymentId: {}, Signature: {}", sanitizedOrderId, paymentId, signature); | ||
log.info("Secret key: {}", secret); |
@@ -72,6 +76,11 @@ | |||
// https://razorpay.com/docs/payments/server-integration/java/payment-gateway/build-integration/#generate-signature-on-your-server | |||
|
|||
boolean status = Utils.verifyPaymentSignature(options, secret); | |||
|
|||
log.info("OrderId: {}, PaymentId: {}, Signature: {}", orderId, paymentId, signature); |
Check failure
Code scanning / CodeQL
Log Injection High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 3 months ago
To fix the log injection issue, we need to sanitize the paymentId
before logging it. The best way to do this is to remove any potentially harmful characters, such as newlines, that could be used to manipulate the log format. We can use the replaceAll
method to remove such characters.
- Identify the lines where the user-provided
paymentId
is logged. - Sanitize the
paymentId
by replacing newline characters with an empty string. - Ensure that the sanitized
paymentId
is used in the log statements.
-
Copy modified lines R56-R84
@@ -55,29 +55,31 @@ | ||
|
||
log.info("Processing callback for order " + orderId); | ||
String uniqueEventId; | ||
int flag=0; | ||
try { | ||
RazorpayClient razorpay = razorPayProxy.getRazorPayClient(); | ||
JSONObject options = new JSONObject(); | ||
options.put("razorpay_order_id",orderId); | ||
options.put("razorpay_payment_id",paymentId); | ||
options.put("razorpay_signature", signature); | ||
RazorPaymentRequest paymentRequest = paymentRequestBuilder.getPaymentRequest(orderId); | ||
|
||
log.info("Processing callback for email " + paymentRequest.getEmail() + " and uniqueEventId " + paymentRequest.getUniqueEventId()); | ||
|
||
uniqueEventId = paymentRequest.getUniqueEventId(); | ||
|
||
String[] parts =uniqueEventId.split("-"); | ||
String dateStr = parts[1] + "-" + parts[2] + "-" + parts[3]; | ||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); | ||
LocalDate eventDate; | ||
|
||
// https://razorpay.com/docs/payments/server-integration/java/payment-gateway/build-integration/#generate-signature-on-your-server | ||
|
||
boolean status = Utils.verifyPaymentSignature(options, secret); | ||
|
||
log.info("OrderId: {}, PaymentId: {}, Signature: {}", orderId, paymentId, signature); | ||
log.info("Secret key: {}", secret); | ||
log.info("Status: {}", status); | ||
log.info("Processing callback for order " + orderId); | ||
String uniqueEventId; | ||
int flag=0; | ||
// Sanitize paymentId to prevent log injection | ||
paymentId = paymentId.replaceAll("[\\r\\n]", ""); | ||
try { | ||
RazorpayClient razorpay = razorPayProxy.getRazorPayClient(); | ||
JSONObject options = new JSONObject(); | ||
options.put("razorpay_order_id",orderId); | ||
options.put("razorpay_payment_id",paymentId); | ||
options.put("razorpay_signature", signature); | ||
RazorPaymentRequest paymentRequest = paymentRequestBuilder.getPaymentRequest(orderId); | ||
|
||
log.info("Processing callback for email " + paymentRequest.getEmail() + " and uniqueEventId " + paymentRequest.getUniqueEventId()); | ||
|
||
uniqueEventId = paymentRequest.getUniqueEventId(); | ||
|
||
String[] parts =uniqueEventId.split("-"); | ||
String dateStr = parts[1] + "-" + parts[2] + "-" + parts[3]; | ||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); | ||
LocalDate eventDate; | ||
|
||
// https://razorpay.com/docs/payments/server-integration/java/payment-gateway/build-integration/#generate-signature-on-your-server | ||
|
||
boolean status = Utils.verifyPaymentSignature(options, secret); | ||
|
||
log.info("OrderId: {}, PaymentId: {}, Signature: {}", orderId, paymentId, signature); | ||
log.info("Secret key: {}", secret); | ||
log.info("Status: {}", status); | ||
|
@@ -72,6 +76,11 @@ | |||
// https://razorpay.com/docs/payments/server-integration/java/payment-gateway/build-integration/#generate-signature-on-your-server | |||
|
|||
boolean status = Utils.verifyPaymentSignature(options, secret); | |||
|
|||
log.info("OrderId: {}, PaymentId: {}, Signature: {}", orderId, paymentId, signature); |
Check failure
Code scanning / CodeQL
Log Injection High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 3 months ago
To fix the log injection issue, we need to sanitize the signature
parameter before logging it. The best way to do this is to remove any potentially harmful characters, such as newlines, that could be used to manipulate the log format. We can use the replace
method to replace newline characters with an empty string. This ensures that the log entry remains a single line and prevents log injection.
-
Copy modified lines R80-R81
@@ -79,3 +79,4 @@ | ||
|
||
log.info("OrderId: {}, PaymentId: {}, Signature: {}", orderId, paymentId, signature); | ||
String sanitizedSignature = signature.replace("\n", "").replace("\r", ""); | ||
log.info("OrderId: {}, PaymentId: {}, Signature: {}", orderId, paymentId, sanitizedSignature); | ||
log.info("Secret key: {}", secret); |
@@ -72,6 +76,11 @@ | |||
// https://razorpay.com/docs/payments/server-integration/java/payment-gateway/build-integration/#generate-signature-on-your-server | |||
|
|||
boolean status = Utils.verifyPaymentSignature(options, secret); | |||
|
|||
log.info("OrderId: {}, PaymentId: {}, Signature: {}", orderId, paymentId, signature); | |||
log.info("Secret key: {}", secret); |
Check failure
Code scanning / CodeQL
Insertion of sensitive information into log files High
potentially sensitive information
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 3 months ago
To fix the problem, we need to ensure that sensitive information such as the secret
key is not logged. Instead of logging the actual secret, we can log a placeholder or omit the sensitive information entirely. This change will maintain the logging functionality without exposing sensitive data.
- General Fix: Avoid logging sensitive information directly. Use placeholders or omit the sensitive data.
- Detailed Fix: In the file
platform/src/main/java/com/flickmatch/platform/rest/RazorPaymentCallbackController.java
, replace the log statement on line 81 that logs thesecret
key with a safer alternative. - Specific Changes: Replace the line
log.info("Secret key: {}", secret);
with a placeholder message likelog.info("Secret key: [PROTECTED]");
.
-
Copy modified lines R80-R82
@@ -79,5 +79,5 @@ | ||
|
||
log.info("OrderId: {}, PaymentId: {}, Signature: {}", orderId, paymentId, signature); | ||
log.info("Secret key: {}", secret); | ||
log.info("Status: {}", status); | ||
log.info("OrderId: {}, PaymentId: {}, Signature: {}", orderId, paymentId, signature); | ||
log.info("Secret key: [PROTECTED]"); | ||
log.info("Status: {}", status); | ||
|
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: flickkshitij <[email protected]>
No description provided.