-
Notifications
You must be signed in to change notification settings - Fork 494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
api: Limit request body size to 10MB #5246
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5246 +/- ##
==========================================
- Coverage 53.75% 51.35% -2.41%
==========================================
Files 450 450
Lines 56191 56193 +2
==========================================
- Hits 30207 28859 -1348
- Misses 23632 24959 +1327
- Partials 2352 2375 +23
... and 103 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
// Create a program with MaxTealSourceBytes+1 bytes | ||
// This should fail inside the handler when reading the bytes from the request body. | ||
largeProgram := []byte(strings.Repeat("a", v2.MaxTealSourceBytes+1)) | ||
tealDisassembleTest(t, largeProgram, 400, "http: request body too large", true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests are affected by a smaller size limit (200KB instead of 10MB) defined by MaxTealSourceBytes
and will trigger the error here:
return badRequest(ctx, err, err.Error(), v2.Log) |
|
||
// Create a program with MaxTealSourceBytes+1 bytes | ||
// This should fail inside the handler when reading the bytes from the request body. | ||
largeProgram := []byte(strings.Repeat("a", v2.MaxTealSourceBytes+1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Co-authored-by: Bob Broderick <118225939+bbroder-algo@users.noreply.github.com>
Summary
This PR adds a limit to the request body size so clients cannot send algod requests larger than 10MB.
Closes #5219
Test Plan
Adds tests in the handler to check source/dryrun request limits and adds an e2e test to check that a simulate request body >10MB fails with a 413 error.