-
Notifications
You must be signed in to change notification settings - Fork 891
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
234 - Set default values on Server Settings if color is not set #235
234 - Set default values on Server Settings if color is not set #235
Conversation
Now getting "Settings updated " message on UI just by navigating to Server settings page. |
const router = Router(); | ||
|
||
router.post( | ||
'/:network/:hash', | ||
requireUserSession, | ||
processUserTransaction | ||
processUserTransaction, |
Check failure
Code scanning / CodeQL
Missing rate limiting High
a database access
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 2 months ago
To fix the problem, we need to introduce rate limiting to the route handler to prevent abuse. The express-rate-limit
package is a well-known library for this purpose. We will:
- Install the
express-rate-limit
package. - Set up a rate limiter with appropriate configuration.
- Apply the rate limiter to the specific route that handles user transactions.
-
Copy modified line R4 -
Copy modified lines R8-R13 -
Copy modified line R16
@@ -3,2 +3,3 @@ | ||
const { processUserTransaction } = require('./transactions.Service'); | ||
const RateLimit = require('express-rate-limit'); | ||
|
||
@@ -6,4 +7,11 @@ | ||
|
||
// set up rate limiter: maximum of 100 requests per 15 minutes | ||
const limiter = RateLimit({ | ||
windowMs: 15 * 60 * 1000, // 15 minutes | ||
max: 100, // max 100 requests per windowMs | ||
}); | ||
|
||
router.post( | ||
'/:network/:hash', | ||
limiter, | ||
requireUserSession, |
-
Copy modified lines R75-R76
@@ -74,3 +74,4 @@ | ||
"winston-transport": "^4.6.0", | ||
"yoti": "^4.6.0" | ||
"yoti": "^4.6.0", | ||
"express-rate-limit": "^7.4.0" | ||
}, |
Package | Version | Security advisories |
express-rate-limit (npm) | 7.4.0 | None |
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.
QA Verified
Closes #234