mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 19:24:29 +03:00
Yet another refactoring in Rule
This commit is contained in:
@@ -38,7 +38,7 @@ bool DetectSQLi::evaluate(Transaction *t, Rule *rule,
|
||||
ms_dbg_a(t, 4, "detected SQLi using libinjection with " \
|
||||
"fingerprint '" + std::string(fingerprint) + "' at: '" +
|
||||
input + "'");
|
||||
if (rule && t && rule->m_containsCaptureAction) {
|
||||
if (rule && t && rule->hasCaptureAction()) {
|
||||
t->m_collections.m_tx_collection->storeOrUpdateFirst(
|
||||
"0", std::string(fingerprint));
|
||||
ms_dbg_a(t, 7, "Added DetectSQLi match TX.0: " + \
|
||||
|
@@ -34,7 +34,7 @@ bool DetectXSS::evaluate(Transaction *t, Rule *rule,
|
||||
if (t) {
|
||||
if (is_xss) {
|
||||
ms_dbg_a(t, 5, "detected XSS using libinjection.");
|
||||
if (rule && t && rule->m_containsCaptureAction) {
|
||||
if (rule && t && rule->hasCaptureAction()) {
|
||||
t->m_collections.m_tx_collection->storeOrUpdateFirst(
|
||||
"0", std::string(input));
|
||||
ms_dbg_a(t, 7, "Added DetectXSS match TX.0: " + \
|
||||
|
@@ -97,16 +97,16 @@ bool Pm::evaluate(Transaction *transaction, Rule *rule,
|
||||
#endif
|
||||
|
||||
if (rc >= 0 && transaction) {
|
||||
std::string match_(match);
|
||||
std::string match_(match?match:"");
|
||||
logOffset(ruleMessage, rc - match_.size() + 1, match_.size());
|
||||
transaction->m_matched.push_back(match_);
|
||||
}
|
||||
|
||||
if (rule && rule->m_containsCaptureAction && transaction && rc >= 0) {
|
||||
transaction->m_collections.m_tx_collection->storeOrUpdateFirst("0",
|
||||
std::string(match));
|
||||
ms_dbg_a(transaction, 7, "Added pm match TX.0: " + \
|
||||
std::string(match));
|
||||
if (rule && rule->hasCaptureAction()) {
|
||||
transaction->m_collections.m_tx_collection->storeOrUpdateFirst("0",
|
||||
match_);
|
||||
ms_dbg_a(transaction, 7, "Added pm match TX.0: " + \
|
||||
match_);
|
||||
}
|
||||
}
|
||||
|
||||
return rc >= 0;
|
||||
|
@@ -226,7 +226,7 @@ bool Rbl::evaluate(Transaction *t, Rule *rule,
|
||||
furtherInfo(sin, ipStr, t, m_provider);
|
||||
|
||||
freeaddrinfo(info);
|
||||
if (rule && t && rule->m_containsCaptureAction) {
|
||||
if (rule && t && rule->hasCaptureAction()) {
|
||||
t->m_collections.m_tx_collection->storeOrUpdateFirst(
|
||||
"0", std::string(ipStr));
|
||||
ms_dbg_a(t, 7, "Added RXL match TX.0: " + \
|
||||
|
@@ -53,7 +53,7 @@ bool Rx::evaluate(Transaction *transaction, Rule *rule,
|
||||
}
|
||||
|
||||
matches = re->searchAll(input);
|
||||
if (rule && rule->m_containsCaptureAction && transaction) {
|
||||
if (rule && rule->hasCaptureAction() && transaction) {
|
||||
int i = 0;
|
||||
matches.reverse();
|
||||
for (const SMatch& a : matches) {
|
||||
|
@@ -141,7 +141,7 @@ bool VerifyCC::evaluate(Transaction *t, Rule *rule,
|
||||
int is_cc = luhnVerify(match.c_str(), match.size());
|
||||
if (is_cc) {
|
||||
if (t) {
|
||||
if (rule && t && rule->m_containsCaptureAction) {
|
||||
if (rule && t && rule->hasCaptureAction()) {
|
||||
t->m_collections.m_tx_collection->storeOrUpdateFirst(
|
||||
"0", std::string(match));
|
||||
ms_dbg_a(t, 7, "Added VerifyCC match TX.0: " + \
|
||||
|
@@ -124,7 +124,7 @@ bool VerifyCPF::evaluate(Transaction *t, Rule *rule,
|
||||
is_cpf = verify(m.str().c_str(), m.str().size());
|
||||
if (is_cpf) {
|
||||
logOffset(ruleMessage, m.offset(), m.str().size());
|
||||
if (rule && t && rule->m_containsCaptureAction) {
|
||||
if (rule && t && rule->hasCaptureAction()) {
|
||||
t->m_collections.m_tx_collection->storeOrUpdateFirst(
|
||||
"0", m.str());
|
||||
ms_dbg_a(t, 7, "Added VerifyCPF match TX.0: " + \
|
||||
|
@@ -126,7 +126,7 @@ bool VerifySSN::evaluate(Transaction *t, Rule *rule,
|
||||
is_ssn = verify(j.str().c_str(), j.str().size());
|
||||
if (is_ssn) {
|
||||
logOffset(ruleMessage, j.offset(), j.str().size());
|
||||
if (rule && t && rule->m_containsCaptureAction) {
|
||||
if (rule && t && rule->hasCaptureAction()) {
|
||||
t->m_collections.m_tx_collection->storeOrUpdateFirst(
|
||||
"0", j.str());
|
||||
ms_dbg_a(t, 7, "Added VerifySSN match TX.0: " + \
|
||||
|
@@ -94,7 +94,7 @@ bool VerifySVNR::evaluate(Transaction *t, Rule *rule,
|
||||
is_svnr = verify(j.str().c_str(), j.str().size());
|
||||
if (is_svnr) {
|
||||
logOffset(ruleMessage, j.offset(), j.str().size());
|
||||
if (rule && t && rule->m_containsCaptureAction) {
|
||||
if (rule && t && rule->hasCaptureAction()) {
|
||||
t->m_collections.m_tx_collection->storeOrUpdateFirst(
|
||||
"0", j.str());
|
||||
ms_dbg_a(t, 7, "Added VerifySVNR match TX.0: " + \
|
||||
|
Reference in New Issue
Block a user