fix(backend): resolve OCRService strict base64 line break rejection and CPU blocking DoS#794
Conversation
…nc and add ErrorBoundary
…er assertion errors
…istence-error-boundaries
…syntax/ESLint errors
…ency in incident service
…on and performance risk
|
@harshitanagpal05 is attempting to deploy a commit to the ritesh Team on Vercel. A member of the Team first needs to authorize it. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
|
Superb implementation, @harshitanagpal05! I've successfully resolved all conflicts in your PR and queued it for merging into
Keep up the outstanding work! Let's build together! 🔥 |
Summary
We have successfully resolved the base64 input validation functional bug and CPU exhaustion performance vulnerability in the OCR service.
Proposed Changes
OCRService.extract_textwith a compiled C regular expression lookup to allow standard whitespaces and line wraps (\n,\r).test_ocr_service.pyto be fully asynchronous usingpytest-anyio.PIL.Image.openinside unit tests to return a mock Image with custom bounds, preventing format exceptions from failing tests.closes bug(backend): strict all() base64 checking in OCRService rejects valid base64 strings with newlines and causes CPU-blocking DoS #793
Verification Results
All 8 async unit tests pass cleanly: