mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
fixed compilation error with disable_debug_log flag
This commit is contained in:
parent
81e1cdced3
commit
e9f3312ea9
@ -50,8 +50,9 @@ bool Exec::init(std::string *error) {
|
||||
|
||||
|
||||
bool Exec::evaluate(Rule *rule, Transaction *t) {
|
||||
#ifndef NO_LOGS
|
||||
t->debug(8, "Running script... " + m_script);
|
||||
|
||||
#endif
|
||||
m_lua.run(t);
|
||||
return true;
|
||||
}
|
||||
|
@ -274,7 +274,9 @@ bool AuditLog::saveIfRelevant(Transaction *transaction) {
|
||||
bool AuditLog::saveIfRelevant(Transaction *transaction, int parts) {
|
||||
bool saveAnyway = false;
|
||||
if (m_status == OffAuditLogStatus || m_status == NotSetLogStatus) {
|
||||
#ifndef NO_LOGS
|
||||
transaction->debug(5, "Audit log engine was not set.");
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,9 @@ int Lua::run(Transaction *t) {
|
||||
break;
|
||||
}
|
||||
e.append(lua_tostring(L, -1));
|
||||
#ifndef NO_LOGS
|
||||
t->debug(2, e);
|
||||
#endif
|
||||
ret = false;
|
||||
goto err;
|
||||
}
|
||||
@ -167,7 +169,9 @@ int Lua::run(Transaction *t) {
|
||||
e.append(" - ");
|
||||
e.append(luaerr);
|
||||
}
|
||||
#ifndef NO_LOGS
|
||||
t->debug(2, e);
|
||||
#endif
|
||||
ret = false;
|
||||
goto err;
|
||||
}
|
||||
@ -183,7 +187,9 @@ int Lua::run(Transaction *t) {
|
||||
e.append(" - ");
|
||||
e.append(luaerr);
|
||||
}
|
||||
#ifndef NO_LOGS
|
||||
t->debug(2, e);
|
||||
#endif
|
||||
ret = false;
|
||||
goto err;
|
||||
}
|
||||
@ -192,8 +198,9 @@ int Lua::run(Transaction *t) {
|
||||
if (a != NULL) {
|
||||
luaRet.assign(a);
|
||||
}
|
||||
|
||||
#ifndef NO_LOGS
|
||||
t->debug(9, "Returning from lua script: " + luaRet);
|
||||
#endif
|
||||
|
||||
if (luaRet.size() == 0) {
|
||||
ret = false;
|
||||
@ -206,7 +213,9 @@ err:
|
||||
|
||||
return ret;
|
||||
#else
|
||||
#ifndef NO_LOGS
|
||||
t->debug(9, "Lua support was not enabled.");
|
||||
#endif
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
@ -228,7 +237,9 @@ int Lua::log(lua_State *L) {
|
||||
|
||||
/* Log message. */
|
||||
if (t != NULL) {
|
||||
#ifndef NO_LOGS
|
||||
t->debug(level, text);
|
||||
#endif
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -320,7 +331,9 @@ int Lua::setvar(lua_State *L) {
|
||||
|
||||
|
||||
if (nargs != 2) {
|
||||
#ifndef NO_LOGS
|
||||
t->debug(8, "m.setvar: Failed m.setvar funtion must has 2 arguments");
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
var_value = luaL_checkstring(L, 2);
|
||||
@ -341,8 +354,10 @@ int Lua::setvar(lua_State *L) {
|
||||
std::string::npos);
|
||||
|
||||
} else {
|
||||
#ifndef NO_LOGS
|
||||
t->debug(8, "m.setvar: Must specify a collection using dot character" \
|
||||
" - ie m.setvar(tx.myvar,mydata)");
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -380,8 +395,10 @@ std::string Lua::applyTransformations(lua_State *L, Transaction *t,
|
||||
if (tfn) {
|
||||
newVar = tfn->evaluate(newVar, t);
|
||||
} else {
|
||||
#ifndef NO_LOGS
|
||||
t->debug(1, "SecRuleScript: Invalid transformation function: " \
|
||||
+ std::string(name));
|
||||
#endif
|
||||
}
|
||||
delete tfn;
|
||||
}
|
||||
@ -402,17 +419,19 @@ std::string Lua::applyTransformations(lua_State *L, Transaction *t,
|
||||
newVar = tfn->evaluate(newVar, t);
|
||||
delete tfn;
|
||||
} else {
|
||||
#ifndef NO_LOGS
|
||||
t->debug(1, "SecRuleScript: Invalid transformation function: " \
|
||||
+ std::string(name));
|
||||
#endif
|
||||
}
|
||||
return newVar;
|
||||
}
|
||||
|
||||
#ifndef NO_LOGS
|
||||
t->debug(8, "SecRuleScript: Transformation parameter must be a " \
|
||||
"transformation name or array of transformation names, but found " \
|
||||
"" + std::string(lua_typename(L, idx)) + " (type " \
|
||||
+ std::to_string(lua_type(L, idx)) + ")");
|
||||
|
||||
#endif
|
||||
return newVar;
|
||||
}
|
||||
#endif
|
||||
|
@ -104,15 +104,19 @@ bool FuzzyHash::evaluate(Transaction *t, const std::string &str) {
|
||||
|
||||
if (fuzzy_hash_buf((const unsigned char*)str.c_str(),
|
||||
str.size(), result)) {
|
||||
#ifndef NO_LOGS
|
||||
t->debug(4, "Problems generating fuzzy hash");
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
while (chunk != NULL) {
|
||||
int i = fuzzy_compare(chunk->data, result);
|
||||
if (i >= m_threshold) {
|
||||
#ifndef NO_LOGS
|
||||
t->debug(4, "Fuzzy hash: matched " \
|
||||
"with score: " + std::to_string(i) + ".");
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
chunk = chunk->next;
|
||||
|
@ -24,7 +24,9 @@ bool RuleScript::init(std::string *err) {
|
||||
|
||||
bool RuleScript::evaluate(Transaction *trans,
|
||||
std::shared_ptr<RuleMessage> ruleMessage) {
|
||||
#ifndef NO_LOGS
|
||||
trans->debug(4, " Executing script: " + m_name + ".");
|
||||
#endif
|
||||
bool containsDisruptive = false;
|
||||
|
||||
if (ruleMessage == NULL) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user