-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Escape error.log fields ('data', etc.) value #2854
Conversation
May be we should add the new function here too: --- a/src/operators/operator.cc
+++ b/src/operators/operator.cc
@@ -112,17 +112,17 @@ std::string Operator::resolveMatchMessage(Transaction *t,
if (m_couldContainsMacro == false) {
ret = "Matched \"Operator `" + m_op + "' with parameter `" +
utils::string::limitTo(200, m_param) +
- "' against variable `" + key + "' (Value: `" +
- utils::string::limitTo(100,
- utils::string::toHexIfNeeded(value)) + \
+ "' against variable `" +
+ utils::string::log_escape_hex(utils::string::limitTo(100, key)) + "' (Value: `" +
+ utils::string::log_escape_hex(utils::string::limitTo(100, value)) +
"' )";
} else {
std::string p(m_string->evaluate(t));
ret = "Matched \"Operator `" + m_op + "' with parameter `" +
utils::string::limitTo(200, p) +
- "' against variable `" + key + "' (Value: `" +
- utils::string::limitTo(100,
- utils::string::toHexIfNeeded(value)) +
+ "' against variable `" +
+ utils::string::log_escape_hex(utils::string::limitTo(100, key)) + "' (Value: `" +
+ utils::string::log_escape_hex(utils::string::limitTo(100, value)) +
"' )";
}
} I didn't find any occurrence where the user input appears. There is a similar function toHexIfNeeded(), but it does not encode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments both for when a new function should be called, and comments about specifics about a new function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good. Thanks.
This patch escapes the log's
data
field, similar as mod_security2 does.The aim is to help to process the content for log parsers.