Refactoring on the Rule class

This commit is contained in:
Felipe Zimmerle
2018-09-28 10:28:02 -03:00
parent 74841779f8
commit 554251bade
17 changed files with 474 additions and 630 deletions

View File

@@ -40,8 +40,7 @@ bool DetectSQLi::evaluate(Transaction *t, Rule *rule,
"fingerprint '" + std::string(fingerprint) + "' at: '" +
input + "'");
#endif
if (rule && t
&& rule->getActionsByName("capture", t).size() > 0) {
if (rule && t && rule->m_containsCaptureAction) {
t->m_collections.m_tx_collection->storeOrUpdateFirst(
"0", std::string(fingerprint));
#ifndef NO_LOGS

View File

@@ -36,8 +36,7 @@ bool DetectXSS::evaluate(Transaction *t, Rule *rule,
#ifndef NO_LOGS
t->debug(5, "detected XSS using libinjection.");
#endif
if (rule && t
&& rule->getActionsByName("capture", t).size() > 0) {
if (rule && t && rule->m_containsCaptureAction) {
t->m_collections.m_tx_collection->storeOrUpdateFirst(
"0", std::string(input));
#ifndef NO_LOGS

View File

@@ -96,8 +96,6 @@ bool Pm::evaluate(Transaction *transaction, Rule *rule,
#ifdef MODSEC_MUTEX_ON_PM
pthread_mutex_unlock(&m_lock);
#endif
bool capture = rule && rule->getActionsByName("capture",
transaction).size() > 0;
if (rc > 0 && transaction) {
std::string match_(match);
@@ -105,7 +103,7 @@ bool Pm::evaluate(Transaction *transaction, Rule *rule,
transaction->m_matched.push_back(match_);
}
if (capture && transaction && rc) {
if (rule && rule->m_containsCaptureAction && transaction && rc) {
transaction->m_collections.m_tx_collection->storeOrUpdateFirst("0",
std::string(match));
#ifndef NO_LOGS

View File

@@ -222,8 +222,7 @@ bool Rbl::evaluate(Transaction *t, Rule *rule,
furtherInfo(sin, ipStr, t);
freeaddrinfo(info);
if (rule && t
&& rule->getActionsByName("capture", t).size() > 0) {
if (rule && t && rule->m_containsCaptureAction) {
t->m_collections.m_tx_collection->storeOrUpdateFirst(
"0", std::string(ipStr));
#ifndef NO_LOGS

View File

@@ -54,8 +54,7 @@ bool Rx::evaluate(Transaction *transaction, Rule *rule,
}
matches = re->searchAll(input);
if (rule && rule->getActionsByName("capture",
transaction).size() > 0 && transaction) {
if (rule && rule->m_containsCaptureAction && transaction) {
int i = 0;
matches.reverse();
for (const SMatch& a : matches) {

View File

@@ -142,8 +142,7 @@ bool VerifyCC::evaluate(Transaction *t, Rule *rule,
is_cc = luhnVerify(match.c_str(), match.size());
if (is_cc) {
if (t) {
if (rule && t
&& rule->getActionsByName("capture", t).size() > 0) {
if (rule && t && rule->m_containsCaptureAction) {
t->m_collections.m_tx_collection->storeOrUpdateFirst(
"0", std::string(match));
#ifndef NO_LOGS

View File

@@ -133,8 +133,7 @@ bool VerifyCPF::evaluate(Transaction *t, Rule *rule,
is_cpf = verify(i.match.c_str(), i.match.size());
if (is_cpf) {
logOffset(ruleMessage, i.m_offset, i.m_length);
if (rule && t
&& rule->getActionsByName("capture", t).size() > 0) {
if (rule && t && rule->m_containsCaptureAction) {
t->m_collections.m_tx_collection->storeOrUpdateFirst(
"0", std::string(i.match));
#ifndef NO_LOGS

View File

@@ -124,8 +124,7 @@ bool VerifySSN::evaluate(Transaction *t, Rule *rule,
is_ssn = verify(i.match.c_str(), i.match.size());
if (is_ssn) {
logOffset(ruleMessage, i.m_offset, i.m_length);
if (rule && t
&& rule->getActionsByName("capture", t).size() > 0) {
if (rule && t && rule->m_containsCaptureAction) {
t->m_collections.m_tx_collection->storeOrUpdateFirst(
"0", std::string(i.match));
#ifndef NO_LOGS