Fix several minor issues on the seclang grammar

This commit is contained in:
Felipe Zimmerle
2015-08-22 11:06:28 -03:00
parent e78d7f5b91
commit 1065e297b2
15 changed files with 150 additions and 70 deletions

View File

@@ -59,6 +59,14 @@ 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(Assay *assay, const std::string &input) {
int rc = 0;
@@ -79,6 +87,8 @@ bool Pm::evaluate(Assay *assay, const std::string &input) {
bool Pm::init(const char **error) {
std::vector<std::string> vec;
replaceAll(param, "\\", "\\\\");
char *content = parse_pm_content(param.c_str(), param.length(), error);
if (content == NULL) {
return false;

View File

@@ -35,7 +35,7 @@ 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(Assay *assay, const std::string &input);
virtual bool init(const char **error);

View File

@@ -24,10 +24,12 @@ namespace ModSecurity {
namespace operators {
bool Rx::evaluate(Assay *assay, const std::string& input) {
SMatch match;
if (regex_search(input, &match, m_re) && match.size() >= 1) {
std::string i = input;
if (regex_search(i, &match, m_re) && match.size() >= 1) {
this->matched.push_back(match.match);
return true;
}