backend: enforce request body size and JSON string-length validation via middleware#665
Open
EmeditWeb wants to merge 1 commit into
Open
backend: enforce request body size and JSON string-length validation via middleware#665EmeditWeb wants to merge 1 commit into
EmeditWeb wants to merge 1 commit into
Conversation
|
@EmeditWeb Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Close #639
Title
Enforce input length limits across backend endpoints
Summary
I added centralized request body size and per-field JSON string-length validation to prevent overly large payloads and inconsistent field lengths across API endpoints.
Files Changed
Details
DEFAULT_MAX_BODY_BYTES(16 KiB) — request body byte cap.DEFAULT_MAX_FIELD_LENGTH(1024 chars) — per-string field cap inside JSON.validate_json_string_lengths(...)in validation.rs to recursively check JSON string lengths and collect field-level errors.enforce_max_request_sizemiddleware in middleware.rs:Content-Lengthor actual body size >DEFAULT_MAX_BODY_BYTES(HTTP 413).Content-Type: application/json, parses the body and rejects when any JSON string exceedsDEFAULT_MAX_FIELD_LENGTH(HTTP 400) with afieldsobject detailing violations.Motivation / Risk
Testing (step-by-step)
cd backend cargo check