mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-11-15 17:12:14 +03:00
First version of the inline highlight calculation
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
SecRule ARGS:param1 "test" "id:1,deny,phase:2,chain,msg:'test'"
|
||||
SecRule ARGS:param1 "test" "id:1,deny,phase:2,t:lowercase,chain,msg:'test'"
|
||||
SecRule ARGS:param1 "test" "log"
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
SecRuleEngine On
|
||||
SecRule ARGS:param1 "test" "id:1,deny"
|
||||
SecRule ARGS:param1 "test" "id:1,deny,t:lowercase"
|
||||
|
||||
@@ -1 +1 @@
|
||||
SecRule ARGS:param1 "test" "id:1,deny,msg:'this',msg:'is',msg:'a',msg:'test'"
|
||||
SecRule ARGS:param1 "test" "id:1,deny,msg:'this',t:replaceNulls,msg:'is',msg:'a',msg:'test',t:lowercase,t:trim"
|
||||
|
||||
@@ -1 +1 @@
|
||||
SecRule ARGS:param1 "WHEEE" "id:1,phase:2,deny,msg:'this',msg:'is',msg:'a',msg:'test'"
|
||||
SecRule ARGS:param1 "WHEEE" "id:1,phase:2,deny,msg:'this',msg:'is',msg:'a',msg:'test',t:lower"
|
||||
|
||||
@@ -163,7 +163,6 @@ class ReadingLogsViaRuleMessage {
|
||||
pthread_join(threads[i], &status);
|
||||
std::cout << "Main: completed thread id :" << i << std::endl;
|
||||
}
|
||||
|
||||
delete rules;
|
||||
delete modsec;
|
||||
pthread_exit(NULL);
|
||||
@@ -172,6 +171,38 @@ end:
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
static std::string highlightToText(
|
||||
const modsecurity::RuleMessageHighlight &h) {
|
||||
std::cout << " * ModSecurity variable to be highlighted" << std::endl;
|
||||
|
||||
for (const auto &i : h.m_variable) {
|
||||
std::cout << " - From: " << std::to_string(i.m_startingAt);
|
||||
std::cout << " to: " << std::to_string(i.m_startingAt + i.m_size);
|
||||
std::cout << std::endl;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
std::cout << " * Variable's values ";
|
||||
std::cout << "(may include transformations)" << std::endl;
|
||||
for (const auto &i : h.m_value) {
|
||||
std::cout << " - " << i.first << ": " << i.second << std::endl;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
std::cout << " * Operators match to be highlight inside ";
|
||||
std::cout << "the variables (after transformations)" << std::endl;
|
||||
|
||||
for (const auto &i : h.m_op) {
|
||||
std::cout << " - From: " << i.m_area.m_startingAt;
|
||||
std::cout << " to: " << std::to_string(i.m_area.m_startingAt \
|
||||
+ i.m_area.m_size);
|
||||
std::cout << " [Value: " << i.m_value << "]" << std::endl;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
return "";
|
||||
}
|
||||
|
||||
static void logCb(void *data, const void *ruleMessagev) {
|
||||
if (ruleMessagev == NULL) {
|
||||
std::cout << "I've got a call but the message was null ;(";
|
||||
@@ -196,6 +227,17 @@ end:
|
||||
std::cout << modsecurity::RuleMessage::log(ruleMessage);
|
||||
std::cout << std::endl;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
std::cout << "Verbose details on the match highlight" << std::endl;
|
||||
std::cout << " Highlight reference string: ";
|
||||
std::cout << ruleMessage->m_reference << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << "Details:" << std::endl;
|
||||
modsecurity::RuleMessageHighlight h =
|
||||
modsecurity::RuleMessage::computeHighlight(ruleMessage,
|
||||
ruleMessage->m_buf);
|
||||
highlightToText(h);
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
@@ -32,7 +32,7 @@ int main(int argc, char **argv) {
|
||||
*(argv++);
|
||||
std::string rules(*argv);
|
||||
ReadingLogsViaRuleMessage rlvrm(request_header, request_uri, request_body,
|
||||
response_headers, response_body, ip, rules);
|
||||
"", response_body, ip, rules);
|
||||
rlvrm.process();
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user