Refactoring: how to report to error logs

This commit is contained in:
Felipe Zimmerle
2016-12-01 01:05:29 -03:00
parent e6b58014db
commit bfc30dad34
29 changed files with 236 additions and 161 deletions

View File

@@ -26,6 +26,7 @@
#include "src/operators/operator.h"
#include "src/utils/acmp.h"
#include "src/utils/string.h"
namespace modsecurity {
namespace operators {
@@ -78,15 +79,6 @@ void Pm::postOrderTraversal(acmp_btree_node_t *node) {
node = NULL;
}
void Pm::replaceAll(std::string str, const std::string& from,
const std::string& to) {
size_t start_pos = 0;
while ((start_pos = str.find(from, start_pos)) != std::string::npos) {
size_t end_pos = start_pos + from.length();
str.replace(start_pos, end_pos, to);
start_pos += to.length();
}
}
bool Pm::evaluate(Transaction *transaction, Rule *rule,
const std::string &input) {
@@ -119,8 +111,6 @@ bool Pm::init(const std::string &file, std::string *error) {
std::istringstream *iss;
const char *err = NULL;
replaceAll(m_param, "\\", "\\\\");
char *content = parse_pm_content(m_param.c_str(), m_param.length(), &err);
if (content == NULL) {
iss = new std::istringstream(m_param);

View File

@@ -35,8 +35,6 @@ class Pm : public Operator {
m_p = acmp_create(0);
}
~Pm();
void replaceAll(std::string str, const std::string& from,
const std::string& to);
bool evaluate(Transaction *transaction, Rule *rule,
const std::string &input) override;
bool evaluate(Transaction *transaction,