Skip to content

Commit 9fa2200

Browse files
Update detect_sqli.cc
1 parent 7c104e4 commit 9fa2200

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/operators/detect_sqli.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ namespace modsecurity::operators {
2929

3030
bool DetectSQLi::evaluate(Transaction *t, RuleWithActions *rule,
3131
const std::string& input, RuleMessage &ruleMessage) {
32+
#ifndef NO_LOGS
3233
const std::string loggable_input =
3334
utils::string::limitTo(80, utils::string::toHexIfNeeded(input));
35+
#endif
3436

3537
std::array<char, 8> fingerprint{};
3638

@@ -45,9 +47,11 @@ bool DetectSQLi::evaluate(Transaction *t, RuleWithActions *rule,
4547
case LIBINJECTION_RESULT_TRUE:
4648
t->m_matched.emplace_back(fingerprint.data());
4749

50+
#ifndef NO_LOGS
4851
ms_dbg_a(t, 4,
4952
std::string("detected SQLi using libinjection with fingerprint '")
5053
+ fingerprint.data() + "' at: '" + loggable_input + "'");
54+
#endif
5155

5256
if (rule != nullptr && rule->hasCaptureAction()) {
5357
t->m_collections.m_tx_collection->storeOrUpdateFirst(
@@ -60,11 +64,13 @@ bool DetectSQLi::evaluate(Transaction *t, RuleWithActions *rule,
6064
break;
6165

6266
case LIBINJECTION_RESULT_ERROR:
67+
#ifndef NO_LOGS
6368
ms_dbg_a(t, 4,
6469
std::string("libinjection parser error during SQLi analysis (")
6570
+ libinjectionResultToString(sqli_result)
6671
+ "); treating as match (fail-safe). Input: '"
6772
+ loggable_input + "'");
73+
#endif
6874

6975
if (rule != nullptr && rule->hasCaptureAction()) {
7076
t->m_collections.m_tx_collection->storeOrUpdateFirst(
@@ -80,9 +86,11 @@ bool DetectSQLi::evaluate(Transaction *t, RuleWithActions *rule,
8086
break;
8187

8288
case LIBINJECTION_RESULT_FALSE:
89+
#ifndef NO_LOGS
8390
ms_dbg_a(t, 9,
8491
std::string("libinjection was not able to find any SQLi in: ")
8592
+ loggable_input);
93+
#endif
8694
break;
8795
}
8896

0 commit comments

Comments
 (0)