mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-15 23:55:03 +03:00
Adds operator @pmFromFile and @pmF
This commit is contained in:
parent
57ceef1fe6
commit
0720fd4790
@ -17,25 +17,11 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "operators/operator.h"
|
#include "operators/pm_from_file.h"
|
||||||
|
|
||||||
namespace ModSecurity {
|
namespace ModSecurity {
|
||||||
namespace operators {
|
namespace operators {
|
||||||
|
|
||||||
bool PmF::evaluate(Assay *assay) {
|
|
||||||
/**
|
|
||||||
* @todo Implement the operator PmF.
|
|
||||||
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#pmf
|
|
||||||
*/
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PmF::PmF(std::string op, std::string param, bool negation)
|
|
||||||
: Operator() {
|
|
||||||
this->op = op;
|
|
||||||
this->param = param;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace operators
|
} // namespace operators
|
||||||
} // namespace ModSecurity
|
} // namespace ModSecurity
|
||||||
|
@ -18,19 +18,21 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "operators/operator.h"
|
#include "operators/pm_from_file.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
namespace ModSecurity {
|
namespace ModSecurity {
|
||||||
namespace operators {
|
namespace operators {
|
||||||
|
|
||||||
class PmF : public Operator {
|
|
||||||
|
class PmF : public PmFromFile {
|
||||||
public:
|
public:
|
||||||
/** @ingroup ModSecurity_Operator */
|
/** @ingroup ModSecurity_Operator */
|
||||||
PmF(std::string o, std::string p, bool i);
|
PmF(std::string op, std::string param, bool negation)
|
||||||
bool evaluate(Assay *assay);
|
: PmFromFile(op, param, negation) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace operators
|
} // namespace operators
|
||||||
} // namespace ModSecurity
|
} // namespace ModSecurity
|
||||||
#endif
|
#endif
|
||||||
|
@ -18,24 +18,41 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "operators/operator.h"
|
#include "operators/operator.h"
|
||||||
|
#include "utils/https_client.h"
|
||||||
|
|
||||||
namespace ModSecurity {
|
namespace ModSecurity {
|
||||||
namespace operators {
|
namespace operators {
|
||||||
|
|
||||||
bool PmFromFile::evaluate(Assay *assay) {
|
|
||||||
/**
|
bool PmFromFile::init(const char **error) {
|
||||||
* @todo Implement the operator PmFromFile.
|
std::istream *iss;
|
||||||
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#pmfromfile
|
|
||||||
*/
|
if (param.compare(0, 8, "https://") == 0) {
|
||||||
|
Utils::HttpsClient client;
|
||||||
|
bool ret = client.download(param);
|
||||||
|
if (ret == false) {
|
||||||
|
*error = client.error.c_str();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
iss = new std::stringstream(client.content);
|
||||||
|
} else {
|
||||||
|
iss = new std::ifstream(param, std::ios::in);
|
||||||
|
|
||||||
|
if (((std::ifstream *)iss)->is_open() == false) {
|
||||||
|
*error = std::string("Failed to open file: " + param).c_str();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (std::string line; std::getline(*iss, line); ) {
|
||||||
|
acmp_add_pattern(m_p, line.c_str(), NULL, NULL, line.length());
|
||||||
|
}
|
||||||
|
|
||||||
|
acmp_prepare(m_p);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PmFromFile::PmFromFile(std::string op, std::string param, bool negation)
|
|
||||||
: Operator() {
|
|
||||||
this->op = op;
|
|
||||||
this->param = param;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace operators
|
} // namespace operators
|
||||||
} // namespace ModSecurity
|
} // namespace ModSecurity
|
||||||
|
@ -18,19 +18,23 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "operators/operator.h"
|
#include "operators/pm.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
namespace ModSecurity {
|
namespace ModSecurity {
|
||||||
namespace operators {
|
namespace operators {
|
||||||
|
|
||||||
class PmFromFile : public Operator {
|
|
||||||
|
class PmFromFile : public Pm {
|
||||||
public:
|
public:
|
||||||
/** @ingroup ModSecurity_Operator */
|
/** @ingroup ModSecurity_Operator */
|
||||||
PmFromFile(std::string o, std::string p, bool i);
|
PmFromFile(std::string op, std::string param, bool negation)
|
||||||
bool evaluate(Assay *assay);
|
: Pm(op, param, negation) { }
|
||||||
|
|
||||||
|
bool init(const char **error) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace operators
|
} // namespace operators
|
||||||
} // namespace ModSecurity
|
} // namespace ModSecurity
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user