Skip to content
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

fix(plugins/request-size-limiting): Check the file size when the request body buffered to a temporary file #13303

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

yankun-li-kong
Copy link
Contributor

@yankun-li-kong yankun-li-kong commented Jun 26, 2024

Summary

Firstly enable request-size-limiting plugin with below config

    plugins:
    - config:
        allowed_payload_size: 512
        require_content_length: false
        size_unit: kilobytes
      enabled: true
      name: request-size-limiting

When client send request without content-length and request body chunked with Transfer-Encoding,
then kong.request.get_raw_body() become nil, and request-size-limiting plugin do not work anymore and return 200 directly.

Below curl command could trigger the error:

dd if=/dev/urandom of=1m.dat bs=1m count=1
curl -v --data-binary @1m.dat http://kong:8000/test -H "Content-Length:" -H "Transfer-Encoding: chunked"

This PR will check the file size when the request body buffered to a temporary file.
Then request-size-limiting plugin still able to get the request body size and work as expected.

Checklist

  • The Pull Request has tests
  • A changelog file has been created under changelog/unreleased/kong or skip-changelog label added on PR if changelog is unnecessary. README.md
  • There is a user-facing docs PR against https://github.com/Kong/docs.konghq.com - PUT DOCS PR HERE

Issue reference

Fix #FTI-6034

Copy link
Contributor

@catbro666 catbro666 left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick kong-ee schedule this PR for cherry-picking to kong/kong-ee plugins/request-size-limiting size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants