-
Notifications
You must be signed in to change notification settings - Fork 212
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
fix: add credentials: 'omit' to all calls to recruit #7061
base: develop
Are you sure you want to change the base?
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
authorization
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 30 days 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-limit
package. - 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.
-
Copy modified line R14 -
Copy modified lines R25-R28 -
Copy modified line R64
@@ -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)); | ||
|
-
Copy modified lines R176-R177
@@ -175,3 +175,4 @@ | ||
"xml2json": "^0.11.2", | ||
"xss": "^1.0.15" | ||
"xss": "^1.0.15", | ||
"express-rate-limit": "^7.5.0" | ||
}, |
Package | Version | Security advisories |
express-rate-limit (npm) | 7.5.0 | None |
No description provided.