Implement Phase 4 handling for ModSecurity-nginx#377
Open
Easton97-Jens wants to merge 16 commits into
Open
Conversation
…strict test config
…rvention-handling-in-modsecurity-nginx Phase 4: configurable handling, content-type scoping and JSON logging
…igs-and-document-phase-4-functionality docs: add bilingual Phase-4 handling docs and example configurations
…n-modsecurity-proxy Guard allocations, tighten phase4 content-type parsing, and update tests
|
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.



What changed
This PR introduces and stabilizes dedicated
phase:4handling for the nginx ModSecurity connector.Main additions include:
minimalsafestrictmodsecurity_phase4_logmodsecurity_phase4_content_types_fileAdditional fixes included in this PR:
Why these changes
phase:4operates on response bodies. At this stage, nginx may already have sent response headers or even part of the response body.Because of this technical limitation, actions such as:
denystatusredirectcannot always be converted into a clean client-visible HTTP response once headers are already sent.
This PR introduces explicit and predictable handling for those late-intervention scenarios:
minimal→ downgrade to
log_onlysafe→ downgrade to
log_only(default-safe production behavior)strict→ optional
connection_abortThe goal is to:
Logging and observability
The new phase4 logging implementation provides structured JSON-lines logging including fields such as:
Tests also verify that response-body payload data is not leaked into phase4 logs.
Testing
This PR adds and extends coverage for:
Documentation
Comprehensive documentation for the implemented behavior was added, including:
phase:4