-
Notifications
You must be signed in to change notification settings - Fork 1
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
Bcsc #205
Bcsc #205
Conversation
Dev -> QA
Dev -> QA
QA -> Prod
Update prod.deploy.yml
Dev -> QA
QA -> Prod
bcscRouter.get('/', async (req: Request, res: Response) => { | ||
const { siteId } = req.query; | ||
|
||
// Set a secure, HTTP-only cookie with the `siteID` | ||
res.cookie('siteId', siteId, { | ||
httpOnly: true, // The cookie cannot be accessed via client-side JavaScript | ||
secure: process.env.NODE_ENV === 'production', // Ensures the cookie is only sent over HTTPS | ||
sameSite: 'lax', // Controls whether the cookie is sent with cross-origin requests | ||
}); | ||
|
||
await controller.initiateLogin( | ||
() => {}, | ||
() => {}, | ||
siteId as string, | ||
); | ||
}); |
Check failure
Code scanning / CodeQL
Missing rate limiting High
authorization
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 2 months ago
To fix the problem, we need to introduce rate limiting to the Express application. This can be achieved by using the express-rate-limit
package. We will set up a rate limiter and apply it to the routes that perform authorization operations. This will help prevent abuse by limiting the number of requests a client can make to these endpoints within a specified time window.
- Install the
express-rate-limit
package. - Import the
express-rate-limit
package in thesrc/routes/bcsc.ts
file. - Set up a rate limiter with appropriate configuration (e.g., maximum number of requests per time window).
- Apply the rate limiter to the relevant routes.
-
Copy modified line R3 -
Copy modified lines R8-R12 -
Copy modified lines R15-R16
@@ -2,2 +2,3 @@ | ||
import express, { Request, Response } from 'express'; | ||
import rateLimit from 'express-rate-limit'; | ||
|
||
@@ -6,4 +7,11 @@ | ||
const bcscRouter = express.Router(); | ||
|
||
const limiter = rateLimit({ | ||
windowMs: 15 * 60 * 1000, // 15 minutes | ||
max: 100, // limit each IP to 100 requests per windowMs | ||
}); | ||
const controller = new BscsController(); | ||
|
||
bcscRouter.use(limiter); | ||
|
||
bcscRouter.get('/', async (req: Request, res: Response) => { |
No description provided.