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(pdk): use deep copies of Route, Service, and Consumer objects when log serialize #11566

Merged
merged 4 commits into from
Sep 20, 2023

Conversation

sabertobihwy
Copy link
Contributor

@sabertobihwy sabertobihwy commented Sep 13, 2023

Summary

In the function of kong.log.serialize, the lifecycle of three table ctx.route, ctx.service and ctx.authenticated_consumer is across request. Modifying the sub-items in the current request of the table will affect the next request, resulting in unexpected behavior in Kong.

Checklist

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

Full changelog

  • This commit modifies the code to utilize deep copies of the Route, Service, and Consumer objects in the log serializer. This ensures that the original objects are not modified when logging data.
  • Add four test cases.

Issue reference

Fix FTI-5357

objects when log serialize

In the function of `kong.log.serialize`, the lifecycle of
three table `ctx.route`, `ctx.service` and `ctx.authenticated_consumer`
is across request. Modifying the sub-items in the current request of
the table will affect the next request, resulting in unexpected behavior
in Kong.
Signed-off-by: sabertobihwy <sabertobihwy@gmail.com>
@sabertobihwy sabertobihwy marked this pull request as ready for review September 14, 2023 03:07
CHANGELOG/unreleased/kong/11566.yaml Outdated Show resolved Hide resolved
kong/pdk/log.lua Outdated Show resolved Hide resolved
spec/01-unit/10-log_serializer_spec.lua Outdated Show resolved Hide resolved
spec/02-integration/07-sdk/02-log_spec.lua Outdated Show resolved Hide resolved
Signed-off-by: sabertobihwy <sabertobihwy@gmail.com>
Signed-off-by: sabertobihwy <sabertobihwy@gmail.com>
Copy link
Contributor

@chronolaw chronolaw left a comment

Choose a reason for hiding this comment

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

Great Job!

@windmgc windmgc merged commit 7e9e88f into master Sep 20, 2023
24 checks passed
@windmgc windmgc deleted the FTI-5357 branch September 20, 2023 14:59
windmgc pushed a commit that referenced this pull request Sep 25, 2023
Reword changelog of #11566 to be more user-facing
windmgc pushed a commit that referenced this pull request Jan 24, 2024
…n log serialize (#11566)

In the function of `kong.log.serialize`, the lifecycle of
three table `ctx.route`, `ctx.service` and `ctx.authenticated_consumer`
is across request. Modifying the sub-items in the current request of
the table will affect the next request, resulting in unexpected behavior
in Kong.

Fix FTI-5357

---------

Signed-off-by: sabertobihwy <sabertobihwy@gmail.com>
windmgc pushed a commit that referenced this pull request Mar 7, 2024
…n log serialize (#11566)

In the function of `kong.log.serialize`, the lifecycle of
three table `ctx.route`, `ctx.service` and `ctx.authenticated_consumer`
is across request. Modifying the sub-items in the current request of
the table will affect the next request, resulting in unexpected behavior
in Kong.

Fix FTI-5357

---------

Signed-off-by: sabertobihwy <sabertobihwy@gmail.com>
windmgc pushed a commit that referenced this pull request Mar 8, 2024
…n log serialize (#11566)

In the function of `kong.log.serialize`, the lifecycle of
three table `ctx.route`, `ctx.service` and `ctx.authenticated_consumer`
is across request. Modifying the sub-items in the current request of
the table will affect the next request, resulting in unexpected behavior
in Kong.

Fix FTI-5357

---------

Signed-off-by: sabertobihwy <sabertobihwy@gmail.com>
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.

None yet

3 participants