Repository navigation
fix(server): cap insert_assets request bodies - #558
Merged
Merged
Conversation
POST /api/assets decoded with json.NewDecoder directly. A multipart Content-Type skips the JSON body middleware, so that request was uncapped. Decode through the shared limit first and answer 413 before touching the database.
Contributor
|
Review notes The change to
#575 caps multipart bodies in the middleware at the largest upload-handler limit, which covers all of them. This PR is still a reasonable tighter per-handler cap on top of that. |
BaaRai
force-pushed
the
fix/insert-assets-body
branch
from
November 26, 2026 22:24
76f30d1 to
9ef4e06
Compare
BaaRai
added a commit
to gabrimarch3/ARTEX
that referenced
this pull request
Nov 26, 2026
BaaRai
force-pushed
the
fix/insert-assets-body
branch
from
November 26, 2026 22:40
9ef4e06 to
7028595
Compare
BaaRai
added a commit
to gabrimarch3/ARTEX
that referenced
this pull request
Nov 26, 2026
Owner
|
Merged, thanks @Coff0xc. Rebased on current main and verified with its tests and negative control. |
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.
POST /api/assetsdecoded the body withjson.NewDecoderon its own. The JSON body middleware skipsmultipart/so uploads can stream, and this handler inherited that skip. A multipart request could therefore be an uncapped JSON document.The handler now uses the shared decoder, which applies the existing cap, and answers 413 before it checks the database. The multipart exemption for real uploads is unchanged.
go test -count=1 -run "TestInsertAssetsCapsMultipartBody|TestDecodeCapsBody|TestMultipartBodyIsNotGivenTheJSONCap|TestRawJSONBodyOverTheCapIs413|TestDecodeAcceptsSmallBody" ./server/passed.