Skip to content
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

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

kkartunov
Copy link
Collaborator

No description provided.

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

This route handler performs
authorization
, but is not rate-limited.

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:

  1. Install the express-rate-limit package.
  2. Import the package in the file.
  3. Set up a rate limiter with appropriate configuration.
  4. Apply the rate limiter to the specific route handler that performs authorization.
Suggested changeset 2
src/server/routes/recruitCRM.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/server/routes/recruitCRM.js b/src/server/routes/recruitCRM.js
--- a/src/server/routes/recruitCRM.js
+++ b/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));
 
EOF
@@ -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

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/package.json b/package.json
--- a/package.json
+++ b/package.json
@@ -175,3 +175,4 @@
     "xml2json": "^0.11.2",
-    "xss": "^1.0.15"
+    "xss": "^1.0.15",
+    "express-rate-limit": "^7.5.0"
   },
EOF
@@ -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.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant