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

feat(conf): configurable max for request headers, response headers, uri args, post args and decode args for lua #10443

Merged
merged 7 commits into from
Mar 20, 2023

Conversation

bungle
Copy link
Member

@bungle bungle commented Mar 7, 2023

Summary

Adds new kong.conf configuration settings:

  • lua_max_req_headers (affects kong.request.get_headers() and ngx.req.get_headers(), does not affect proxying)
  • lua_max_resp_headers (affects kong.response.get_headers() and kong.service.response.get_headers() and ngx.resp.get_headers(), does not affect proxying)
  • lua_max_uri_args (affects kong.request.get_query(), kong.request.get_query_arg(), ngx.req.get_uri_args(), does not affect proxying)
  • lua_max_post_args (affects kong.request.get_body() and ngx.req.get_post_args(), does not affect proxying)

And changes Kong to use those defaults.

This PR also contains some style/perf commits. I suggest this to be reviewed commit-by-commit.

KAG-715

Issues Resolved

Fix #10324

@bungle bungle added the pr/wip A work in progress PR opened to receive feedback label Mar 7, 2023
@bungle bungle force-pushed the feat/configurable-arg-limits branch 2 times, most recently from 577afef to acb4786 Compare March 8, 2023 09:29
@bungle bungle force-pushed the feat/configurable-arg-limits branch from 4d41865 to 9629d81 Compare March 8, 2023 19:15
@bungle bungle force-pushed the feat/configurable-arg-limits branch from 9629d81 to 01e4bda Compare March 9, 2023 12:36
@pull-request-size pull-request-size bot added size/XL and removed size/L labels Mar 9, 2023
@bungle bungle added this to the 3.3 milestone Mar 9, 2023
@bungle bungle force-pushed the feat/configurable-arg-limits branch 2 times, most recently from 09b6212 to 22b1b50 Compare March 9, 2023 12:49
kong.conf.default Outdated Show resolved Hide resolved
kong/router/atc.lua Outdated Show resolved Hide resolved
kong/router/traditional.lua Outdated Show resolved Hide resolved
@bungle bungle force-pushed the feat/configurable-arg-limits branch from 22b1b50 to ed6f997 Compare March 10, 2023 15:28
@bungle bungle marked this pull request as ready for review March 10, 2023 15:30
@bungle bungle force-pushed the feat/configurable-arg-limits branch 3 times, most recently from 4b74484 to f1383c0 Compare March 10, 2023 18:35
@bungle bungle force-pushed the feat/configurable-arg-limits branch 4 times, most recently from b67d0f7 to 32ab9eb Compare March 17, 2023 11:32
kong.conf.default Outdated Show resolved Hide resolved
kong.conf.default Outdated Show resolved Hide resolved
kong.conf.default Outdated Show resolved Hide resolved
kong/pdk/request.lua Show resolved Hide resolved
spec/fixtures/mock_upstream.lua Show resolved Hide resolved
kong/pdk/table.lua Outdated Show resolved Hide resolved
bungle added 7 commits March 20, 2023 11:56
### Summary

Just localizes some functions in request module. The most of them were already localized,
but this adds the rest.
### Summary

Adds is_trusted_ip() helper function to request module. There were
some repetitive code.
### Summary

If `kong.request.get_uri_args` is called multiple times in request,
the table returned by it is now cached to request context and reused
when called again.
### Summary

On my Mac the `os.execute("echo -n '' > " .. FILE_LOG_PATH)` was creating
files that contained `-n`, which is really strange. We have a helper to
cleanup log files, so lets just use it instead.
### Summary

Just fixes the indentation in kong response pdk module.
### Summary

Previously the code was using `ngx.re.gsub` for simple `-` to `_` conversion
on input strings. For HTTP module it uses `resty.core.utils.str_replace_char`.
For stream module this is not currently needed here.

The already fast replacement logic is now about the 5 times faster.

Signed-off-by: Aapo Talvensaari <aapo.talvensaari@gmail.com>
…ri args, post args and decode args for lua

### Summary

Adds new `kong.conf` configuration settings:

- `lua_max_req_headers` (affects `kong.request.get_headers()` and `ngx.req.get_headers()`, does not affect proxying)
- `lua_max_resp_headers` (affects `kong.response.get_headers()` and `kong.service.response.get_headers()` and `ngx.resp.get_headers()`, does not affect proxying)
- `lua_max_uri_args` (affects `kong.request.get_query()`, `kong.request.get_query_arg()`, `ngx.req.get_uri_args()`, does not affect proxying)
- `lua_max_post_args` (affects `kong.request.get_body()` and `ngx.req.get_post_args()`, does not affect proxying)

And changes Kong to use those defaults.

This PR also contains some style/perf commits. I suggest this to be reviewed `commit-by-commit`.

Signed-off-by: Aapo Talvensaari <aapo.talvensaari@gmail.com>
@bungle bungle force-pushed the feat/configurable-arg-limits branch from d4ef4ec to c6dea45 Compare March 20, 2023 10:04
@jschmid1 jschmid1 self-requested a review March 20, 2023 10:11
Copy link
Contributor

@jschmid1 jschmid1 left a comment

Choose a reason for hiding this comment

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

approved, granted the tests pass

@bungle bungle merged commit d964b83 into master Mar 20, 2023
@bungle bungle deleted the feat/configurable-arg-limits branch March 20, 2023 11:29
windmgc pushed a commit that referenced this pull request Oct 24, 2023
…11721)

resty.core.utils.str_replace_char() is a better way to replace - to _.
In the future string.lua will gather more functions to simplify tools.utils.lua.

See: #10443
chronolaw added a commit that referenced this pull request Jan 23, 2024
…11721)

resty.core.utils.str_replace_char() is a better way to replace - to _.
In the future string.lua will gather more functions to simplify tools.utils.lua.

See: #10443
chronolaw added a commit that referenced this pull request Jan 24, 2024
…11721)

resty.core.utils.str_replace_char() is a better way to replace - to _.
In the future string.lua will gather more functions to simplify tools.utils.lua.

See: #10443
chronolaw added a commit that referenced this pull request Feb 26, 2024
…11721)

resty.core.utils.str_replace_char() is a better way to replace - to _.
In the future string.lua will gather more functions to simplify tools.utils.lua.

See: #10443
chronolaw added a commit that referenced this pull request Feb 26, 2024
…11721)

resty.core.utils.str_replace_char() is a better way to replace - to _.
In the future string.lua will gather more functions to simplify tools.utils.lua.

See: #10443
chronolaw added a commit that referenced this pull request Mar 4, 2024
…11721)

resty.core.utils.str_replace_char() is a better way to replace - to _.
In the future string.lua will gather more functions to simplify tools.utils.lua.

See: #10443
locao pushed a commit that referenced this pull request Mar 5, 2024
…11721)

resty.core.utils.str_replace_char() is a better way to replace - to _.
In the future string.lua will gather more functions to simplify tools.utils.lua.

See: #10443
ADD-SP pushed a commit that referenced this pull request Mar 7, 2024
…11721)

resty.core.utils.str_replace_char() is a better way to replace - to _.
In the future string.lua will gather more functions to simplify tools.utils.lua.

See: #10443
ADD-SP pushed a commit that referenced this pull request Mar 7, 2024
…11721)

resty.core.utils.str_replace_char() is a better way to replace - to _.
In the future string.lua will gather more functions to simplify tools.utils.lua.

See: #10443
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.

Kong max query args
4 participants