Backend fixes#1824
Conversation
|
Caution Review failedPull request was closed or merged during review No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR adds two security improvements: rate limiting for the company name endpoint with a test-mode-specific threshold, and read-only validation for MongoDB aggregation pipeline queries to prevent write operations and server-side JavaScript execution. ChangesSecurity and Query Validation Enhancements
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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.
Pull request overview
This PR tightens backend protections by (1) hardening MongoDB panel query validation to reject non-read-only aggregation pipelines, and (2) adding explicit request throttling to the “get company name” endpoint to reduce abuse/load.
Changes:
- Added an AST-level MongoDB aggregation pipeline validator to block write stages and server-side JavaScript operators.
- Added a
@Throttle(...)override to/company/name/:companyId(and minor import reordering).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| backend/src/entities/visualizations/panel/utils/check-query-is-safe.util.ts | Adds isReadOnlyMongoAggregationPipeline() enforcement for Mongo panel queries. |
| backend/src/entities/company-info/company-info.controller.ts | Applies per-route throttling to the company-name lookup endpoint. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (!isReadOnlyMongoAggregationPipeline(query)) { | ||
| return { | ||
| isSafe: false, | ||
| reason: | ||
| 'Query must be a read-only aggregation pipeline (write stages or server-side JavaScript operators such as $out, $merge, $function, $accumulator, $where are not allowed)', | ||
| }; | ||
| } |
Summary by CodeRabbit
Performance
Security