[V3] Allow the callback function to receive and log a http return code #1919
+4
−4
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.
As discussed in #1916, there is an issue where the callback function will not insert the http return code into the message even though the audit log contained the correct message.
ex: callback:
ModSecurity: Access denied with code %d (phase 2). Matched "Operator Rx with parameter a....auditlog:
ModSecurity: Access denied with code 200 (phase 2). Matched "Operator Rx with parameter a...After some digging through the code for the process for the callback I found that the callback is only called through
Transaction::serverLog()which contains the functionModSecurity::serverLog(m_logCbData, rm). ModSecurity has no access/reference to theTransaction::m_httpCodeReturnedso it would have had to been passed byTransaction::serverLog()withthis->m_httpCodeReturnedto be able to be passed into theRuleMessage::log()to generate the callback message. After this patch I am able to get the http return code into the callback function message parameter.Though I am unsure how/if props should be set or in
ModSecurity::serverLog(). I am also unsure in the case thatRuleMessageLogPropertyis set, how to best pass them_httpCodeReturnedto the rule message or callback function.Additionally I noticed in
ModSecurity::serverLog()there might be bug due to the repeated code in the if statement.