Skip to content

Conversation

@M4tteoP
Copy link
Member

@M4tteoP M4tteoP commented Dec 27, 2025

ports to upstream corazawaf/coraza-caddy#235.
cc @hnakamur

@M4tteoP M4tteoP requested a review from a team as a code owner December 27, 2025 17:51
@M4tteoP M4tteoP added the v3.4 label Dec 27, 2025
@codecov
Copy link

codecov bot commented Dec 27, 2025

Codecov Report

❌ Patch coverage is 54.54545% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.24%. Comparing base (93b606a) to head (1940eca).

Files with missing lines Patch % Lines
http/interceptor.go 54.54% 6 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1461      +/-   ##
==========================================
- Coverage   85.27%   85.24%   -0.03%     
==========================================
  Files         173      173              
  Lines        8400     8411      +11     
==========================================
+ Hits         7163     7170       +7     
- Misses        991      993       +2     
- Partials      246      248       +2     
Flag Coverage Δ
coraza.rule.case_sensitive_args_keys 85.20% <54.54%> (-0.03%) ⬇️
coraza.rule.mandatory_rule_id_check 85.23% <54.54%> (-0.03%) ⬇️
coraza.rule.multiphase_evaluation 84.96% <54.54%> (-0.03%) ⬇️
coraza.rule.no_regex_multiline 85.23% <54.54%> (-0.03%) ⬇️
default 85.24% <54.54%> (-0.03%) ⬇️
examples+ 16.51% <ø> (ø)
examples+coraza.rule.case_sensitive_args_keys 85.13% <54.54%> (-0.03%) ⬇️
examples+coraza.rule.mandatory_rule_id_check 85.23% <54.54%> (-0.03%) ⬇️
examples+coraza.rule.multiphase_evaluation 84.75% <54.54%> (-0.03%) ⬇️
examples+coraza.rule.no_regex_multiline 85.07% <54.54%> (-0.03%) ⬇️
examples+memoize_builders 85.18% <54.54%> (-0.03%) ⬇️
examples+no_fs_access 82.82% <54.54%> (-0.03%) ⬇️
ftw 85.24% <54.54%> (-0.03%) ⬇️
memoize_builders 85.36% <54.54%> (-0.03%) ⬇️
no_fs_access 84.76% <54.54%> (-0.03%) ⬇️
tinygo 85.22% <54.54%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes an issue where response body data was not being passed through to downstream after partial processing when the response body limit is reached with ProcessPartial action. The fix ensures that when WriteResponseBody returns fewer bytes than provided (indicating partial processing), the remaining bytes are written directly to the downstream writer.

Key changes:

  • Extracted buffered response body write logic into a reusable method to avoid duplication
  • Modified the Write method to pass through remaining bytes after partial processing
  • Added comprehensive test coverage for various response body processing scenarios

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
http/interceptor.go Added wroteBufferedBodyToDownstream flag to track state, created writeBufferedResponseBodyToDownstream() helper method, and updated Write() method to handle partial writes by passing through remaining bytes
http/interceptor_test.go Added comprehensive TestResponseBody test function covering multiple scenarios including limit rejection, partial processing with and without data leaks, and chunked response handling

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jcchavezs jcchavezs merged commit 8712632 into corazawaf:main Dec 29, 2025
273 of 275 checks passed
@jcchavezs jcchavezs deleted the pass_through_respose_body_after_process_partial branch December 29, 2025 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants