mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-15 23:55:03 +03:00
Makes @pm compatible with the brand new capture schema
This commit is contained in:
parent
eecb90cfd0
commit
7a36499f22
@ -88,7 +88,8 @@ void Pm::replaceAll(std::string str, const std::string& from,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Pm::evaluate(Transaction *transaction, const std::string &input) {
|
bool Pm::evaluate(Transaction *transaction, Rule *rule,
|
||||||
|
const std::string &input) {
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
ACMPT pt;
|
ACMPT pt;
|
||||||
pt.parser = m_p;
|
pt.parser = m_p;
|
||||||
@ -96,10 +97,19 @@ bool Pm::evaluate(Transaction *transaction, const std::string &input) {
|
|||||||
const char *match = NULL;
|
const char *match = NULL;
|
||||||
|
|
||||||
rc = acmp_process_quick(&pt, &match, input.c_str(), input.length());
|
rc = acmp_process_quick(&pt, &match, input.c_str(), input.length());
|
||||||
|
bool capture = rule && rule->getActionsByName("capture").size() > 0;
|
||||||
|
|
||||||
if (rc == 1 && transaction) {
|
if (rc == 1 && transaction) {
|
||||||
transaction->m_matched.push_back(std::string(match));
|
transaction->m_matched.push_back(std::string(match));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (capture && transaction && rc) {
|
||||||
|
transaction->m_collections.storeOrUpdateFirst("TX", "0",
|
||||||
|
std::string(match));
|
||||||
|
transaction->debug(7, "Added pm match TX.0: " + \
|
||||||
|
std::string(match));
|
||||||
|
}
|
||||||
|
|
||||||
return rc == 1;
|
return rc == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,12 @@ class Pm : public Operator {
|
|||||||
~Pm();
|
~Pm();
|
||||||
void replaceAll(std::string str, const std::string& from,
|
void replaceAll(std::string str, const std::string& from,
|
||||||
const std::string& to);
|
const std::string& to);
|
||||||
bool evaluate(Transaction *transaction, const std::string &input) override;
|
bool evaluate(Transaction *transaction, Rule *rule,
|
||||||
|
const std::string &input) override;
|
||||||
|
bool evaluate(Transaction *transaction,
|
||||||
|
const std::string &input) override {
|
||||||
|
return evaluate(transaction, NULL, input);
|
||||||
|
}
|
||||||
|
|
||||||
bool init(const std::string &file, std::string *error) override;
|
bool init(const std::string &file, std::string *error) override;
|
||||||
void postOrderTraversal(acmp_btree_node_t *node);
|
void postOrderTraversal(acmp_btree_node_t *node);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user