mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-30 11:44:32 +03:00
Adds checks for the NO_LOGS definition and improved the vars resolution time
This commit is contained in:
@@ -33,7 +33,9 @@ Block::Block(std::string action)
|
||||
|
||||
|
||||
bool Block::evaluate(Rule *rule, Assay *assay) {
|
||||
#ifndef NO_LOGS
|
||||
assay->debug(8, "Running action block");
|
||||
#endif
|
||||
for (Action *a : rule->actions_runtime_pos) {
|
||||
if (a->isDisruptive() == true) {
|
||||
assay->actions.push_back(a);
|
||||
|
@@ -35,17 +35,16 @@ bool Capture::evaluate(Rule *rule, Assay *assay) {
|
||||
std::list<std::string> match;
|
||||
|
||||
operators::Pm *pm = dynamic_cast<operators::Pm *>(op);
|
||||
operators::Rx *rx = dynamic_cast<operators::Rx *>(op);
|
||||
operators::Contains *contains = dynamic_cast<operators::Contains *>(op);
|
||||
|
||||
if (pm != NULL) {
|
||||
match = pm->matched;
|
||||
}
|
||||
|
||||
operators::Rx *rx = dynamic_cast<operators::Rx *>(op);
|
||||
if (rx != NULL) {
|
||||
match = rx->matched;
|
||||
}
|
||||
|
||||
operators::Contains *contains = dynamic_cast<operators::Contains *>(op);
|
||||
if (contains != NULL) {
|
||||
match = contains->matched;
|
||||
}
|
||||
|
@@ -31,7 +31,9 @@ Deny::Deny(std::string action)
|
||||
|
||||
|
||||
bool Deny::evaluate(Rule *rule, Assay *assay) {
|
||||
#ifndef NO_LOGS
|
||||
assay->debug(8, "Running action deny");
|
||||
#endif
|
||||
assay->actions.push_back(this);
|
||||
return true;
|
||||
}
|
||||
|
@@ -36,7 +36,9 @@ LogData::LogData(std::string action)
|
||||
|
||||
bool LogData::evaluate(Rule *rule, Assay *assay) {
|
||||
std::string msg = MacroExpansion::expand(m_data, assay);
|
||||
#ifndef NO_LOGS
|
||||
assay->debug(9, "Saving msg: " + msg);
|
||||
#endif
|
||||
assay->rulesMessages.push_back(msg);
|
||||
assay->serverLog(msg);
|
||||
return true;
|
||||
|
@@ -36,7 +36,9 @@ Msg::Msg(std::string action)
|
||||
|
||||
bool Msg::evaluate(Rule *rule, Assay *assay) {
|
||||
std::string msg = MacroExpansion::expand(m_msg, assay);
|
||||
#ifndef NO_LOGS
|
||||
assay->debug(9, "Saving msg: " + msg);
|
||||
#endif
|
||||
assay->rulesMessages.push_back(msg);
|
||||
assay->serverLog(msg);
|
||||
return true;
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#include "modsecurity/assay.h"
|
||||
#include "src/rule.h"
|
||||
#include "src/macro_expansion.h"
|
||||
#include "src/utils.h"
|
||||
|
||||
namespace ModSecurity {
|
||||
namespace actions {
|
||||
@@ -57,6 +58,7 @@ bool SetVar::init(std::string *error) {
|
||||
pos = action.find(".");
|
||||
if (pos != std::string::npos) {
|
||||
collectionName = std::string(action, 0, pos);
|
||||
collectionName = toupper(collectionName);
|
||||
} else {
|
||||
error->assign("Missing the collection and/or variable name");
|
||||
return false;
|
||||
@@ -140,8 +142,10 @@ bool SetVar::evaluate(Rule *rule, Assay *assay) {
|
||||
break;
|
||||
}
|
||||
|
||||
#ifndef NO_LOGS
|
||||
assay->debug(8, "Saving variable: " + collectionName + ":" + \
|
||||
variableName + " with value: " + targetValue);
|
||||
#endif
|
||||
assay->setCollection(collectionName, variableName, targetValue);
|
||||
|
||||
return true;
|
||||
|
@@ -51,9 +51,11 @@ Severity::Severity(std::string action)
|
||||
|
||||
|
||||
bool Severity::evaluate(Rule *rule, Assay *assay) {
|
||||
#ifndef NO_LOGS
|
||||
assay->debug(9, "This rule severity is: " + \
|
||||
std::to_string(this->m_severity) + " current assay is: " + \
|
||||
std::to_string(assay->highest_severity));
|
||||
#endif
|
||||
|
||||
if (assay->highest_severity > this->m_severity) {
|
||||
assay->highest_severity = this->m_severity;
|
||||
|
@@ -32,7 +32,9 @@ SkipAfter::SkipAfter(std::string action)
|
||||
|
||||
|
||||
bool SkipAfter::evaluate(Rule *rule, Assay *assay) {
|
||||
#ifndef NO_LOGS
|
||||
assay->debug(5, "Setting skipAfter for: " + m_marker);
|
||||
#endif
|
||||
assay->m_marker = m_marker;
|
||||
return true;
|
||||
}
|
||||
|
@@ -36,7 +36,9 @@ Tag::Tag(std::string action)
|
||||
|
||||
bool Tag::evaluate(Rule *rule, Assay *assay) {
|
||||
std::string tag = MacroExpansion::expand(m_tag, assay);
|
||||
#ifndef NO_LOGS
|
||||
assay->debug(9, "Rule tag: " + tag);
|
||||
#endif
|
||||
assay->ruleTags.push_back(tag);
|
||||
return true;
|
||||
}
|
||||
|
@@ -41,7 +41,9 @@ std::string Base64Decode::evaluate(std::string value,
|
||||
* @todo Implement the transformation base64decode
|
||||
*/
|
||||
if (assay) {
|
||||
#ifndef NO_LOGS
|
||||
assay->debug(4, "Transformation 64 is not implemented yet.");
|
||||
#endif
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
@@ -41,8 +41,10 @@ std::string Base64DecodeExt::evaluate(std::string value,
|
||||
* @todo Implement the transformation Base64DecodeExt
|
||||
*/
|
||||
if (assay) {
|
||||
#ifndef NO_LOGS
|
||||
assay->debug(4, "Transformation Base64DecodeExt is" \
|
||||
" not implemented yet.");
|
||||
#endif
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
@@ -41,7 +41,9 @@ std::string CmdLine::evaluate(std::string value,
|
||||
* @todo Implement the transformation CmdLine
|
||||
*/
|
||||
if (assay) {
|
||||
#ifndef NO_LOGS
|
||||
assay->debug(4, "Transformation CmdLine is not implemented yet.");
|
||||
#endif
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
@@ -41,8 +41,10 @@ std::string CompressWhitespace::evaluate(std::string value,
|
||||
* @todo Implement the transformation CompressWhitespace
|
||||
*/
|
||||
if (assay) {
|
||||
#ifndef NO_LOGS
|
||||
assay->debug(4, "Transformation CompressWhitespace is " \
|
||||
"not implemented yet.");
|
||||
#endif
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
@@ -41,8 +41,10 @@ std::string EscapeSeqDecode::evaluate(std::string value,
|
||||
* @todo Implement the transformation EscapeSeqDecode
|
||||
*/
|
||||
if (assay) {
|
||||
#ifndef NO_LOGS
|
||||
assay->debug(4, "Transformation EscapeSeqDecode is " \
|
||||
"not implemented yet.");
|
||||
#endif
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
@@ -41,7 +41,9 @@ std::string HexDecode::evaluate(std::string value,
|
||||
* @todo Implement the transformation HexDecode
|
||||
*/
|
||||
if (assay) {
|
||||
#ifndef NO_LOGS
|
||||
assay->debug(4, "Transformation HexDecode is not implemented yet.");
|
||||
#endif
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
@@ -41,7 +41,9 @@ std::string HexEncode::evaluate(std::string value,
|
||||
* @todo Implement the transformation HexEncode
|
||||
*/
|
||||
if (assay) {
|
||||
#ifndef NO_LOGS
|
||||
assay->debug(4, "Transformation HexEncode is not implemented yet.");
|
||||
#endif
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
@@ -41,7 +41,9 @@ std::string Length::evaluate(std::string value,
|
||||
* @todo Implement the transformation Length
|
||||
*/
|
||||
if (assay) {
|
||||
#ifndef NO_LOGS
|
||||
assay->debug(4, "Transformation Length is not implemented yet.");
|
||||
#endif
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
@@ -41,7 +41,9 @@ std::string Md5::evaluate(std::string value,
|
||||
* @todo Implement the transformation Md5
|
||||
*/
|
||||
if (assay) {
|
||||
#ifndef NO_LOGS
|
||||
assay->debug(4, "Transformation Md5 is not implemented yet.");
|
||||
#endif
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
@@ -41,8 +41,10 @@ std::string NormalisePath::evaluate(std::string value,
|
||||
* @todo Implement the transformation NormalisePath
|
||||
*/
|
||||
if (assay) {
|
||||
#ifndef NO_LOGS
|
||||
assay->debug(4, "Transformation NormalisePath is not" \
|
||||
" implemented yet.");
|
||||
#endif
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
@@ -41,8 +41,10 @@ std::string ParityEven7bit::evaluate(std::string value,
|
||||
* @todo Implement the transformation ParityEven7bit
|
||||
*/
|
||||
if (assay) {
|
||||
#ifndef NO_LOGS
|
||||
assay->debug(4, "Transformation ParityEven7bit is not" \
|
||||
" implemented yet.");
|
||||
#endif
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
@@ -41,8 +41,10 @@ std::string ParityOdd7bit::evaluate(std::string value,
|
||||
* @todo Implement the transformation ParityOdd7bit
|
||||
*/
|
||||
if (assay) {
|
||||
#ifndef NO_LOGS
|
||||
assay->debug(4, "Transformation ParityOdd7bit is not " \
|
||||
"implemented yet.");
|
||||
#endif
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
@@ -41,8 +41,10 @@ std::string ParityZero7bit::evaluate(std::string value,
|
||||
* @todo Implement the transformation ParityZero7bit
|
||||
*/
|
||||
if (assay) {
|
||||
#ifndef NO_LOGS
|
||||
assay->debug(4, "Transformation ParityZero7bit is not" \
|
||||
"implemented yet.");
|
||||
#endif
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
@@ -41,8 +41,10 @@ std::string RemoveComments::evaluate(std::string value,
|
||||
* @todo Implement the transformation RemoveComments
|
||||
*/
|
||||
if (assay) {
|
||||
#ifndef NO_LOGS
|
||||
assay->debug(4, "Transformation RemoveComments is not " \
|
||||
"implemented yet.");
|
||||
#endif
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
@@ -41,8 +41,10 @@ std::string RemoveCommentsChar::evaluate(std::string value,
|
||||
* @todo Implement the transformation RemoveCommentsChar
|
||||
*/
|
||||
if (assay) {
|
||||
#ifndef NO_LOGS
|
||||
assay->debug(4, "Transformation RemoveCommentsChar " \
|
||||
"is not implemented yet.");
|
||||
#endif
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
@@ -41,8 +41,10 @@ std::string RemoveWhitespace::evaluate(std::string value,
|
||||
* @todo Implement the transformation RemoveWhitespace
|
||||
*/
|
||||
if (assay) {
|
||||
#ifndef NO_LOGS
|
||||
assay->debug(4, "Transformation RemoveWhitespace is " \
|
||||
"not implemented yet.");
|
||||
#endif
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
@@ -41,8 +41,10 @@ std::string ReplaceComments::evaluate(std::string value,
|
||||
* @todo Implement the transformation ReplaceComments
|
||||
*/
|
||||
if (assay) {
|
||||
#ifndef NO_LOGS
|
||||
assay->debug(4, "Transformation ReplaceComments " \
|
||||
"is not implemented yet.");
|
||||
#endif
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
@@ -41,7 +41,9 @@ std::string ReplaceNulls::evaluate(std::string value,
|
||||
* @todo Implement the transformation ReplaceNulls
|
||||
*/
|
||||
if (assay) {
|
||||
#ifndef NO_LOGS
|
||||
assay->debug(4, "Transformation ReplaceNulls is not implemented yet.");
|
||||
#endif
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
@@ -41,7 +41,9 @@ std::string Sha1::evaluate(std::string value,
|
||||
* @todo Implement the transformation Sha1
|
||||
*/
|
||||
if (assay) {
|
||||
#ifndef NO_LOGS
|
||||
assay->debug(4, "Transformation Sha1 is not implemented yet.");
|
||||
#endif
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
@@ -41,7 +41,9 @@ std::string SqlHexDecode::evaluate(std::string value,
|
||||
* @todo Implement the transformation SqlHexDecode
|
||||
*/
|
||||
if (assay) {
|
||||
#ifndef NO_LOGS
|
||||
assay->debug(4, "Transformation SqlHexDecode is not implemented yet.");
|
||||
#endif
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
@@ -41,7 +41,9 @@ std::string UrlDecode::evaluate(std::string value,
|
||||
* @todo Implement the transformation UrlDecode
|
||||
*/
|
||||
if (assay) {
|
||||
#ifndef NO_LOGS
|
||||
assay->debug(4, "Transformation UrlDecode is not implemented yet.");
|
||||
#endif
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
@@ -41,7 +41,9 @@ std::string UrlEncode::evaluate(std::string value,
|
||||
* @todo Implement the transformation UrlEncode
|
||||
*/
|
||||
if (assay) {
|
||||
#ifndef NO_LOGS
|
||||
assay->debug(4, "Transformation UrlEncode is not implemented yet.");
|
||||
#endif
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
@@ -41,7 +41,9 @@ std::string Utf8Unicode::evaluate(std::string value,
|
||||
* @todo Implement the transformation Utf8Unicode
|
||||
*/
|
||||
if (assay) {
|
||||
#ifndef NO_LOGS
|
||||
assay->debug(4, "Transformation Utf8Unicode is not implemented yet.");
|
||||
#endif
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
Reference in New Issue
Block a user