Skip to content

Commit b9b2eeb

Browse files
e-n-0eliottness
andauthored
fix(proxy): multiple analysis of truncated body (#3981)
Co-authored-by: Eliott Bouhana <[email protected]>
1 parent 847743a commit b9b2eeb

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

instrumentation/appsec/proxy/body_buffer.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ type bodyBuffer struct {
1010
buffer []byte
1111
sizeLimit int
1212
truncated bool
13+
analyzed bool
1314
}
1415

1516
// newBodyBuffer creates a new bodyBuffer with the specified size limit

instrumentation/appsec/proxy/message_processor.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,14 @@ func (mp *Processor[O]) OnResponseTrailers(_ *RequestState) (*O, error) {
278278
}
279279

280280
func processBody(ctx context.Context, bodyBuffer *bodyBuffer, body []byte, eos bool, analyzeBody func(ctx context.Context, encodable any) error) error {
281+
if bodyBuffer.analyzed {
282+
return nil
283+
}
284+
281285
bodyBuffer.append(body)
282286

283287
if eos || bodyBuffer.truncated {
288+
bodyBuffer.analyzed = true
284289
return analyzeBody(ctx, json.NewEncodableFromData(bodyBuffer.buffer, bodyBuffer.truncated))
285290
}
286291

0 commit comments

Comments
 (0)