-
Notifications
You must be signed in to change notification settings - Fork 296
feat: new kms api example module branch #6119
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
Conversation
|
||
// parse request | ||
try { | ||
console.log('POST /key', req.body); |
Check warning
Code scanning / CodeQL
Log injection Medium
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 month ago
To fix the issue, we need to sanitize the user-provided input (req.body
) before logging it. Specifically:
- Remove any newline (
\n
) or carriage return (\r
) characters from the input to prevent log injection. - Clearly mark the user input in the log entry to distinguish it from other log data.
This can be achieved by using JSON.stringify
to serialize the req.body
object and then replacing newline and carriage return characters with an empty string. This ensures that the logged data is safe and does not introduce unintended log entries.
-
Copy modified lines R89-R90
@@ -88,3 +88,4 @@ | ||
try { | ||
console.log('POST /key', req.body); | ||
const sanitizedBody = JSON.stringify(req.body).replace(/[\n\r]/g, ''); | ||
console.log('POST /key', sanitizedBody); | ||
ZodPostKeySchema.parse(req.body); |
return; | ||
} | ||
|
||
const { prv, pub, coin, source, type, userKeyProvider, backupKeyProvider } = req.body; |
Check notice
Code scanning / CodeQL
Unused variable, import, function or class Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 month ago
To fix the issue, we should remove the unused variable backupKeyProvider
from the destructuring assignment on line 97. This will eliminate the unnecessary variable and improve code clarity and maintainability. No other changes are required, as the removal of this variable does not affect the functionality of the code.
-
Copy modified line R97
@@ -96,3 +96,3 @@ | ||
|
||
const { prv, pub, coin, source, type, userKeyProvider, backupKeyProvider } = req.body; | ||
const { prv, pub, coin, source, type, userKeyProvider } = req.body; | ||
|
Closing this branch as all the changes were moved to another repo. Thanks. |
Ticket: WP-4379