fix: log resolved client_ip in WAF violation log (supersedes #306, adds tests) - #321
Open
boecks wants to merge 2 commits into
Open
fix: log resolved client_ip in WAF violation log (supersedes #306, adds tests)#321boecks wants to merge 2 commits into
boecks wants to merge 2 commits into
Conversation
In addition to the pull request https://github.com/corazawaf/coraza-caddy/pull/184/changes for setting the correct client_ip IP via getClientAddress, the generation of the error log with the correct IP has been left out of the change.
End-to-end regression test for the client_ip fix: a request through a trusted proxy with X-Forwarded-For triggers a deny rule; the emitted 'WAF rule violation detected' log entry must report the forwarded client IP, not the proxy's RemoteAddr. Fails without the fix. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughChangesClient IP violation logging
🚥 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This carries the one-line fix from #306 unchanged — original commit by @thelogh, authorship preserved via cherry-pick — rebased onto current
main, plus the end-to-end regression test requested in the #306 review: a request arriving through a trusted proxy withX-Forwarded-Fortriggers a deny rule, and the test asserts theWAF rule violation detectedlog entry reports the forwarded client IP rather than the proxy'sRemoteAddr. The test fails without the fix and passes with it.Context: @thelogh did write tests in response to the review, but they were opened as thelogh#1 against his own fork's
mainrather than thepatch-1branch backing #306, so they never surfaced there and #306 has been stalled since early June. Not trying to take anything over — if @thelogh updatespatch-1instead, happy to close this one.Field report: we've been running this exact fix in production since mid-June (fork pin in an xcaddy build) on a public-facing Caddy edge with Coraza + OWASP CRS in front of ~14 vhosts, alongside CrowdSec log ingestion that consumes these violation logs — the corrected
client_ipis what makes those logs actionable for banning. No regressions observed; we'd love to retire the fork.Summary by CodeRabbit
Bug Fixes
Tests