mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 19:24:29 +03:00
Fix `capture' memory management
The capture action was implemented before the transaction concept. While partially ported to use the transaction, some of the elements were not freed correctly. Now it is fully ported to use the class Transaction.
This commit is contained in:
@@ -27,7 +27,7 @@ bool Contains::evaluate(Transaction *transaction, const std::string &input) {
|
||||
bool contains = input.find(p) != std::string::npos;
|
||||
|
||||
if (contains) {
|
||||
matched.push_back(p);
|
||||
transaction->m_matched.push_back(p);
|
||||
}
|
||||
|
||||
if (negation) {
|
||||
|
@@ -31,9 +31,8 @@ class Contains : public Operator {
|
||||
/** @ingroup ModSecurity_Operator */
|
||||
Contains(std::string op, std::string param, bool negation)
|
||||
: Operator(op, param, negation) { }
|
||||
bool evaluate(Transaction *transaction, const std::string &exp) override;
|
||||
|
||||
std::list<std::string> matched;
|
||||
bool evaluate(Transaction *transaction, const std::string &exp) override;
|
||||
};
|
||||
|
||||
} // namespace operators
|
||||
|
@@ -32,8 +32,8 @@ bool DetectSQLi::evaluate(Transaction *transaction, const std::string &input) {
|
||||
issqli = libinjection_sqli(input.c_str(), input.length(), fingerprint);
|
||||
|
||||
if (issqli) {
|
||||
matched.push_back(fingerprint);
|
||||
if (transaction) {
|
||||
transaction->m_matched.push_back(fingerprint);
|
||||
#ifndef NO_LOGS
|
||||
transaction->debug(4, "detected SQLi using libinjection with " \
|
||||
"fingerprint '" + std::string(fingerprint) + "' at: '" +
|
||||
|
@@ -31,8 +31,6 @@ class DetectSQLi : public Operator {
|
||||
: Operator(op, param, negation) { }
|
||||
|
||||
bool evaluate(Transaction *transaction, const std::string &input);
|
||||
|
||||
std::list<std::string> matched;
|
||||
};
|
||||
|
||||
} // namespace operators
|
||||
|
@@ -78,7 +78,7 @@ bool Pm::evaluate(Transaction *transaction, const std::string &input) {
|
||||
|
||||
rc = acmp_process_quick(&pt, &match, input.c_str(), input.length());
|
||||
if (rc == 1) {
|
||||
this->matched.push_back(std::string(match));
|
||||
transaction->m_matched.push_back(std::string(match));
|
||||
}
|
||||
|
||||
return rc == 1;
|
||||
|
@@ -42,7 +42,6 @@ class Pm : public Operator {
|
||||
bool init(const std::string &file, const char **error) override;
|
||||
void postOrderTraversal(acmp_btree_node_t *node);
|
||||
|
||||
std::list<std::string> matched;
|
||||
protected:
|
||||
ACMP *m_p;
|
||||
};
|
||||
|
@@ -30,7 +30,7 @@ bool Rx::evaluate(Transaction *transaction, const std::string& input) {
|
||||
SMatch match;
|
||||
|
||||
if (regex_search(input, &match, *m_re) && match.size() >= 1) {
|
||||
this->matched.push_back(match.match);
|
||||
transaction->m_matched.push_back(match.match);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -42,7 +42,6 @@ class Rx : public Operator {
|
||||
|
||||
bool evaluate(Transaction *transaction, const std::string &input);
|
||||
|
||||
std::list<std::string> matched;
|
||||
private:
|
||||
std::string m_param;
|
||||
Regex *m_re;
|
||||
|
Reference in New Issue
Block a user