Skip to content

fix(server): rate-limit /api/analyze and /api/embed endpoints (#1328)#1339

Merged
magyargergo merged 1 commit into
abhigyanpatwari:mainfrom
azizur100389:fix/rate-limit-analyze-embed
May 4, 2026
Merged

fix(server): rate-limit /api/analyze and /api/embed endpoints (#1328)#1339
magyargergo merged 1 commit into
abhigyanpatwari:mainfrom
azizur100389:fix/rate-limit-analyze-embed

Conversation

@azizur100389

Copy link
Copy Markdown
Contributor

Summary

Changes

File Change
gitnexus/src/server/api.ts Insert createRouteLimiter({ limit: 10 }) on POST /api/analyze, createRouteLimiter({ limit: 20 }) on POST /api/embed
gitnexus/test/unit/rate-limit.test.ts 2 structural wiring assertions (regex against api.ts source)

Test plan

  • npx tsc --noEmit — clean
  • npx vitest run test/unit/rate-limit.test.ts — 15/15 pass (was 13)
  • npx prettier --check on changed files — clean
  • Pre-commit hooks (eslint + prettier + typecheck) — passed
  • Full vitest run --project default — only pre-existing dev-env failures (home dir .git causes tmpdir-based tests to see a parent git repo); all pass on CI

Closes #1328

…anpatwari#1328)

Apply createRouteLimiter to the two heaviest FS-touching POST endpoints
that were scoped out of U4 (abhigyanpatwari#1327) because CodeQL did not flag them
directly. /api/analyze gets 10 rpm/IP (clone + full-tree walk),
/api/embed gets 20 rpm/IP (ONNX inference per file). Adds structural
wiring tests matching the existing rate-limit.test.ts pattern.
@vercel

vercel Bot commented May 4, 2026

Copy link
Copy Markdown

@azizur100389 is attempting to deploy a commit to the NexusCore Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

github-actions Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor

CI Report

All checks passed

Pipeline Status

Stage Status Details
✅ Typecheck success tsc --noEmit
✅ Tests success unit tests, 3 platforms
✅ E2E success gitnexus-web changes only

Test Results

Tests Passed Failed Skipped Duration
8020 8019 0 1 375s

✅ All 8019 tests passed

1 test(s) skipped — expand for details
  • buildTypeEnv > known limitations (documented skip tests) > Ruby block parameter: users.each { |user| } — closure param inference, different feature

Code Coverage

Tests

Metric Coverage Covered Base Delta Status
Statements 77.62% 24457/31508 77.02% 📈 +0.6 🟢 ███████████████░░░░░
Branches 66.21% 15519/23437 65.97% 📈 +0.2 🟢 █████████████░░░░░░░
Functions 82.86% 2414/2913 81.86% 📈 +1.0 🟢 ████████████████░░░░
Lines 80.65% 22078/27375 79.89% 📈 +0.8 🟢 ████████████████░░░░

📋 View full run · Generated by CI

@magyargergo magyargergo merged commit f101356 into abhigyanpatwari:main May 4, 2026
29 of 30 checks passed
@magyargergo

Copy link
Copy Markdown
Collaborator

Thank you for this!

@azizur100389

Copy link
Copy Markdown
Contributor Author

Happy to contribute! The clear issue write-up made it straightforward to pick up. Thanks for the quick merge.

@magyargergo magyargergo mentioned this pull request May 10, 2026
4 tasks
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.

Security follow-up: rate-limit /api/analyze and /api/embed (heaviest FS-touching endpoints)

2 participants