mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 19:24:29 +03:00
Looks for external resources in the same path of the rule
This commit is contained in:
@@ -23,7 +23,8 @@ namespace ModSecurity {
|
||||
namespace operators {
|
||||
|
||||
|
||||
bool IpMatchFromFile::init(const char **error) {
|
||||
bool IpMatchFromFile::init(const std::string &file,
|
||||
const char **error) {
|
||||
std::string e("");
|
||||
bool res = false;
|
||||
|
||||
|
@@ -29,7 +29,7 @@ class IpMatchFromFile : public IpMatch {
|
||||
IpMatchFromFile(std::string op, std::string param, bool negation)
|
||||
: IpMatch(op, param, negation) { }
|
||||
|
||||
bool init(const char **error) override;
|
||||
bool init(const std::string& file, const char **error) override;
|
||||
};
|
||||
|
||||
} // namespace operators
|
||||
|
@@ -40,7 +40,10 @@ class Operator {
|
||||
std::string param;
|
||||
bool negation;
|
||||
|
||||
virtual bool init(const char **error) { return true; }
|
||||
virtual bool init(const std::string &file, const char **error) {
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool evaluate(Assay *assay);
|
||||
virtual bool evaluate(Assay *assay, const std::string &str);
|
||||
static Operator *instantiate(std::string op);
|
||||
|
@@ -19,12 +19,13 @@
|
||||
|
||||
#include "operators/operator.h"
|
||||
#include "utils/https_client.h"
|
||||
#include "src/utils.h"
|
||||
|
||||
namespace ModSecurity {
|
||||
namespace operators {
|
||||
|
||||
|
||||
bool PmFromFile::init(const char **error) {
|
||||
bool PmFromFile::init(const std::string &config, const char **error) {
|
||||
std::istream *iss;
|
||||
|
||||
if (param.compare(0, 8, "https://") == 0) {
|
||||
@@ -36,7 +37,8 @@ bool PmFromFile::init(const char **error) {
|
||||
}
|
||||
iss = new std::stringstream(client.content);
|
||||
} else {
|
||||
iss = new std::ifstream(param, std::ios::in);
|
||||
std::string resource = find_resource(param, config);
|
||||
iss = new std::ifstream(resource, std::ios::in);
|
||||
|
||||
if (((std::ifstream *)iss)->is_open() == false) {
|
||||
*error = std::string("Failed to open file: " + param).c_str();
|
||||
|
@@ -31,7 +31,7 @@ class PmFromFile : public Pm {
|
||||
PmFromFile(std::string op, std::string param, bool negation)
|
||||
: Pm(op, param, negation) { }
|
||||
|
||||
bool init(const char **error) override;
|
||||
bool init(const std::string &file, const char **error) override;
|
||||
};
|
||||
|
||||
|
||||
|
@@ -30,6 +30,7 @@ bool Rx::evaluate(Assay *assay, const std::string& input) {
|
||||
SMatch match;
|
||||
|
||||
if (regex_search(input, &match, *m_re) && match.size() >= 1) {
|
||||
std::cout << "wheee" << std::endl;
|
||||
// this->matched.push_back(match.match);
|
||||
return true;
|
||||
}
|
||||
|
@@ -83,7 +83,8 @@ bool ValidateByteRange::getRange(const std::string &rangeRepresentation,
|
||||
}
|
||||
|
||||
|
||||
bool ValidateByteRange::init(const char **error) {
|
||||
bool ValidateByteRange::init(const std::string &file,
|
||||
const char **error) {
|
||||
size_t pos = param.find_first_of(",");
|
||||
|
||||
if (pos == std::string::npos) {
|
||||
|
@@ -38,7 +38,7 @@ class ValidateByteRange : public Operator {
|
||||
|
||||
bool evaluate(Assay *assay, const std::string &input) override;
|
||||
bool getRange(const std::string &rangeRepresentation, const char **error);
|
||||
bool init(const char **error) override;
|
||||
bool init(const std::string& file, const char **error) override;
|
||||
private:
|
||||
std::vector<std::string> ranges;
|
||||
char table[32];
|
||||
|
Reference in New Issue
Block a user