fix(security): wire RATE_LIMIT_IDS to endpoints & add regression test contract (#2039) - #2072
Open
Samarth1306w wants to merge 1 commit into
Open
fix(security): wire RATE_LIMIT_IDS to endpoints & add regression test contract (#2039)#2072Samarth1306w wants to merge 1 commit into
Samarth1306w wants to merge 1 commit into
Conversation
…ack endpoints and add contract test (CapSoftware#2039)
|
🚨 Contributor flagged. Click here for more info: Superagent Dashboard |
Comment on lines
+37
to
+47
| for (const [key, value] of Object.entries(RATE_LIMIT_IDS)) { | ||
| const hasKeyRef = combinedSource.includes(`RATE_LIMIT_IDS.${key}`); | ||
| const hasValueRef = combinedSource.includes(`"${value}"`) || combinedSource.includes(`'${value}'`); | ||
|
|
||
| if (!hasKeyRef && !hasValueRef) { | ||
| unreferencedKeys.push(key); | ||
| } | ||
| } | ||
|
|
||
| expect( | ||
| unreferencedKeys, |
Contributor
There was a problem hiding this comment.
Unreferenced IDs break contract test
When the apps/web unit suite runs, this loop adds AUTH_OTP_VERIFY, AUTH_OTP_SEND, LOOM_DOWNLOAD, MESSENGER_MESSAGE, and DESKTOP_LOGS to unreferencedKeys because they have no references outside the excluded declaration file, causing the new assertion to fail deterministically.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/web/__tests__/unit/rate-limit-ids.test.ts
Line: 37-47
Comment:
**Unreferenced IDs break contract test**
When the apps/web unit suite runs, this loop adds `AUTH_OTP_VERIFY`, `AUTH_OTP_SEND`, `LOOM_DOWNLOAD`, `MESSENGER_MESSAGE`, and `DESKTOP_LOGS` to `unreferencedKeys` because they have no references outside the excluded declaration file, causing the new assertion to fail deterministically.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
Closes #2039
Summary
rate-limit-ids.test.ts) that asserts everyRATE_LIMIT_IDdeclared inlib/rate-limit.tsis referenced at least once outside the declaration file.RATE_LIMIT_IDS.GUEST_CHECKOUTto the guest checkout route (apps/web/app/api/settings/billing/guest-checkout/route.ts).RATE_LIMIT_IDS.ANALYTICS_TRACKto the analytics tracking route (apps/web/app/api/analytics/track/route.ts).Acceptance criteria
/claim #2039
Greptile Summary
The PR adds Vercel Firewall rate-limit checks to the public analytics-tracking and guest-checkout routes and introduces a unit-test contract intended to detect unused rate-limit IDs.
Confidence Score: 4/5
The contract-test failure must be fixed before merging because the apps/web unit suite will fail on five existing unreferenced rate-limit IDs.
The route guards follow the shared limiter contract, but the newly added test iterates all declarations and asserts none are unreferenced even though five declarations have no references in the scanned source tree.
Files Needing Attention: apps/web/tests/unit/rate-limit-ids.test.ts
Important Files Changed
Prompt To Fix All With AI
Reviews (1): Last reviewed commit: "fix(security): wire RATE_LIMIT_IDS to gu..." | Re-trigger Greptile