fixed compilation error with disable_debug_log flag

This commit is contained in:
Izik Abramov 2017-12-05 15:35:26 +02:00 committed by Felipe Zimmerle
parent cb182b0dc5
commit cb8d0b068d
5 changed files with 32 additions and 4 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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

View File

@ -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;

View File

@ -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) {