Skip to content

Commit e9f3312

Browse files
Izik AbramovFelipe Zimmerle
authored andcommitted
fixed compilation error with disable_debug_log flag
1 parent 81e1cdc commit e9f3312

File tree

5 files changed

+32
-4
lines changed

5 files changed

+32
-4
lines changed

src/actions/exec.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ bool Exec::init(std::string *error) {
5050

5151

5252
bool Exec::evaluate(Rule *rule, Transaction *t) {
53+
#ifndef NO_LOGS
5354
t->debug(8, "Running script... " + m_script);
54-
55+
#endif
5556
m_lua.run(t);
5657
return true;
5758
}

src/audit_log/audit_log.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,9 @@ bool AuditLog::saveIfRelevant(Transaction *transaction) {
274274
bool AuditLog::saveIfRelevant(Transaction *transaction, int parts) {
275275
bool saveAnyway = false;
276276
if (m_status == OffAuditLogStatus || m_status == NotSetLogStatus) {
277+
#ifndef NO_LOGS
277278
transaction->debug(5, "Audit log engine was not set.");
279+
#endif
278280
return true;
279281
}
280282

src/engine/lua.cc

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,9 @@ int Lua::run(Transaction *t) {
153153
break;
154154
}
155155
e.append(lua_tostring(L, -1));
156+
#ifndef NO_LOGS
156157
t->debug(2, e);
158+
#endif
157159
ret = false;
158160
goto err;
159161
}
@@ -167,7 +169,9 @@ int Lua::run(Transaction *t) {
167169
e.append(" - ");
168170
e.append(luaerr);
169171
}
172+
#ifndef NO_LOGS
170173
t->debug(2, e);
174+
#endif
171175
ret = false;
172176
goto err;
173177
}
@@ -183,7 +187,9 @@ int Lua::run(Transaction *t) {
183187
e.append(" - ");
184188
e.append(luaerr);
185189
}
190+
#ifndef NO_LOGS
186191
t->debug(2, e);
192+
#endif
187193
ret = false;
188194
goto err;
189195
}
@@ -192,8 +198,9 @@ int Lua::run(Transaction *t) {
192198
if (a != NULL) {
193199
luaRet.assign(a);
194200
}
195-
201+
#ifndef NO_LOGS
196202
t->debug(9, "Returning from lua script: " + luaRet);
203+
#endif
197204

198205
if (luaRet.size() == 0) {
199206
ret = false;
@@ -206,7 +213,9 @@ int Lua::run(Transaction *t) {
206213

207214
return ret;
208215
#else
216+
#ifndef NO_LOGS
209217
t->debug(9, "Lua support was not enabled.");
218+
#endif
210219
return false;
211220
#endif
212221
}
@@ -228,7 +237,9 @@ int Lua::log(lua_State *L) {
228237

229238
/* Log message. */
230239
if (t != NULL) {
240+
#ifndef NO_LOGS
231241
t->debug(level, text);
242+
#endif
232243
}
233244

234245
return 0;
@@ -320,7 +331,9 @@ int Lua::setvar(lua_State *L) {
320331

321332

322333
if (nargs != 2) {
334+
#ifndef NO_LOGS
323335
t->debug(8, "m.setvar: Failed m.setvar funtion must has 2 arguments");
336+
#endif
324337
return -1;
325338
}
326339
var_value = luaL_checkstring(L, 2);
@@ -341,8 +354,10 @@ int Lua::setvar(lua_State *L) {
341354
std::string::npos);
342355

343356
} else {
357+
#ifndef NO_LOGS
344358
t->debug(8, "m.setvar: Must specify a collection using dot character" \
345359
" - ie m.setvar(tx.myvar,mydata)");
360+
#endif
346361
return -1;
347362
}
348363

@@ -380,8 +395,10 @@ std::string Lua::applyTransformations(lua_State *L, Transaction *t,
380395
if (tfn) {
381396
newVar = tfn->evaluate(newVar, t);
382397
} else {
398+
#ifndef NO_LOGS
383399
t->debug(1, "SecRuleScript: Invalid transformation function: " \
384400
+ std::string(name));
401+
#endif
385402
}
386403
delete tfn;
387404
}
@@ -402,17 +419,19 @@ std::string Lua::applyTransformations(lua_State *L, Transaction *t,
402419
newVar = tfn->evaluate(newVar, t);
403420
delete tfn;
404421
} else {
422+
#ifndef NO_LOGS
405423
t->debug(1, "SecRuleScript: Invalid transformation function: " \
406424
+ std::string(name));
425+
#endif
407426
}
408427
return newVar;
409428
}
410-
429+
#ifndef NO_LOGS
411430
t->debug(8, "SecRuleScript: Transformation parameter must be a " \
412431
"transformation name or array of transformation names, but found " \
413432
"" + std::string(lua_typename(L, idx)) + " (type " \
414433
+ std::to_string(lua_type(L, idx)) + ")");
415-
434+
#endif
416435
return newVar;
417436
}
418437
#endif

src/operators/fuzzy_hash.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,19 @@ bool FuzzyHash::evaluate(Transaction *t, const std::string &str) {
104104

105105
if (fuzzy_hash_buf((const unsigned char*)str.c_str(),
106106
str.size(), result)) {
107+
#ifndef NO_LOGS
107108
t->debug(4, "Problems generating fuzzy hash");
109+
#endif
108110
return false;
109111
}
110112

111113
while (chunk != NULL) {
112114
int i = fuzzy_compare(chunk->data, result);
113115
if (i >= m_threshold) {
116+
#ifndef NO_LOGS
114117
t->debug(4, "Fuzzy hash: matched " \
115118
"with score: " + std::to_string(i) + ".");
119+
#endif
116120
return true;
117121
}
118122
chunk = chunk->next;

src/rule_script.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ bool RuleScript::init(std::string *err) {
2424

2525
bool RuleScript::evaluate(Transaction *trans,
2626
std::shared_ptr<RuleMessage> ruleMessage) {
27+
#ifndef NO_LOGS
2728
trans->debug(4, " Executing script: " + m_name + ".");
29+
#endif
2830
bool containsDisruptive = false;
2931

3032
if (ruleMessage == NULL) {

0 commit comments

Comments
 (0)