Skip to content

Potential fix for code scanning alert no. 26: Missing rate limiting#397

Draft
farrukhishaq wants to merge 8 commits intomainfrom
improvment/asl-4930-codeql
Draft

Potential fix for code scanning alert no. 26: Missing rate limiting#397
farrukhishaq wants to merge 8 commits intomainfrom
improvment/asl-4930-codeql

Conversation

@farrukhishaq
Copy link
Copy Markdown
Collaborator

Potential fix for https://github.com/UKHomeOffice/aspel-workspace/security/code-scanning/26

Add an Express rate-limiting middleware to this reports router so requests to GET /:report are capped per client/IP over a time window.
Best fix: use express-rate-limit and apply it before the route handler (router.use(limiter)), so both streaming and non-streaming database paths are covered in one change without altering existing business logic.

File to change

  • packages/asl-metrics/lib/reports/index.js

What to add

  1. Import express-rate-limit.
  2. Define a limiter instance (for example 100 requests per 15 minutes).
  3. Attach it to this router before router.get('/:report', ...).

This addresses both alert variants since both DB accesses happen inside the same route.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

farrukhishaq and others added 8 commits April 13, 2026 10:47
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…om user-controlled sources

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…ction

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
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