Skip to content

Limit picod request body size for prevent DoS attack#326

Merged
volcano-sh-bot merged 1 commit into
volcano-sh:mainfrom
RainbowMango:pr_limit_picod_request_body
May 20, 2026
Merged

Limit picod request body size for prevent DoS attack#326
volcano-sh-bot merged 1 commit into
volcano-sh:mainfrom
RainbowMango:pr_limit_picod_request_body

Conversation

@RainbowMango
Copy link
Copy Markdown
Contributor

What type of PR is this?

/kind cleanup
/kind security

What this PR does / why we need it:

This pull request refactors how the maximum request body size is enforced in the application. The body size limit logic has been moved from the authentication middleware to a new global middleware, ensuring that all incoming requests are protected from large payloads, not just those passing through authentication.

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

This PR is split from #250 to address the comments of #250 (comment).

Does this PR introduce a user-facing change?:

`picod`: All incoming requests are now protected from large payloads. 

Copilot AI review requested due to automatic review settings May 12, 2026 11:09
@volcano-sh-bot
Copy link
Copy Markdown
Contributor

@RainbowMango: The label(s) kind/security cannot be applied, because the repository doesn't have them.

Details

In response to this:

What type of PR is this?

/kind cleanup
/kind security

What this PR does / why we need it:

This pull request refactors how the maximum request body size is enforced in the application. The body size limit logic has been moved from the authentication middleware to a new global middleware, ensuring that all incoming requests are protected from large payloads, not just those passing through authentication.

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

This PR is split from #250 to address the comments of #250 (comment).

Does this PR introduce a user-facing change?:

`picod`: All incoming requests are now protected from large payloads. 

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@volcano-sh-bot
Copy link
Copy Markdown
Contributor

Welcome @RainbowMango! It looks like this is your first PR to volcano-sh/agentcube 🎉

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates PicoD’s Gin server setup to enforce a maximum HTTP request body size globally (not only for authenticated routes), reducing DoS risk from oversized payloads.

Changes:

  • Add a global Gin middleware that wraps c.Request.Body with http.MaxBytesReader(..., MaxBodySize) and set engine.MaxMultipartMemory = MaxBodySize.
  • Remove the request body size enforcement from AuthMiddleware, keeping auth focused on JWT verification.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
pkg/picod/server.go Adds global request body size limiting middleware and aligns multipart parsing memory cap with MaxBodySize.
pkg/picod/auth.go Removes body-size enforcement from authentication middleware.

Comment thread pkg/picod/server.go Outdated
Comment thread pkg/picod/server.go Outdated
Comment thread pkg/picod/server.go
Comment thread pkg/picod/auth.go Outdated
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request moves the request body size limit enforcement from the authentication middleware to a global middleware in the server setup. Feedback includes a request to remove redundant blank lines in auth.go, a suggestion to generalize a comment in server.go to avoid hardcoded values, and a recommendation to lower MaxMultipartMemory to prevent high memory consumption during multipart uploads.

Comment thread pkg/picod/auth.go Outdated
Comment thread pkg/picod/server.go Outdated
Comment thread pkg/picod/server.go
Comment thread pkg/picod/server.go
Signed-off-by: RainbowMango <qdurenhongcai@gmail.com>
@RainbowMango RainbowMango force-pushed the pr_limit_picod_request_body branch from 5d37153 to 0322b15 Compare May 13, 2026 03:47
@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 47.92%. Comparing base (524e55e) to head (0322b15).
⚠️ Report is 47 commits behind head on main.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #326      +/-   ##
==========================================
+ Coverage   47.57%   47.92%   +0.35%     
==========================================
  Files          30       30              
  Lines        2819     2865      +46     
==========================================
+ Hits         1341     1373      +32     
- Misses       1338     1344       +6     
- Partials      140      148       +8     
Flag Coverage Δ
unittests 47.92% <100.00%> (+0.35%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@volcano-sh-bot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hzxuzhonghu

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@FAUST-BENCHOU
Copy link
Copy Markdown
Contributor

/lgtm

@volcano-sh-bot
Copy link
Copy Markdown
Contributor

@FAUST-BENCHOU: changing LGTM is restricted to collaborators

Details

In response to this:

/lgtm

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@hzxuzhonghu
Copy link
Copy Markdown
Member

/lgtm

@volcano-sh-bot volcano-sh-bot merged commit 64f331a into volcano-sh:main May 20, 2026
15 checks passed
@RainbowMango RainbowMango deleted the pr_limit_picod_request_body branch May 20, 2026 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants