Skip to content
This repository has been archived by the owner on Nov 2, 2023. It is now read-only.

sdk/middleware/sqgin: fix request ctx #157

Merged
merged 3 commits into from Sep 30, 2020

Conversation

amnay-mo
Copy link

@amnay-mo amnay-mo commented Sep 29, 2020

This fixes a bug where gin's c.Request's context gets overwritten by the sqgin middleware

If you set some values in the context of c.Request, you won't be able to retrieve them after sqgin's 'middlewareHandler' has done its work

@Julio-Guerra Julio-Guerra changed the base branch from master to dev September 29, 2020 15:04
@Julio-Guerra Julio-Guerra added this to the v0.16.1 milestone Sep 29, 2020
@Julio-Guerra Julio-Guerra added the bug Something isn't working label Sep 29, 2020
@Julio-Guerra Julio-Guerra force-pushed the fix-sqgin-request-ctx branch 2 times, most recently from 84ce914 to 1039bca Compare September 30, 2020 10:48
@Julio-Guerra
Copy link
Collaborator

Thanks a lot Amnay.
FYI, I rebased to the latest dev branch - hence the push force.

@Julio-Guerra
Copy link
Collaborator

On a side note, I created this related issue gin-gonic/gin#2516 as this problem wouldn't happen if the request and gin contexts would be correctly "merged" together.

Gin's context wrongly implements `context.Context` and doesn't wrap the
underlying request context at all. Therefore, we need to use the actual request
context `c.Request.Context()` so that the agent can properly manage the request
context, but also to correctly propagate values stored in the context.
@Julio-Guerra Julio-Guerra merged commit a242284 into sqreen:dev Sep 30, 2020
@Julio-Guerra Julio-Guerra mentioned this pull request Sep 30, 2020
Julio-Guerra added a commit that referenced this pull request Sep 30, 2020
Fixes:

- (#158) PII: make the PII scrubbing of In-App WAF attack events
  case-insensitive in order to correctly scrub transformed request parameters.

- (#159) Monitoring: fix the content type and length monitoring of HTTP
  responses.

- (#157) Gin middleware: use the request Go context instead of Gin's so that the
  agent can properly manage the request execution context, but also to correctly
  propagate values stored in the Go context before the middleware function.
Julio-Guerra added a commit that referenced this pull request Sep 30, 2020
Fixes

- (#158) PII: make the PII scrubbing of In-App WAF attack events
  case-insensitive in order to correctly scrub transformed request parameters.

- (#159) Monitoring: fix the content type and length monitoring of HTTP
  responses.

- (#157) Gin middleware: use the request Go context instead of Gin's so that the
  agent can properly manage the request execution context, but also to correctly
  propagate values stored in the Go context before the middleware function.
Julio-Guerra added a commit that referenced this pull request Oct 1, 2020
Fixes:

- (#158) PII: make the PII scrubbing of In-App WAF attack events
  case-insensitive in order to correctly scrub transformed request parameters.

- (#159) Monitoring: fix the content type and length monitoring of HTTP
  responses.

- (#157) Gin middleware: use the request Go context instead of Gin's so that the
  agent can properly manage the request execution context, but also to correctly
  propagate values stored in the Go context before the middleware function.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants