fix: cap delayed response-body buffering to bound worker memory - #21
Conversation
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/mod_coraza_filter_out.c`:
- Around line 205-227: Update the cap-exceeded branch in
coraza_append_response_body to remove the output filter with
ap_remove_output_filter(f) before flushing and returning. Preserve the existing
pending-brigade prepend and downstream pass, ensuring subsequent response
brigades bypass Coraza inspection and continue streaming normally.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a014a005-08cd-4f3c-bb5a-da06626971fa
📒 Files selected for processing (5)
Dockerfilesrc/mod_coraza.hsrc/mod_coraza_filter_out.ctest.shtests/cgi-bin/bulk
|
@coderabbitai full review |
✅ Action performedFull review finished. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a configurable 1 MiB cap for delayed response buffering. When the cap is exceeded, buffered data is flushed and inspection stops. A paced 4 MiB CGI endpoint, Docker wiring, and integration checks validate delivery and early header flushing. ChangesDelayed response cap
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@test.sh`:
- Around line 338-353: Update check_size to capture curl’s exit status and HTTP
response status alongside size_download, and only report PASS when curl
succeeds, the HTTP status is successful, and the downloaded size matches
expected. Apply the same validation to the separate size assertion around the
later response measurement, ensuring failures increment FAIL and include the
relevant status/error details.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: d487b5f7-10b2-4294-954a-61a83183f0f5
📒 Files selected for processing (5)
Dockerfilesrc/mod_coraza.hsrc/mod_coraza_filter_out.ctest.shtests/cgi-bin/bulk
Ports coraza-nginx #71. While the header delay holds a response for phase-4 inspection, the output filter reads every body bucket into memory before forwarding — a large download or a long stream would buffer without limit.
The filter now tracks the buffered bytes and, once they pass
CORAZA_MAX_DELAYED_BODY(1 MiB, build-overridable), stops delaying: it flushes the headers + everything buffered so far and lets the rest stream. A later phase-4 match can then no longer render a clean error page (headers are on the wire) — the same trade-off the SSE and 101 paths accept.The check is per-bucket in the read loop, not just on the pending brigade, so it also bounds a single response drained in one filter pass (e.g. a CGI/streamed source), not only multi-brigade proxied responses.
Test (paced 4 MiB CGI, both MPMs): the response arrives intact (200, full 4 MiB) and the cap logs an early flush; without the fix that flush never happens. Suite 144/0.
Summary by CodeRabbit
New Features
Bug Fixes
Tests