fix: add credentials: 'omit' to all calls to recruit#7061
Open
fix: add credentials: 'omit' to all calls to recruit#7061
Conversation
| console.log('debug: /jobs/:id/apply - req.body', req.body); | ||
| console.log('debug: /jobs/:id/apply - req.params', req.params); | ||
| next(); | ||
| }, cors(applyOptions), (req, res, next) => authenticator(authenticatorOptions)(req, res, next), upload.single('resume'), (req, res, next) => new RecruitCRMService().applyForJob(req, res, next)); |
Check failure
Code scanning / CodeQL
Missing rate limiting High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 year ago
To fix the problem, we need to introduce rate limiting to the route handler to prevent denial-of-service attacks. The best way to do this is by using the express-rate-limit package, which allows us to easily set up rate limiting for our Express application.
We will:
- Install the
express-rate-limitpackage. - Import the package in the file.
- Set up a rate limiter with appropriate configuration.
- Apply the rate limiter to the specific route handler that performs authorization.
Suggested changeset
2
src/server/routes/recruitCRM.js
| @@ -13,2 +13,3 @@ | ||
| const authenticatorOptions = _.pick(config.SECRET.JWT_AUTH, ['AUTH_SECRET', 'VALID_ISSUERS']); | ||
| const RateLimit = require('express-rate-limit'); | ||
| const cors = require('cors'); | ||
| @@ -23,2 +24,6 @@ | ||
| }); | ||
| const limiter = RateLimit({ | ||
| windowMs: 15 * 60 * 1000, // 15 minutes | ||
| max: 100, // max 100 requests per windowMs | ||
| }); | ||
| const routes = express.Router(); | ||
| @@ -58,3 +63,3 @@ | ||
| next(); | ||
| }, cors(applyOptions), (req, res, next) => authenticator(authenticatorOptions)(req, res, next), upload.single('resume'), (req, res, next) => new RecruitCRMService().applyForJob(req, res, next)); | ||
| }, cors(applyOptions), limiter, (req, res, next) => authenticator(authenticatorOptions)(req, res, next), upload.single('resume'), (req, res, next) => new RecruitCRMService().applyForJob(req, res, next)); | ||
|
|
package.json
Outside changed files
| @@ -175,3 +175,4 @@ | ||
| "xml2json": "^0.11.2", | ||
| "xss": "^1.0.15" | ||
| "xss": "^1.0.15", | ||
| "express-rate-limit": "^7.5.0" | ||
| }, |
This fix introduces these dependencies
| Package | Version | Security advisories |
| express-rate-limit (npm) | 7.5.0 | None |
Copilot is powered by AI and may make mistakes. Always verify output.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.