mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 19:24:29 +03:00
Refactoring on the Rule class
This commit is contained in:
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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) {
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user