-
Notifications
You must be signed in to change notification settings - Fork 484
feat(appsec/proxy): enable body processing by default (except GCP SE) #4069
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
base: main
Are you sure you want to change the base?
Conversation
6a965ca to
5d0feb8
Compare
BenchmarksBenchmark execution time: 2025-10-24 16:30:09 Comparing candidate commit 48767a0 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 24 metrics, 0 unstable metrics. |
|
b363d29 to
d31115a
Compare
|
|
||
| setup := func() (envoyextproc.ExternalProcessorClient, mocktracer.Tracer, func()) { | ||
| rig, err := newEnvoyAppsecRig(t, EnvoyIntegration, false, 0) | ||
| rig, err := newEnvoyAppsecRig(t, GCPServiceExtensionIntegration, false, nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The integration was changed only to have a body parsing disabled for the tests
d31115a to
e873ce2
Compare
| // Set default body parsing size limit if not specified for non-default integrations | ||
| if config.BodyParsingSizeLimit == nil { | ||
| defaultBody := proxy.DefaultBodyParsingSizeLimit | ||
| config.BodyParsingSizeLimit = &defaultBody | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think at this point the integration is not set properly in most cases and since GCP is the default value...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the end yes it's not that useful. Removed in 48767a0
| defaultBody := proxy.DefaultBodyParsingSizeLimit | ||
| config.BodyParsingSizeLimit = &defaultBody |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| defaultBody := proxy.DefaultBodyParsingSizeLimit | |
| config.BodyParsingSizeLimit = &defaultBody | |
| config.BodyParsingSizeLimit = & | |
| proxy.DefaultBodyParsingSizeLimit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
proxy.DefaultBodyParsingSizeLimit is a const, I can't directly take its address
|
|
||
| const ( | ||
| // DefaultBodyParsingSizeLimit is the default number of bytes parsed for body analysis. | ||
| DefaultBodyParsingSizeLimit = 10_000_000 // 10MB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you mind doing it in power of two ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applied in f61a2f2
|
|
||
| mp.firstRequest.Do(func() { | ||
| if mp.BodyParsingSizeLimit == nil { | ||
| mp.computedBodyParsingSizeLimit = req.BodyParsingSizeLimit(ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a data race here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure there is a data race here? The value of computedBodyParsingSizeLimit is only set once with the firstRequest.Do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed using atomic value in fb33a1e
What does this PR do?
This PR enables body processing by default for all proxies integrations except for GCP Service Extensions.
The challenge of this PR was to enable body processing by default for Envoy based proxies but excluding GCP Service Extension from this. As the final integration type is detected during runtime (based on metadata set inside the gRPC stream of requests), the message processor configuration needed to be updated after its initialization.
The integration type is chose either at startup via specification in the code (if integration is different than the default GCP Service Extension) or when the first request is received.
This PR changes the public api for
ProcessorConfigof the proxy package, but as this is only used internally by contribs and we have no current usage of this module outside, we accept this breaking change.The default value set for body processing is
10MB.Note:
Why excluding GCP Service Extension
We currently have an ongoing support case where some request could provoke some backend timeout when body processing is enabled using GCP Service Extension. This integration will also be updated later when this case will be closed.
Motivation
Body processing needs to be enabled for the GA of the AAP Envoy integration.
Reviewer's Checklist
./scripts/lint.shlocally.Unsure? Have a question? Request a review!