-
Notifications
You must be signed in to change notification settings - Fork 7
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
Shard 1426 #128
base: dev
Are you sure you want to change the base?
Shard 1426 #128
Conversation
…pared statment for better code readability, higher performance sql injection proof queries to db
if (config.VERBOSE) { | ||
Logger.mainLogger.debug('Account accounts', accounts ? accounts.length : accounts, 'skip', skip) | ||
Logger.mainLogger.debug('Account accounts', accounts.length, 'skip', skip, 'limit', limit); |
Check warning
Code scanning / CodeQL
Log injection Medium
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 4 hours ago
To fix the problem, we need to sanitize the skip
parameter before logging it. This can be done by removing any newline characters from the skip
parameter using String.prototype.replace
. This ensures that the log entry cannot be manipulated by injecting special characters.
- In the file
src/dbstore/accounts.ts
, sanitize theskip
parameter before logging it. - Add a utility function to sanitize user input by removing newline characters.
- Use this utility function to sanitize the
skip
parameter before logging it.
-
Copy modified lines R234-R235
@@ -233,3 +233,4 @@ | ||
if (config.VERBOSE) { | ||
Logger.mainLogger.debug('Account accounts', accounts.length, 'skip', skip, 'limit', limit); | ||
const sanitizedSkip = String(skip).replace(/\n|\r/g, ""); | ||
Logger.mainLogger.debug('Account accounts', accounts.length, 'skip', sanitizedSkip, 'limit', limit); | ||
} |
if (config.VERBOSE) { | ||
Logger.mainLogger.debug('Updated cycle for counter', cycle.cycleRecord.counter, cycle.cycleMarker) | ||
Logger.mainLogger.debug('Updated cycle for counter', cycle.counter, marker); |
Check warning
Code scanning / CodeQL
Log injection Medium
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 3 hours ago
To fix the log injection issue, we need to sanitize the cycle.counter
value before logging it. Specifically, we should remove any newline characters from the cycle.counter
value to prevent log injection attacks. This can be done using the String.prototype.replace
method.
-
Copy modified lines R91-R92
@@ -90,3 +90,4 @@ | ||
if (config.VERBOSE) { | ||
Logger.mainLogger.debug('Updated cycle for counter', cycle.counter, marker); | ||
const sanitizedCounter = String(cycle.counter).replace(/\n|\r/g, ""); | ||
Logger.mainLogger.debug('Updated cycle for counter', sanitizedCounter, marker); | ||
} |
if (config.VERBOSE) { | ||
Logger.mainLogger.debug('Updated cycle for counter', cycle.cycleRecord.counter, cycle.cycleMarker) | ||
Logger.mainLogger.debug('Updated cycle for counter', cycle.counter, marker); |
Check warning
Code scanning / CodeQL
Log injection Medium
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 3 hours ago
To fix the log injection issue, we need to sanitize the marker
variable before logging it. This can be done by removing any newline characters from the marker
string using String.prototype.replace
. This ensures that user input cannot inject new log entries.
-
Copy modified lines R91-R92
@@ -90,3 +90,4 @@ | ||
if (config.VERBOSE) { | ||
Logger.mainLogger.debug('Updated cycle for counter', cycle.counter, marker); | ||
const sanitizedMarker = marker.replace(/\n|\r/g, ""); | ||
Logger.mainLogger.debug('Updated cycle for counter', cycle.counter, sanitizedMarker); | ||
} |
Logger.mainLogger.error(e) | ||
Logger.mainLogger.error('Unable to update Cycle', cycle.cycleMarker) | ||
Logger.mainLogger.error(e); | ||
Logger.mainLogger.error('Unable to update Cycle', marker); |
Check warning
Code scanning / CodeQL
Log injection Medium
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 2 hours ago
To fix the log injection issue, we need to sanitize the marker
variable before logging it. This can be done by removing any newline characters from the marker
string. We will use the String.prototype.replace
method to achieve this. The changes will be made in the updateCycle
function in the src/dbstore/cycles.ts
file.
-
Copy modified lines R95-R96
@@ -94,3 +94,4 @@ | ||
Logger.mainLogger.error(e); | ||
Logger.mainLogger.error('Unable to update Cycle', marker); | ||
const sanitizedMarker = marker.replace(/\n|\r/g, ""); | ||
Logger.mainLogger.error('Unable to update Cycle', sanitizedMarker); | ||
} |
} | ||
|
||
if (config.VERBOSE) { | ||
Logger.mainLogger.debug('Receipt receipts', receipts.length, 'skip', skip); |
Check warning
Code scanning / CodeQL
Log injection Medium
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 3 hours ago
To fix the problem, we need to sanitize the skip
parameter before logging it. This can be done by converting the skip
parameter to a string and removing any newline characters. This ensures that the log entry cannot be manipulated by injecting special characters.
- In the
queryReceipts
function, sanitize theskip
parameter before logging it. - Use
String.prototype.replace
to remove any newline characters from theskip
parameter. - Ensure that the sanitized
skip
parameter is used in the log statement.
-
Copy modified lines R268-R269
@@ -267,3 +267,4 @@ | ||
if (config.VERBOSE) { | ||
Logger.mainLogger.debug('Receipt receipts', receipts.length, 'skip', skip); | ||
const sanitizedSkip = String(skip).replace(/\n|\r/g, ""); | ||
Logger.mainLogger.debug('Receipt receipts', receipts.length, 'skip', sanitizedSkip); | ||
} |
'Transaction transactions', | ||
transactions ? transactions.length : transactions, | ||
'skip', | ||
skip |
Check warning
Code scanning / CodeQL
Log injection Medium
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 3 hours ago
To fix the log injection issue, we need to sanitize the skip
parameter before logging it. Specifically, we should remove any newline characters from the skip
parameter to prevent log injection. This can be done using String.prototype.replace
to ensure no line endings are present in the user input.
-
Copy modified line R203 -
Copy modified line R208
@@ -202,2 +202,3 @@ | ||
if (config.VERBOSE) { | ||
const sanitizedSkip = String(skip).replace(/\n|\r/g, ""); | ||
Logger.mainLogger.debug( | ||
@@ -206,3 +207,3 @@ | ||
'skip', | ||
skip | ||
sanitizedSkip | ||
); |
Added prepared statements everywhere in archiver
now it's faster and secured against sql injections