-
Notifications
You must be signed in to change notification settings - Fork 5
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 a seperate logger for worker processes #87
base: dev
Are you sure you want to change the base?
Conversation
PR Reviewer Guide 🔍
|
// Set interval to check receipt count every 15 seconds | ||
setInterval(async () => { | ||
for (const [, worker] of newWorkers) { | ||
worker.kill() | ||
} | ||
if (receiptLoadTraker < config.receiptLoadTrakerLimit) { | ||
if (config.workerProcessesDebugLog) | ||
console.log(`Receipt load is below the limit: ${receiptLoadTraker}/${config.receiptLoadTrakerLimit}`) | ||
Logger.workerProcessLogger.debug(`Receipt load is below the limit: ${receiptLoadTraker}/${config.receiptLoadTrakerLimit}`) |
Check warning
Code scanning / CodeQL
Log injection Medium
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 3 months ago
To fix the log injection issue, we need to sanitize the user-provided values before logging them. Specifically, we should remove any newline characters from the config.receiptLoadTrakerLimit
value before it is included in the log message. This can be done using String.prototype.replace
to ensure no line endings are present in the user input.
-
Copy modified lines R51-R54
@@ -50,4 +50,6 @@ | ||
if (receiptLoadTraker < config.receiptLoadTrakerLimit) { | ||
if (config.workerProcessesDebugLog) | ||
Logger.workerProcessLogger.debug(`Receipt load is below the limit: ${receiptLoadTraker}/${config.receiptLoadTrakerLimit}`) | ||
if (config.workerProcessesDebugLog) { | ||
const sanitizedLimit = String(config.receiptLoadTrakerLimit).replace(/\n|\r/g, ""); | ||
Logger.workerProcessLogger.debug(`Receipt load is below the limit: ${receiptLoadTraker}/${sanitizedLimit}`) | ||
} | ||
// Kill the extra workers from the end of the array |
@@ -1,7 +1,7 @@ | |||
{ | |||
"saveConsoleOutput": true, | |||
"dir": "archiver-logs", | |||
"files": { "main": "", "fatal": "", "net": "" }, | |||
"files": { "main": "", "fatal": "", "net": "", "workerProcess": "" }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we give the name as workerHandler instead? I think since it's more about the debug logs by the main process handling the worker processes.
No description provided.