Conversation
…up-idle fix: test expectations for idle user
* feat: enhance application scoring and update validation - Added score handling in nudgeApplication logic to increment score on nudging. - Updated application creation to set an initial score of 50. - Enhanced application update validation to include optional fields: firstName, lastName, college, skills, city, state, country, and role. - Improved integration tests to verify score updates and application modifications. - Adjusted unit tests to reflect changes in application scoring logic. * feat: introduce application scoring system and update application queries * test: refactor application update test for invalid role handling * refactor: remove firstName and lastName from application update validation and tests * refactor: rename 'college' to 'institution' in application validation, service, and tests
| router.post("/picture", authenticate, checkIsVerifiedDiscord, upload.single("profile"), users.postUserPicture); | ||
| router.post( | ||
| "/picture", | ||
| authenticate, |
Check failure
Code scanning / CodeQL
Missing rate limiting High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 5 days ago
In general, to fix missing rate limiting on an Express route that performs authentication/authorization and potentially expensive work, you should add a rate-limiting middleware (e.g., via express-rate-limit) before the handler. This middleware should be configured to allow a reasonable number of requests per user/IP in a fixed time window, returning HTTP 429 when exceeded. Applying it specifically to the sensitive route avoids impacting unrelated traffic.
For this code, the least intrusive and clearest fix is to introduce an express-rate-limit middleware in routes/users.js and apply it only to the /picture POST route. That keeps existing functionality unchanged except for enforcing a maximum number of profile picture upload attempts per IP (or per whatever key the rate limiter uses). Concretely:
- Add
const rateLimit = require("express-rate-limit");near the otherrequirestatements. - Define a
const pictureUploadLimiter = rateLimit({...})with a sensiblewindowMsandmaxvalue (e.g., smallish cap such as 10–20 attempts per 15 minutes, which is generous for profile pictures but mitigates DoS). - Insert
pictureUploadLimiterinto the middleware chain forrouter.post("/picture", ...), right afterauthenticate(so only authenticated users are counted, but before actual upload/processing to minimize resource usage on abusive requests).
This addresses all three alert variants, is localized to the shown file, and avoids changing any external behavior other than adding rate limiting.
| @@ -16,7 +16,13 @@ | ||
| const { userAuthorization } = require("../middlewares/userAuthorization"); | ||
| const conditionalMiddleware = require("../middlewares/conditionalMiddleware"); | ||
| const skipWhenApplicationType = require("../middlewares/pictureRouteMiddleware"); | ||
| const rateLimit = require("express-rate-limit"); | ||
|
|
||
| const pictureUploadLimiter = rateLimit({ | ||
| windowMs: 15 * 60 * 1000, // 15 minutes | ||
| max: 20, // limit each IP to 20 picture upload requests per windowMs | ||
| }); | ||
|
|
||
| router.post("/", authorizeAndAuthenticate([ROLES.SUPERUSER], [Services.CRON_JOB_HANDLER]), users.markUnverified); | ||
| router.post("/update-in-discord", authenticate, authorizeRoles([SUPERUSER]), users.setInDiscordScript); | ||
| router.post("/verify", authenticate, users.verifyUser); | ||
| @@ -69,6 +74,7 @@ | ||
| router.post( | ||
| "/picture", | ||
| authenticate, | ||
| pictureUploadLimiter, | ||
| upload.single("profile"), | ||
| skipWhenApplicationType(checkIsVerifiedDiscord), | ||
| users.handleUserPictureUpload |
| @@ -42,7 +42,8 @@ | ||
| "passport-github2": "0.1.12", | ||
| "passport-google-oauth20": "^2.0.0", | ||
| "rate-limiter-flexible": "5.0.3", | ||
| "winston": "3.13.0" | ||
| "winston": "3.13.0", | ||
| "express-rate-limit": "^8.2.1" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/chai": "4.3.16", |
| Package | Version | Security advisories |
| express-rate-limit (npm) | 8.2.1 | None |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Date: 21 Feb 2026
Developer Name: @vinit717 @AnujChhikara
Issue Ticket Number
PRs going for sync
Description
Documentation Updated?
Under Feature Flag
Database Changes
Breaking Changes
Development Tested?
Screenshots
edit application :-
edit-proof.mp4
Image upload -
create-proof.mp4