diff --git a/src/actions/exec.cc b/src/actions/exec.cc index e295b7ed..c7dae9ba 100644 --- a/src/actions/exec.cc +++ b/src/actions/exec.cc @@ -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; } diff --git a/src/audit_log/audit_log.cc b/src/audit_log/audit_log.cc index 2db18e52..5c8e2497 100644 --- a/src/audit_log/audit_log.cc +++ b/src/audit_log/audit_log.cc @@ -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; } diff --git a/src/engine/lua.cc b/src/engine/lua.cc index f300d0b4..c4386ae1 100644 --- a/src/engine/lua.cc +++ b/src/engine/lua.cc @@ -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 diff --git a/src/operators/fuzzy_hash.cc b/src/operators/fuzzy_hash.cc index db415df5..422714af 100644 --- a/src/operators/fuzzy_hash.cc +++ b/src/operators/fuzzy_hash.cc @@ -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; diff --git a/src/rule_script.cc b/src/rule_script.cc index dba252b5..425b20ef 100644 --- a/src/rule_script.cc +++ b/src/rule_script.cc @@ -24,7 +24,9 @@ bool RuleScript::init(std::string *err) { bool RuleScript::evaluate(Transaction *trans, std::shared_ptr ruleMessage) { +#ifndef NO_LOGS trans->debug(4, " Executing script: " + m_name + "."); +#endif bool containsDisruptive = false; if (ruleMessage == NULL) {