Adds support to m_highlightJSON in RuleMessage class

This variable helds a JSON with information regarding all matches.
Only filled when IncludeFullHighlightLog property is set.
This commit is contained in:
Felipe Zimmerle 2018-10-11 10:00:59 -03:00
parent eec95cfe17
commit e83f66ee49
No known key found for this signature in database
GPG Key ID: E6DFB08CE8B11277
6 changed files with 13 additions and 3 deletions

View File

@ -237,6 +237,10 @@ end:
modsecurity::RuleMessage::computeHighlight(ruleMessage,
ruleMessage->m_buf);
highlightToText(h);
std::cout << "Highlight JSON:" << std::endl;
std::cout << ruleMessage->m_highlightJSON << std::endl;
std::cout << "Request:" << std::endl;
std::cout << ruleMessage->m_buf;
std::cout << std::endl;
}

View File

@ -262,7 +262,7 @@ extern "C" {
* Notice that the highlight can be calculate post-analisys. Calculate it
* during the analisys may delay the analisys process.
*
*/
*/
IncludeFullHighlightLogProperty = 4,
};

View File

@ -151,6 +151,7 @@ class RuleMessage {
std::list<std::string> m_tags;
RuleMessageHighlight m_highlight;
std::string m_highlightJSON;
};

View File

@ -215,7 +215,7 @@ SecDataDir /tmp/
# trigger a server error (determined by a 5xx or 4xx, excluding 404,
# level response status codes).
#
SecAuditEngine RelevantOnly
SecAuditEngine Off
SecAuditLogRelevantStatus "^(?:5|4(?!04))"
# Log everything we know about a transaction.

View File

@ -207,6 +207,8 @@ void ModSecurity::serverLog(void *data, std::shared_ptr<RuleMessage> rm) {
if (m_logProperties & RuleMessageLogProperty) {
const void *a = static_cast<const void *>(rm.get());
if (m_logProperties & IncludeFullHighlightLogProperty) {
processContentOffset(rm->m_buf.c_str(), rm->m_buf.size(),
rm->m_reference.c_str(), &rm->m_highlightJSON, NULL);
m_logCb(data, a);
return;
}

View File

@ -93,7 +93,10 @@ std::string RuleMessage::log(const RuleMessage *rm, int props, int code) {
return modsecurity::utils::string::toHexIfNeeded(msg);
}
/*
* Depricated. Do not use. Should be removed before merge.
*
*/
RuleMessageHighlight RuleMessage::computeHighlight(const RuleMessage *rm,
const std::string buf) {
RuleMessageHighlight ret;