-
Notifications
You must be signed in to change notification settings - Fork 24
Merge pull request #281 from ducktors/dependabot/github_actions/githu… #292
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
base: master
Are you sure you want to change the base?
Conversation
…b/codeql-action-3.29.9 chore(actions): bump github/codeql-action from 3.29.8 to 3.29.9
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
| app.get("/", async (_req, reply) => { | ||
| const data = await readFile(join(__dirname, "..", "index.html")); | ||
| reply.header("content-type", "text/html; charset=utf-8"); | ||
| reply.send(data); | ||
| }); |
Check failure
Code scanning / CodeQL
Missing rate limiting High
a file system access
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 2 months ago
The best way to fix this problem is to add a rate-limiting middleware to the Fastify app, ensuring the / route cannot be abused by clients sending requests rapidly. The standard package for this in the Fastify ecosystem is @fastify/rate-limit.
- To fix:
- Install
@fastify/rate-limit. - Add the plugin registration before route definitions.
- Apply a global or route-specific rate limit. Here, we will apply a global rate limit for simplicity but it could be made route-specific if needed.
- Install
- The fix only requires adding
app.register(require('@fastify/rate-limit'), { ...opts });beforeapp.getdefinition. - Add the required import (via
require) inline as appropriate. - The code for the fix must go in
examples/basic/server.js.
-
Copy modified lines R8-R13
| @@ -5,6 +5,12 @@ | ||
|
|
||
| const app = fastify({ logger: true }); | ||
|
|
||
| // Add basic rate limiting to prevent abuse | ||
| app.register(require('@fastify/rate-limit'), { | ||
| max: 100, // max 100 requests | ||
| timeWindow: '15 minutes' // per 15 minutes per source IP | ||
| }); | ||
|
|
||
| app.register(socketio); | ||
|
|
||
| app.get("/", async (_req, reply) => { |
-
Copy modified lines R24-R25
| @@ -21,7 +21,8 @@ | ||
| }, | ||
| "dependencies": { | ||
| "fastify-plugin": "^4.5.1", | ||
| "tslib": "^2.6.1" | ||
| "tslib": "^2.6.1", | ||
| "@fastify/rate-limit": "^10.3.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@biomejs/biome": "2.2.0", |
| Package | Version | Security advisories |
| @fastify/rate-limit (npm) | 10.3.0 | None |
…b/codeql-action-3.29.9
chore(actions): bump github/codeql-action from 3.29.8 to 3.29.9
In this PR:
Issues reference:
Checklist:
pnpm lintlocally prior to submission?pnpm buildof your changes locally?pnpm testof your changes locally?