mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-16 07:56:12 +03:00
Adds support to the @detectXSS operator
This commit is contained in:
parent
f0535ae11b
commit
4baee88eb3
@ -174,11 +174,15 @@ libmodsecurity_la_SOURCES = \
|
|||||||
rule.cc \
|
rule.cc \
|
||||||
unique_id.cc \
|
unique_id.cc \
|
||||||
${ACTIONS} \
|
${ACTIONS} \
|
||||||
|
${LIBINJECTION} \
|
||||||
${OPERATORS} \
|
${OPERATORS} \
|
||||||
${UTILS} \
|
${UTILS} \
|
||||||
${VARIABLES}
|
${VARIABLES}
|
||||||
|
|
||||||
|
|
||||||
|
LIBINJECTION = \
|
||||||
|
../others/libinjection/src/libinjection_html5.c \
|
||||||
|
../others/libinjection/src/libinjection_xss.c
|
||||||
|
|
||||||
|
|
||||||
libmodsecurity_la_CFLAGS =
|
libmodsecurity_la_CFLAGS =
|
||||||
|
@ -18,25 +18,35 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "operators/operator.h"
|
#include "operators/operator.h"
|
||||||
|
#include "others/libinjection/src/libinjection.h"
|
||||||
|
|
||||||
namespace ModSecurity {
|
namespace ModSecurity {
|
||||||
namespace operators {
|
namespace operators {
|
||||||
|
|
||||||
bool DetectXSS::evaluate(Assay *assay) {
|
|
||||||
/**
|
bool DetectXSS::evaluate(Assay *assay, const std::string &input) {
|
||||||
* @todo Implement the operator DetectXSS.
|
int is_xss;
|
||||||
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#detectxss
|
|
||||||
*/
|
is_xss = libinjection_xss(input.c_str(), input.length());
|
||||||
return true;
|
|
||||||
|
if (is_xss) {
|
||||||
|
if (assay) {
|
||||||
|
assay->debug(5, "detected XSS using libinjection.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (assay) {
|
||||||
|
assay->debug(9, "libinjection was not able to " \
|
||||||
|
"find any XSS in: " + input);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (negation) {
|
||||||
|
return is_xss == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return is_xss != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DetectXSS::DetectXSS(std::string op, std::string param, bool negation)
|
|
||||||
: Operator() {
|
|
||||||
this->op = op;
|
|
||||||
this->param = param;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace operators
|
} // namespace operators
|
||||||
} // namespace ModSecurity
|
} // namespace ModSecurity
|
||||||
|
@ -20,20 +20,20 @@
|
|||||||
|
|
||||||
#include "operators/operator.h"
|
#include "operators/operator.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
namespace ModSecurity {
|
namespace ModSecurity {
|
||||||
namespace operators {
|
namespace operators {
|
||||||
|
|
||||||
class DetectXSS : public Operator {
|
class DetectXSS : public Operator {
|
||||||
public:
|
public:
|
||||||
/** @ingroup ModSecurity_Operator */
|
/** @ingroup ModSecurity_Operator */
|
||||||
DetectXSS(std::string o, std::string p, bool i);
|
DetectXSS(std::string op, std::string param, bool negation)
|
||||||
bool evaluate(Assay *assay);
|
: Operator(op, param, negation) { }
|
||||||
|
|
||||||
|
bool evaluate(Assay *assay, const std::string &input);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace operators
|
} // namespace operators
|
||||||
} // namespace ModSecurity
|
} // namespace ModSecurity
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#endif // SRC_OPERATORS_DETECT_XSS_H_
|
#endif // SRC_OPERATORS_DETECT_XSS_H_
|
||||||
|
Loading…
x
Reference in New Issue
Block a user