fix: adds guardrails against CPU/memory DoS#523
Conversation
- Replace raw user_id with SHA256 hash (8-char prefix) in all log statements - Maintains audit trail capability while protecting user identifiers (PII) - Complies with GDPR/CCPA privacy requirements - Hash is deterministic for correlation without exposing PII Resolves CodeRabbit PII logging concern
…backfill Fix tenant ticket orphaning by persisting company_id on save
…ashboard feat: Real-time Support Dashboard Updates Using Supabase Realtime Channels
…y bugs on Ticket Detail page
…bles across UI and config
… with premium header
…link them in landing footer
…and style premium elements
…out to OCR service (Fixes ritesh-1918#367)
|
@ionfwsrijan is attempting to deploy a commit to the ritesh Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthroughThe changes implement multi-layered DoS protection for image-based OCR requests. Request validation rejects oversized base64 payloads at the API boundary; OCR service constants define resource limits and concurrency controls; extract_text adds granular input validation, image integrity checks, and async-safe execution with timeouts and semaphore gating; the endpoint is updated to properly await async OCR extraction. ChangesImage OCR DoS Protection
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
|
@ritesh-1918 You may review and merge this |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@backend/services/ocr_service.py`:
- Line 83: Replace the deprecated asyncio.get_event_loop() call with
asyncio.get_running_loop() where the variable loop is obtained (replace the
asyncio.get_event_loop() expression in the OCR service code) so the currently
running loop is retrieved in async contexts; update any surrounding async
function (the code that assigns loop) to ensure it runs inside an active event
loop and use asyncio.get_running_loop() instead of asyncio.get_event_loop().
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 05b905b0-63d5-4a30-9069-43e7ec82200d
📒 Files selected for processing (2)
backend/main.pybackend/services/ocr_service.py
|
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
|---|---|---|---|---|---|
| 29368972 | Triggered | Supabase Service Role JWT | b460068 | scratch/test_companies.js | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secret safely. Learn here the best practices.
- Revoke and rotate this secret.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
|
Hi @ionfwsrijan! Thanks for the contribution. I have successfully converted your PR's target branch to PR approved and merged! Welcome to the family! 🚀💻 🌟 Developer Action NetworkBefore starting or submitting updates, please complete these quick onboarding steps:
Note: All PR branches must target the |
Description
Fixes #367 — adds guardrails against CPU/memory DoS via unbounded base64 image OCR.
Changes
backend/services/ocr_service.py:Image.verify()+ dimension check, max 4096px)asyncio.Semaphoreasyncio.wait_for+ executorextract_text()madeasync— returns early on validation failurebackend/main.py:@field_validatoronTicketRequest.image_base64for early rejection at the validation layeranalyze_ticketcall site toawaitthe asyncextract_text()Acceptance criteria met
Summary by CodeRabbit
Bug Fixes
Improvements