mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 19:24:29 +03:00
Adds capture action to detectXSS
This commit is contained in:
committed by
Felipe Zimmerle
parent
b59d19e95a
commit
22334c9bb6
@@ -25,22 +25,33 @@ namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
|
||||
bool DetectXSS::evaluate(Transaction *transaction, const std::string &input) {
|
||||
bool DetectXSS::evaluate(Transaction *t, Rule *rule,
|
||||
const std::string& input, std::shared_ptr<RuleMessage> ruleMessage) {
|
||||
int is_xss;
|
||||
|
||||
is_xss = libinjection_xss(input.c_str(), input.length());
|
||||
|
||||
if (transaction) {
|
||||
#ifndef NO_LOGS
|
||||
if (t) {
|
||||
if (is_xss) {
|
||||
transaction->debug(5, "detected XSS using libinjection.");
|
||||
} else {
|
||||
transaction->debug(9, "libinjection was not able to " \
|
||||
"find any XSS in: " + input);
|
||||
}
|
||||
#ifndef NO_LOGS
|
||||
t->debug(5, "detected XSS using libinjection.");
|
||||
#endif
|
||||
if (rule && t
|
||||
&& rule->getActionsByName("capture").size() > 0) {
|
||||
t->m_collections.m_tx_collection->storeOrUpdateFirst(
|
||||
"0", std::string(input));
|
||||
#ifndef NO_LOGS
|
||||
t->debug(7, "Added DetectXSS match TX.0: " + \
|
||||
std::string(input));
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
#ifndef NO_LOGS
|
||||
t->debug(9, "libinjection was not able to " \
|
||||
"find any XSS in: " + input);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
return is_xss != 0;
|
||||
}
|
||||
|
||||
|
@@ -31,7 +31,9 @@ class DetectXSS : public Operator {
|
||||
m_match_message.assign("detected XSS using libinjection.");
|
||||
}
|
||||
|
||||
bool evaluate(Transaction *transaction, const std::string &input);
|
||||
bool evaluate(Transaction *t, Rule *rule,
|
||||
const std::string& input,
|
||||
std::shared_ptr<RuleMessage> ruleMessage) override;
|
||||
};
|
||||
|
||||
} // namespace operators
|
||||
|
Reference in New Issue
Block a user