mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
Initial support to parser trail
This commit is contained in:
parent
78b7fa4e2c
commit
cb1a53391d
58
headers/modsecurity/parser/default_driver_trail.h
Normal file
58
headers/modsecurity/parser/default_driver_trail.h
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* ModSecurity, http://www.modsecurity.org/
|
||||
* Copyright (c) 2015 Trustwave Holdings, Inc. (http://www.trustwave.com/)
|
||||
*
|
||||
* You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* If any of the files related to licensing are missing or if you have any
|
||||
* other questions related to licensing please contact Trustwave Holdings, Inc.
|
||||
* directly using the email address security@modsecurity.org.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <stack>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#endif
|
||||
|
||||
#ifndef HEADERS_MODSECURITY_PARSER_DEFAULT_DRIVER_TRAIL_H_
|
||||
#define HEADERS_MODSECURITY_PARSER_DEFAULT_DRIVER_TRAIL_H_
|
||||
|
||||
#include "modsecurity/modsecurity.h"
|
||||
#include "modsecurity/rules.h"
|
||||
#include "modsecurity/rules_properties.h"
|
||||
#include "modsecurity/audit_log.h"
|
||||
#include "modsecurity/parser/driver_trail.h"
|
||||
|
||||
|
||||
namespace modsecurity {
|
||||
namespace Parser {
|
||||
|
||||
#ifdef __cplusplus
|
||||
class DriverTrail;
|
||||
#else
|
||||
typedef struct DriverTrail_t DriverTrail;
|
||||
#endif
|
||||
|
||||
|
||||
class DefaultDriverTrail : public DriverTrail {
|
||||
public:
|
||||
int addSecRule(Rule *rule);
|
||||
int addSecAction(Rule *rule);
|
||||
int addSecMarker(std::string marker);
|
||||
int addSecRuleScript(Rule *rule);
|
||||
|
||||
Rule *m_lastRule;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Parser
|
||||
} // namespace modsecurity
|
||||
|
||||
#endif // HEADERS_MODSECURITY_PARSER_DEFAULT_DRIVER_TRAIL_H_
|
106
headers/modsecurity/parser/driver.h
Normal file
106
headers/modsecurity/parser/driver.h
Normal file
@ -0,0 +1,106 @@
|
||||
|
||||
/*
|
||||
* ModSecurity, http://www.modsecurity.org/
|
||||
* Copyright (c) 2015 Trustwave Holdings, Inc. (http://www.trustwave.com/)
|
||||
*
|
||||
* You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* If any of the files related to licensing are missing or if you have any
|
||||
* other questions related to licensing please contact Trustwave Holdings, Inc.
|
||||
* directly using the email address security@modsecurity.org.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <stack>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#endif
|
||||
|
||||
#ifndef HEADERS_MODSECURITY_PARSER_DRIVER_H_
|
||||
#define HEADERS_MODSECURITY_PARSER_DRIVER_H_
|
||||
|
||||
#include "modsecurity/modsecurity.h"
|
||||
#include "modsecurity/rules.h"
|
||||
#include "modsecurity/rules_properties.h"
|
||||
#include "modsecurity/audit_log.h"
|
||||
#include "modsecurity/parser/driver_trail.h"
|
||||
|
||||
|
||||
using modsecurity::Rule;
|
||||
using modsecurity::Rules;
|
||||
|
||||
|
||||
namespace modsecurity {
|
||||
namespace Parser {
|
||||
|
||||
#ifdef __cplusplus
|
||||
class Driver;
|
||||
#else
|
||||
typedef struct Driver_t Driver;
|
||||
#endif
|
||||
|
||||
|
||||
class Driver {
|
||||
public:
|
||||
Driver(DriverTrail *trail);
|
||||
Driver();
|
||||
virtual ~Driver();
|
||||
|
||||
bool scanBegin();
|
||||
void scanEnd();
|
||||
|
||||
int parseFile(const std::string& f);
|
||||
int parse(const std::string& f, const std::string &ref);
|
||||
|
||||
void error(const yy::location& l, const std::string& m);
|
||||
void error(const yy::location& l, const std::string& m,
|
||||
const std::string& c);
|
||||
|
||||
|
||||
int addSecRule(Rule *rule) {
|
||||
if (!m_trail) {
|
||||
return -1;
|
||||
}
|
||||
return m_trail->addSecRule(rule);
|
||||
}
|
||||
int addSecAction(Rule *rule) {
|
||||
if (!m_trail) {
|
||||
return -1;
|
||||
}
|
||||
return m_trail->addSecAction(rule);
|
||||
}
|
||||
int addSecMarker(std::string marker) {
|
||||
if (!m_trail) {
|
||||
return -1;
|
||||
}
|
||||
return m_trail->addSecMarker(marker);
|
||||
}
|
||||
int addSecRuleScript(RuleScript *rule) {
|
||||
if (!m_trail) {
|
||||
return -1;
|
||||
}
|
||||
return m_trail->addSecRuleScript(rule);
|
||||
}
|
||||
|
||||
DriverTrail *m_trail;
|
||||
|
||||
bool m_traceScanning;
|
||||
bool m_traceParsing;
|
||||
std::string m_file;
|
||||
std::list<yy::location *> m_location;
|
||||
std::list<std::string> m_reference;
|
||||
std::string buffer;
|
||||
std::ostringstream m_parserError;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Parser
|
||||
} // namespace modsecurity
|
||||
|
||||
#endif // HEADERS_MODSECURITY_PARSER_DRIVER_H_
|
58
headers/modsecurity/parser/driver_trail.h
Normal file
58
headers/modsecurity/parser/driver_trail.h
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* ModSecurity, http://www.modsecurity.org/
|
||||
* Copyright (c) 2015 Trustwave Holdings, Inc. (http://www.trustwave.com/)
|
||||
*
|
||||
* You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* If any of the files related to licensing are missing or if you have any
|
||||
* other questions related to licensing please contact Trustwave Holdings, Inc.
|
||||
* directly using the email address security@modsecurity.org.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <stack>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#endif
|
||||
|
||||
#ifndef HEADERS_MODSECURITY_PARSER_DRIVER_TRAIL_H_
|
||||
#define HEADERS_MODSECURITY_PARSER_DRIVER_TRAIL_H_
|
||||
|
||||
#include "modsecurity/modsecurity.h"
|
||||
#include "modsecurity/rules.h"
|
||||
#include "modsecurity/rules_properties.h"
|
||||
#include "modsecurity/audit_log.h"
|
||||
|
||||
using modsecurity::Rule;
|
||||
using modsecurity::Rules;
|
||||
|
||||
namespace modsecurity {
|
||||
namespace Parser {
|
||||
|
||||
#ifdef __cplusplus
|
||||
class DriverTrail;
|
||||
#else
|
||||
typedef struct DriverTrail_t DriverTrail;
|
||||
#endif
|
||||
|
||||
class DriverTrail : public RulesProperties {
|
||||
public:
|
||||
virtual int addSecRule(Rule *rule) = 0;
|
||||
virtual int addSecAction(Rule *rule) = 0;
|
||||
virtual int addSecMarker(std::string marker) = 0;
|
||||
virtual int addSecRuleScript(Rule *rule) = 0;
|
||||
|
||||
std::ostringstream m_error;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Parser
|
||||
} // namespace modsecurity
|
||||
|
||||
#endif // HEADERS_MODSECURITY_PARSER_DRIVER_TRAIL_H_
|
@ -83,6 +83,7 @@ class Rules : public RulesProperties {
|
||||
|
||||
int64_t unicode_codepage;
|
||||
|
||||
std::ostringstream m_parserError;
|
||||
private:
|
||||
int m_referenceCount;
|
||||
#ifndef NO_LOGS
|
||||
|
@ -532,7 +532,6 @@ class RulesProperties {
|
||||
RuleEngine m_secRuleEngine;
|
||||
RulesExceptions m_exceptions;
|
||||
std::list<std::string> m_components;
|
||||
std::ostringstream m_parserError;
|
||||
ConfigSet m_responseBodyTypeToBeInspected;
|
||||
ConfigString m_httpblKey;
|
||||
ConfigString m_uploadDirectory;
|
||||
|
@ -262,6 +262,7 @@ libmodsecurity_la_SOURCES = \
|
||||
parser/seclang-parser.cc \
|
||||
parser/seclang-scanner.cc \
|
||||
parser/driver.cc \
|
||||
parser/default_driver_trail.cc \
|
||||
transaction.cc \
|
||||
anchored_set_variable.cc \
|
||||
anchored_variable.cc \
|
||||
|
122
src/parser/default_driver_trail.cc
Normal file
122
src/parser/default_driver_trail.cc
Normal file
@ -0,0 +1,122 @@
|
||||
/*
|
||||
* ModSecurity, http://www.modsecurity.org/
|
||||
* Copyright (c) 2015 Trustwave Holdings, Inc. (http://www.trustwave.com/)
|
||||
*
|
||||
* You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* If any of the files related to licensing are missing or if you have any
|
||||
* other questions related to licensing please contact Trustwave Holdings, Inc.
|
||||
* directly using the email address security@modsecurity.org.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "src/parser/driver.h"
|
||||
|
||||
#include "src/parser/seclang-parser.hh"
|
||||
#include "modsecurity/audit_log.h"
|
||||
#include "modsecurity/rules_properties.h"
|
||||
#include "modsecurity/parser/default_driver_trail.h"
|
||||
|
||||
|
||||
namespace modsecurity {
|
||||
namespace Parser {
|
||||
|
||||
|
||||
int DefaultDriverTrail::addSecMarker(std::string marker) {
|
||||
for (int i = 0; i < modsecurity::Phases::NUMBER_OF_PHASES; i++) {
|
||||
Rule *rule = new Rule(marker);
|
||||
rule->m_phase = i;
|
||||
m_rules[i].push_back(rule);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int DefaultDriverTrail::addSecAction(Rule *rule) {
|
||||
if (rule->m_phase >= modsecurity::Phases::NUMBER_OF_PHASES) {
|
||||
m_error << "Unknown phase: " << std::to_string(rule->m_phase);
|
||||
m_error << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_rules[rule->m_phase].push_back(rule);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int DefaultDriverTrail::addSecRuleScript(Rule *rule) {
|
||||
m_rules[rule->m_phase].push_back(dynamic_cast<RuleScript *>(rule));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int DefaultDriverTrail::addSecRule(Rule *rule) {
|
||||
if (rule->m_phase >= modsecurity::Phases::NUMBER_OF_PHASES) {
|
||||
m_error << "Unknown phase: " << std::to_string(rule->m_phase);
|
||||
m_error << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_lastRule && m_lastRule->m_chained) {
|
||||
if (m_lastRule->m_chainedRuleChild == NULL) {
|
||||
rule->m_phase = m_lastRule->m_phase;
|
||||
if (rule->m_theDisruptiveAction) {
|
||||
m_error << "Disruptive actions can only be specified by";
|
||||
m_error << " chain starter rules.";
|
||||
return false;
|
||||
}
|
||||
m_lastRule->m_chainedRuleChild = rule;
|
||||
rule->m_chainedRuleParent = m_lastRule;
|
||||
return true;
|
||||
} else {
|
||||
Rule *a = m_lastRule->m_chainedRuleChild;
|
||||
while (a->m_chained && a->m_chainedRuleChild != NULL) {
|
||||
a = a->m_chainedRuleChild;
|
||||
}
|
||||
if (a->m_chained && a->m_chainedRuleChild == NULL) {
|
||||
a->m_chainedRuleChild = rule;
|
||||
rule->m_chainedRuleParent = a;
|
||||
if (a->m_theDisruptiveAction) {
|
||||
m_error << "Disruptive actions can only be ";
|
||||
m_error << "specified by chain starter rules.";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Checking if the rule has an ID and also checking if this ID is not used
|
||||
* by other rule
|
||||
*/
|
||||
if (rule->m_ruleId == 0) {
|
||||
m_error << "Rules must have an ID. File: ";
|
||||
m_error << rule->m_fileName << " at line: ";
|
||||
m_error << std::to_string(rule->m_lineNumber) << std::endl;
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < modsecurity::Phases::NUMBER_OF_PHASES; i++) {
|
||||
std::vector<Rule *> rules = m_rules[i];
|
||||
for (int j = 0; j < rules.size(); j++) {
|
||||
if (rules[j]->m_ruleId == rule->m_ruleId) {
|
||||
m_error << "Rule id: " << std::to_string(rule->m_ruleId) \
|
||||
<< " is duplicated" << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_lastRule = rule;
|
||||
m_rules[rule->m_phase].push_back(rule);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Parser
|
||||
} // namespace modsecurity
|
@ -18,6 +18,7 @@
|
||||
#include "src/parser/seclang-parser.hh"
|
||||
#include "modsecurity/audit_log.h"
|
||||
#include "modsecurity/rules_properties.h"
|
||||
#include "modsecurity/parser/default_driver_trail.h"
|
||||
|
||||
using modsecurity::audit_log::AuditLog;
|
||||
using modsecurity::Rule;
|
||||
@ -25,122 +26,40 @@ using modsecurity::Rule;
|
||||
namespace modsecurity {
|
||||
namespace Parser {
|
||||
|
||||
Driver::Driver()
|
||||
: RulesProperties(),
|
||||
trace_scanning(false),
|
||||
trace_parsing(false),
|
||||
lastRule(NULL) { }
|
||||
|
||||
Driver::Driver() :
|
||||
m_traceScanning(false),
|
||||
m_traceParsing(false),
|
||||
m_trail(new DefaultDriverTrail()) { }
|
||||
|
||||
|
||||
Driver::Driver(DriverTrail *trail) :
|
||||
m_traceScanning(false),
|
||||
m_traceParsing(false),
|
||||
m_trail(trail) { }
|
||||
|
||||
|
||||
Driver::~Driver() {
|
||||
while (loc.empty() == false) {
|
||||
yy::location *a = loc.back();
|
||||
loc.pop_back();
|
||||
while (m_location.empty() == false) {
|
||||
yy::location *a = m_location.back();
|
||||
m_location.pop_back();
|
||||
delete a;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int Driver::addSecMarker(std::string marker) {
|
||||
for (int i = 0; i < modsecurity::Phases::NUMBER_OF_PHASES; i++) {
|
||||
Rule *rule = new Rule(marker);
|
||||
rule->m_phase = i;
|
||||
m_rules[i].push_back(rule);
|
||||
if (m_trail != NULL) {
|
||||
delete m_trail;
|
||||
m_trail = NULL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int Driver::addSecAction(Rule *rule) {
|
||||
if (rule->m_phase >= modsecurity::Phases::NUMBER_OF_PHASES) {
|
||||
m_parserError << "Unknown phase: " << std::to_string(rule->m_phase);
|
||||
m_parserError << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_rules[rule->m_phase].push_back(rule);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int Driver::addSecRuleScript(RuleScript *rule) {
|
||||
m_rules[rule->m_phase].push_back(rule);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int Driver::addSecRule(Rule *rule) {
|
||||
if (rule->m_phase >= modsecurity::Phases::NUMBER_OF_PHASES) {
|
||||
m_parserError << "Unknown phase: " << std::to_string(rule->m_phase);
|
||||
m_parserError << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (lastRule && lastRule->m_chained) {
|
||||
if (lastRule->m_chainedRuleChild == NULL) {
|
||||
rule->m_phase = lastRule->m_phase;
|
||||
if (rule->m_theDisruptiveAction) {
|
||||
m_parserError << "Disruptive actions can only be specified by";
|
||||
m_parserError << " chain starter rules.";
|
||||
return false;
|
||||
}
|
||||
lastRule->m_chainedRuleChild = rule;
|
||||
rule->m_chainedRuleParent = lastRule;
|
||||
return true;
|
||||
} else {
|
||||
Rule *a = lastRule->m_chainedRuleChild;
|
||||
while (a->m_chained && a->m_chainedRuleChild != NULL) {
|
||||
a = a->m_chainedRuleChild;
|
||||
}
|
||||
if (a->m_chained && a->m_chainedRuleChild == NULL) {
|
||||
a->m_chainedRuleChild = rule;
|
||||
rule->m_chainedRuleParent = a;
|
||||
if (a->m_theDisruptiveAction) {
|
||||
m_parserError << "Disruptive actions can only be ";
|
||||
m_parserError << "specified by chain starter rules.";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Checking if the rule has an ID and also checking if this ID is not used
|
||||
* by other rule
|
||||
*/
|
||||
if (rule->m_ruleId == 0) {
|
||||
m_parserError << "Rules must have an ID. File: ";
|
||||
m_parserError << rule->m_fileName << " at line: ";
|
||||
m_parserError << std::to_string(rule->m_lineNumber) << std::endl;
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < modsecurity::Phases::NUMBER_OF_PHASES; i++) {
|
||||
std::vector<Rule *> rules = m_rules[i];
|
||||
for (int j = 0; j < rules.size(); j++) {
|
||||
if (rules[j]->m_ruleId == rule->m_ruleId) {
|
||||
m_parserError << "Rule id: " << std::to_string(rule->m_ruleId) \
|
||||
<< " is duplicated" << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lastRule = rule;
|
||||
m_rules[rule->m_phase].push_back(rule);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int Driver::parse(const std::string &f, const std::string &ref) {
|
||||
lastRule = NULL;
|
||||
loc.push_back(new yy::location());
|
||||
if (ref.empty()) {
|
||||
this->ref.push_back("<<reference missing or not informed>>");
|
||||
//m_trail->m_lastRule = NULL;
|
||||
m_location.push_back(new yy::location());
|
||||
if (m_reference.empty()) {
|
||||
m_reference.push_back("<<reference missing or not informed>>");
|
||||
} else {
|
||||
this->ref.push_back(ref);
|
||||
m_reference.push_back(ref);
|
||||
}
|
||||
|
||||
if (f.empty()) {
|
||||
@ -148,11 +67,11 @@ int Driver::parse(const std::string &f, const std::string &ref) {
|
||||
}
|
||||
|
||||
buffer = f;
|
||||
scan_begin();
|
||||
scanBegin();
|
||||
yy::seclang_parser parser(*this);
|
||||
parser.set_debug_level(trace_parsing);
|
||||
parser.set_debug_level(m_traceParsing);
|
||||
int res = parser.parse();
|
||||
scan_end();
|
||||
scanEnd();
|
||||
|
||||
/*
|
||||
if (m_auditLog->init(&error) == false) {
|
||||
@ -193,10 +112,13 @@ void Driver::error(const yy::location& l, const std::string& m) {
|
||||
|
||||
void Driver::error(const yy::location& l, const std::string& m,
|
||||
const std::string& c) {
|
||||
if (m_trail->m_error.tellp() > 0) {
|
||||
m_parserError << m_trail;
|
||||
}
|
||||
if (m_parserError.tellp() == 0) {
|
||||
m_parserError << "Rules error. ";
|
||||
if (ref.empty() == false) {
|
||||
m_parserError << "File: " << ref.back() << ". ";
|
||||
if (m_reference.empty() == false) {
|
||||
m_parserError << "File: " << m_reference.back() << ". ";
|
||||
}
|
||||
m_parserError << "Line: " << l.end.line << ". ";
|
||||
m_parserError << "Column: " << l.end.column - 1 << ". ";
|
||||
|
@ -21,9 +21,6 @@
|
||||
#include <list>
|
||||
#endif
|
||||
|
||||
#ifndef SRC_PARSER_DRIVER_H_
|
||||
#define SRC_PARSER_DRIVER_H_
|
||||
|
||||
#include "modsecurity/modsecurity.h"
|
||||
#include "modsecurity/rules.h"
|
||||
#include "modsecurity/rules_properties.h"
|
||||
@ -31,59 +28,16 @@
|
||||
#include "src/rule_script.h"
|
||||
#include "src/parser/seclang-parser.hh"
|
||||
|
||||
using modsecurity::Rule;
|
||||
using modsecurity::Rules;
|
||||
|
||||
#ifndef SRC_PARSER_DRIVER_H_
|
||||
#define SRC_PARSER_DRIVER_H_
|
||||
|
||||
# define YY_DECL \
|
||||
yy::seclang_parser::symbol_type yylex(modsecurity::Parser::Driver& driver)
|
||||
|
||||
YY_DECL;
|
||||
|
||||
namespace modsecurity {
|
||||
namespace Parser {
|
||||
|
||||
#ifdef __cplusplus
|
||||
class Driver;
|
||||
#else
|
||||
typedef struct Driver_t Driver;
|
||||
#endif
|
||||
|
||||
|
||||
class Driver : public RulesProperties {
|
||||
public:
|
||||
Driver();
|
||||
virtual ~Driver();
|
||||
|
||||
int addSecRule(Rule *rule);
|
||||
int addSecAction(Rule *rule);
|
||||
int addSecMarker(std::string marker);
|
||||
int addSecRuleScript(RuleScript *rule);
|
||||
|
||||
bool scan_begin();
|
||||
void scan_end();
|
||||
bool trace_scanning;
|
||||
|
||||
int parseFile(const std::string& f);
|
||||
int parse(const std::string& f, const std::string &ref);
|
||||
|
||||
std::string file;
|
||||
|
||||
bool trace_parsing;
|
||||
|
||||
void error(const yy::location& l, const std::string& m);
|
||||
void error(const yy::location& l, const std::string& m,
|
||||
const std::string& c);
|
||||
|
||||
std::list<yy::location *> loc;
|
||||
|
||||
std::list<std::string> ref;
|
||||
std::string buffer;
|
||||
Rule *lastRule;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Parser
|
||||
} // namespace modsecurity
|
||||
#include "modsecurity/parser/driver.h"
|
||||
|
||||
#endif // SRC_PARSER_DRIVER_H_
|
||||
|
@ -1109,7 +1109,7 @@ namespace yy {
|
||||
#line 355 "seclang-parser.yy" // lalr1.cc:783
|
||||
{
|
||||
// Initialize the initial location.
|
||||
yyla.location.begin.filename = yyla.location.end.filename = &driver.file;
|
||||
yyla.location.begin.filename = yyla.location.end.filename = &driver.m_file;
|
||||
}
|
||||
|
||||
#line 1116 "seclang-parser.cc" // lalr1.cc:783
|
||||
@ -1464,7 +1464,7 @@ namespace yy {
|
||||
case 6:
|
||||
#line 758 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_auditLog->setStorageDirMode(strtol(yystack_[0].value.as< std::string > ().c_str(), NULL, 8));
|
||||
driver.m_trail->m_auditLog->setStorageDirMode(strtol(yystack_[0].value.as< std::string > ().c_str(), NULL, 8));
|
||||
}
|
||||
#line 1470 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -1472,7 +1472,7 @@ namespace yy {
|
||||
case 7:
|
||||
#line 764 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_auditLog->setStorageDir(yystack_[0].value.as< std::string > ());
|
||||
driver.m_trail->m_auditLog->setStorageDir(yystack_[0].value.as< std::string > ());
|
||||
}
|
||||
#line 1478 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -1480,7 +1480,7 @@ namespace yy {
|
||||
case 8:
|
||||
#line 770 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_auditLog->setStatus(modsecurity::audit_log::AuditLog::RelevantOnlyAuditLogStatus);
|
||||
driver.m_trail->m_auditLog->setStatus(modsecurity::audit_log::AuditLog::RelevantOnlyAuditLogStatus);
|
||||
}
|
||||
#line 1486 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -1488,7 +1488,7 @@ namespace yy {
|
||||
case 9:
|
||||
#line 774 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_auditLog->setStatus(modsecurity::audit_log::AuditLog::OffAuditLogStatus);
|
||||
driver.m_trail->m_auditLog->setStatus(modsecurity::audit_log::AuditLog::OffAuditLogStatus);
|
||||
}
|
||||
#line 1494 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -1496,7 +1496,7 @@ namespace yy {
|
||||
case 10:
|
||||
#line 778 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_auditLog->setStatus(modsecurity::audit_log::AuditLog::OnAuditLogStatus);
|
||||
driver.m_trail->m_auditLog->setStatus(modsecurity::audit_log::AuditLog::OnAuditLogStatus);
|
||||
}
|
||||
#line 1502 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -1504,7 +1504,7 @@ namespace yy {
|
||||
case 11:
|
||||
#line 784 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_auditLog->setFileMode(strtol(yystack_[0].value.as< std::string > ().c_str(), NULL, 8));
|
||||
driver.m_trail->m_auditLog->setFileMode(strtol(yystack_[0].value.as< std::string > ().c_str(), NULL, 8));
|
||||
}
|
||||
#line 1510 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -1512,7 +1512,7 @@ namespace yy {
|
||||
case 12:
|
||||
#line 790 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_auditLog->setFilePath2(yystack_[0].value.as< std::string > ());
|
||||
driver.m_trail->m_auditLog->setFilePath2(yystack_[0].value.as< std::string > ());
|
||||
}
|
||||
#line 1518 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -1520,7 +1520,7 @@ namespace yy {
|
||||
case 13:
|
||||
#line 796 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_auditLog->setParts(yystack_[0].value.as< std::string > ());
|
||||
driver.m_trail->m_auditLog->setParts(yystack_[0].value.as< std::string > ());
|
||||
}
|
||||
#line 1526 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -1528,7 +1528,7 @@ namespace yy {
|
||||
case 14:
|
||||
#line 802 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_auditLog->setFilePath1(yystack_[0].value.as< std::string > ());
|
||||
driver.m_trail->m_auditLog->setFilePath1(yystack_[0].value.as< std::string > ());
|
||||
}
|
||||
#line 1534 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -1536,7 +1536,7 @@ namespace yy {
|
||||
case 15:
|
||||
#line 807 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_auditLog->setFormat(modsecurity::audit_log::AuditLog::JSONAuditLogFormat);
|
||||
driver.m_trail->m_auditLog->setFormat(modsecurity::audit_log::AuditLog::JSONAuditLogFormat);
|
||||
}
|
||||
#line 1542 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -1544,7 +1544,7 @@ namespace yy {
|
||||
case 16:
|
||||
#line 812 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_auditLog->setFormat(modsecurity::audit_log::AuditLog::NativeAuditLogFormat);
|
||||
driver.m_trail->m_auditLog->setFormat(modsecurity::audit_log::AuditLog::NativeAuditLogFormat);
|
||||
}
|
||||
#line 1550 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -1553,7 +1553,7 @@ namespace yy {
|
||||
#line 818 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
std::string relevant_status(yystack_[0].value.as< std::string > ());
|
||||
driver.m_auditLog->setRelevantStatus(relevant_status);
|
||||
driver.m_trail->m_auditLog->setRelevantStatus(relevant_status);
|
||||
}
|
||||
#line 1559 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -1561,7 +1561,7 @@ namespace yy {
|
||||
case 18:
|
||||
#line 825 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_auditLog->setType(modsecurity::audit_log::AuditLog::SerialAuditLogType);
|
||||
driver.m_trail->m_auditLog->setType(modsecurity::audit_log::AuditLog::SerialAuditLogType);
|
||||
}
|
||||
#line 1567 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -1569,7 +1569,7 @@ namespace yy {
|
||||
case 19:
|
||||
#line 829 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_auditLog->setType(modsecurity::audit_log::AuditLog::ParallelAuditLogType);
|
||||
driver.m_trail->m_auditLog->setType(modsecurity::audit_log::AuditLog::ParallelAuditLogType);
|
||||
}
|
||||
#line 1575 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -1577,7 +1577,7 @@ namespace yy {
|
||||
case 20:
|
||||
#line 833 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_auditLog->setType(modsecurity::audit_log::AuditLog::HttpsAuditLogType);
|
||||
driver.m_trail->m_auditLog->setType(modsecurity::audit_log::AuditLog::HttpsAuditLogType);
|
||||
}
|
||||
#line 1583 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -1585,7 +1585,7 @@ namespace yy {
|
||||
case 21:
|
||||
#line 839 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_uploadKeepFiles = modsecurity::RulesProperties::TrueConfigBoolean;
|
||||
driver.m_trail->m_uploadKeepFiles = modsecurity::RulesProperties::TrueConfigBoolean;
|
||||
}
|
||||
#line 1591 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -1593,7 +1593,7 @@ namespace yy {
|
||||
case 22:
|
||||
#line 843 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_uploadKeepFiles = modsecurity::RulesProperties::FalseConfigBoolean;
|
||||
driver.m_trail->m_uploadKeepFiles = modsecurity::RulesProperties::FalseConfigBoolean;
|
||||
}
|
||||
#line 1599 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -1610,8 +1610,8 @@ namespace yy {
|
||||
case 24:
|
||||
#line 852 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_uploadFileLimit.m_set = true;
|
||||
driver.m_uploadFileLimit.m_value = strtol(yystack_[0].value.as< std::string > ().c_str(), NULL, 10);
|
||||
driver.m_trail->m_uploadFileLimit.m_set = true;
|
||||
driver.m_trail->m_uploadFileLimit.m_value = strtol(yystack_[0].value.as< std::string > ().c_str(), NULL, 10);
|
||||
}
|
||||
#line 1617 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -1619,8 +1619,8 @@ namespace yy {
|
||||
case 25:
|
||||
#line 857 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_uploadFileMode.m_set = true;
|
||||
driver.m_uploadFileMode.m_value = strtol(yystack_[0].value.as< std::string > ().c_str(), NULL, 8);
|
||||
driver.m_trail->m_uploadFileMode.m_set = true;
|
||||
driver.m_trail->m_uploadFileMode.m_value = strtol(yystack_[0].value.as< std::string > ().c_str(), NULL, 8);
|
||||
}
|
||||
#line 1626 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -1628,8 +1628,8 @@ namespace yy {
|
||||
case 26:
|
||||
#line 862 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_uploadDirectory.m_set = true;
|
||||
driver.m_uploadDirectory.m_value = yystack_[0].value.as< std::string > ();
|
||||
driver.m_trail->m_uploadDirectory.m_set = true;
|
||||
driver.m_trail->m_uploadDirectory.m_value = yystack_[0].value.as< std::string > ();
|
||||
}
|
||||
#line 1635 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -1637,7 +1637,7 @@ namespace yy {
|
||||
case 27:
|
||||
#line 867 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_tmpSaveUploadedFiles = modsecurity::RulesProperties::TrueConfigBoolean;
|
||||
driver.m_trail->m_tmpSaveUploadedFiles = modsecurity::RulesProperties::TrueConfigBoolean;
|
||||
}
|
||||
#line 1643 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -1645,7 +1645,7 @@ namespace yy {
|
||||
case 28:
|
||||
#line 871 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_tmpSaveUploadedFiles = modsecurity::RulesProperties::FalseConfigBoolean;
|
||||
driver.m_trail->m_tmpSaveUploadedFiles = modsecurity::RulesProperties::FalseConfigBoolean;
|
||||
}
|
||||
#line 1651 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -1692,7 +1692,7 @@ namespace yy {
|
||||
{
|
||||
yylhs.value.as< std::unique_ptr<Operator> > () = std::move(yystack_[0].value.as< std::unique_ptr<Operator> > ());
|
||||
std::string error;
|
||||
if (yylhs.value.as< std::unique_ptr<Operator> > ()->init(driver.ref.back(), &error) == false) {
|
||||
if (yylhs.value.as< std::unique_ptr<Operator> > ()->init(driver.m_reference.back(), &error) == false) {
|
||||
driver.error(yystack_[1].location, error);
|
||||
YYERROR;
|
||||
}
|
||||
@ -1706,7 +1706,7 @@ namespace yy {
|
||||
yylhs.value.as< std::unique_ptr<Operator> > () = std::move(yystack_[0].value.as< std::unique_ptr<Operator> > ());
|
||||
yylhs.value.as< std::unique_ptr<Operator> > ()->m_negation = true;
|
||||
std::string error;
|
||||
if (yylhs.value.as< std::unique_ptr<Operator> > ()->init(driver.ref.back(), &error) == false) {
|
||||
if (yylhs.value.as< std::unique_ptr<Operator> > ()->init(driver.m_reference.back(), &error) == false) {
|
||||
driver.error(yystack_[2].location, error);
|
||||
YYERROR;
|
||||
}
|
||||
@ -1719,7 +1719,7 @@ namespace yy {
|
||||
{
|
||||
OPERATOR_CONTAINER(yylhs.value.as< std::unique_ptr<Operator> > (), new operators::Rx(std::move(yystack_[0].value.as< std::unique_ptr<RunTimeString> > ())));
|
||||
std::string error;
|
||||
if (yylhs.value.as< std::unique_ptr<Operator> > ()->init(driver.ref.back(), &error) == false) {
|
||||
if (yylhs.value.as< std::unique_ptr<Operator> > ()->init(driver.m_reference.back(), &error) == false) {
|
||||
driver.error(yystack_[1].location, error);
|
||||
YYERROR;
|
||||
}
|
||||
@ -1733,7 +1733,7 @@ namespace yy {
|
||||
OPERATOR_CONTAINER(yylhs.value.as< std::unique_ptr<Operator> > (), new operators::Rx(std::move(yystack_[0].value.as< std::unique_ptr<RunTimeString> > ())));
|
||||
yylhs.value.as< std::unique_ptr<Operator> > ()->m_negation = true;
|
||||
std::string error;
|
||||
if (yylhs.value.as< std::unique_ptr<Operator> > ()->init(driver.ref.back(), &error) == false) {
|
||||
if (yylhs.value.as< std::unique_ptr<Operator> > ()->init(driver.m_reference.back(), &error) == false) {
|
||||
driver.error(yystack_[2].location, error);
|
||||
YYERROR;
|
||||
}
|
||||
@ -2048,7 +2048,7 @@ namespace yy {
|
||||
/* op */ op,
|
||||
/* variables */ v,
|
||||
/* actions */ a,
|
||||
/* file name */ driver.ref.back(),
|
||||
/* file name */ driver.m_reference.back(),
|
||||
/* line number */ yystack_[3].location.end.line
|
||||
);
|
||||
|
||||
@ -2072,7 +2072,7 @@ namespace yy {
|
||||
/* op */ yystack_[0].value.as< std::unique_ptr<Operator> > ().release(),
|
||||
/* variables */ v,
|
||||
/* actions */ NULL,
|
||||
/* file name */ driver.ref.back(),
|
||||
/* file name */ driver.m_reference.back(),
|
||||
/* line number */ yystack_[2].location.end.line
|
||||
);
|
||||
if (driver.addSecRule(rule) == false) {
|
||||
@ -2094,7 +2094,7 @@ namespace yy {
|
||||
/* op */ NULL,
|
||||
/* variables */ NULL,
|
||||
/* actions */ a,
|
||||
/* file name */ driver.ref.back(),
|
||||
/* file name */ driver.m_reference.back(),
|
||||
/* line number */ yystack_[1].location.end.line
|
||||
);
|
||||
driver.addSecAction(rule);
|
||||
@ -2113,7 +2113,7 @@ namespace yy {
|
||||
RuleScript *r = new RuleScript(
|
||||
/* path to script */ yystack_[1].value.as< std::string > (),
|
||||
/* actions */ a,
|
||||
/* file name */ driver.ref.back(),
|
||||
/* file name */ driver.m_reference.back(),
|
||||
/* line number */ yystack_[1].location.end.line
|
||||
);
|
||||
|
||||
@ -2172,7 +2172,7 @@ namespace yy {
|
||||
YYERROR;
|
||||
}
|
||||
|
||||
if (!driver.m_defaultActions[definedPhase].empty()) {
|
||||
if (!driver.m_trail->m_defaultActions[definedPhase].empty()) {
|
||||
std::stringstream ss;
|
||||
ss << "SecDefaultActions can only be placed once per phase and configuration context. Phase ";
|
||||
ss << secRuleDefinedPhase;
|
||||
@ -2182,7 +2182,7 @@ namespace yy {
|
||||
}
|
||||
|
||||
for (actions::Action *a : checkedActions) {
|
||||
driver.m_defaultActions[definedPhase].push_back(a);
|
||||
driver.m_trail->m_defaultActions[definedPhase].push_back(a);
|
||||
}
|
||||
|
||||
delete actions;
|
||||
@ -2201,7 +2201,7 @@ namespace yy {
|
||||
case 79:
|
||||
#line 1243 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_secRuleEngine = modsecurity::Rules::DisabledRuleEngine;
|
||||
driver.m_trail->m_secRuleEngine = modsecurity::Rules::DisabledRuleEngine;
|
||||
}
|
||||
#line 2207 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -2209,7 +2209,7 @@ namespace yy {
|
||||
case 80:
|
||||
#line 1247 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_secRuleEngine = modsecurity::Rules::EnabledRuleEngine;
|
||||
driver.m_trail->m_secRuleEngine = modsecurity::Rules::EnabledRuleEngine;
|
||||
}
|
||||
#line 2215 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -2217,7 +2217,7 @@ namespace yy {
|
||||
case 81:
|
||||
#line 1251 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_secRuleEngine = modsecurity::Rules::DetectionOnlyRuleEngine;
|
||||
driver.m_trail->m_secRuleEngine = modsecurity::Rules::DetectionOnlyRuleEngine;
|
||||
}
|
||||
#line 2223 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -2225,7 +2225,7 @@ namespace yy {
|
||||
case 82:
|
||||
#line 1255 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_secRequestBodyAccess = modsecurity::RulesProperties::TrueConfigBoolean;
|
||||
driver.m_trail->m_secRequestBodyAccess = modsecurity::RulesProperties::TrueConfigBoolean;
|
||||
}
|
||||
#line 2231 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -2233,7 +2233,7 @@ namespace yy {
|
||||
case 83:
|
||||
#line 1259 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_secRequestBodyAccess = modsecurity::RulesProperties::FalseConfigBoolean;
|
||||
driver.m_trail->m_secRequestBodyAccess = modsecurity::RulesProperties::FalseConfigBoolean;
|
||||
}
|
||||
#line 2239 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -2241,7 +2241,7 @@ namespace yy {
|
||||
case 84:
|
||||
#line 1263 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_secResponseBodyAccess = modsecurity::RulesProperties::TrueConfigBoolean;
|
||||
driver.m_trail->m_secResponseBodyAccess = modsecurity::RulesProperties::TrueConfigBoolean;
|
||||
}
|
||||
#line 2247 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -2249,7 +2249,7 @@ namespace yy {
|
||||
case 85:
|
||||
#line 1267 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_secResponseBodyAccess = modsecurity::RulesProperties::FalseConfigBoolean;
|
||||
driver.m_trail->m_secResponseBodyAccess = modsecurity::RulesProperties::FalseConfigBoolean;
|
||||
}
|
||||
#line 2255 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -2261,8 +2261,8 @@ namespace yy {
|
||||
driver.error(yystack_[1].location, "Argument separator should be set to a single character.");
|
||||
YYERROR;
|
||||
}
|
||||
driver.m_secArgumentSeparator.m_value = yystack_[0].value.as< std::string > ();
|
||||
driver.m_secArgumentSeparator.m_set = true;
|
||||
driver.m_trail->m_secArgumentSeparator.m_value = yystack_[0].value.as< std::string > ();
|
||||
driver.m_trail->m_secArgumentSeparator.m_set = true;
|
||||
}
|
||||
#line 2268 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -2270,7 +2270,7 @@ namespace yy {
|
||||
case 87:
|
||||
#line 1280 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_components.push_back(yystack_[0].value.as< std::string > ());
|
||||
driver.m_trail->m_components.push_back(yystack_[0].value.as< std::string > ());
|
||||
}
|
||||
#line 2276 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -2294,8 +2294,8 @@ namespace yy {
|
||||
case 90:
|
||||
#line 1292 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_secWebAppId.m_value = yystack_[0].value.as< std::string > ();
|
||||
driver.m_secWebAppId.m_set = true;
|
||||
driver.m_trail->m_secWebAppId.m_value = yystack_[0].value.as< std::string > ();
|
||||
driver.m_trail->m_secWebAppId.m_set = true;
|
||||
}
|
||||
#line 2301 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -2519,7 +2519,7 @@ namespace yy {
|
||||
#line 1412 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
std::string error;
|
||||
if (driver.m_exceptions.load(yystack_[0].value.as< std::string > (), &error) == false) {
|
||||
if (driver.m_trail->m_exceptions.load(yystack_[0].value.as< std::string > (), &error) == false) {
|
||||
std::stringstream ss;
|
||||
ss << "SecRuleRemoveById: failed to load:";
|
||||
ss << yystack_[0].value.as< std::string > ();
|
||||
@ -2536,7 +2536,7 @@ namespace yy {
|
||||
#line 1425 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
std::string error;
|
||||
if (driver.m_exceptions.loadRemoveRuleByTag(yystack_[0].value.as< std::string > (), &error) == false) {
|
||||
if (driver.m_trail->m_exceptions.loadRemoveRuleByTag(yystack_[0].value.as< std::string > (), &error) == false) {
|
||||
std::stringstream ss;
|
||||
ss << "SecRuleRemoveByTag: failed to load:";
|
||||
ss << yystack_[0].value.as< std::string > ();
|
||||
@ -2553,7 +2553,7 @@ namespace yy {
|
||||
#line 1438 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
std::string error;
|
||||
if (driver.m_exceptions.loadRemoveRuleByMsg(yystack_[0].value.as< std::string > (), &error) == false) {
|
||||
if (driver.m_trail->m_exceptions.loadRemoveRuleByMsg(yystack_[0].value.as< std::string > (), &error) == false) {
|
||||
std::stringstream ss;
|
||||
ss << "SecRuleRemoveByMsg: failed to load:";
|
||||
ss << yystack_[0].value.as< std::string > ();
|
||||
@ -2570,7 +2570,7 @@ namespace yy {
|
||||
#line 1451 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
std::string error;
|
||||
if (driver.m_exceptions.loadUpdateTargetByTag(yystack_[1].value.as< std::string > (), std::move(yystack_[0].value.as< std::unique_ptr<std::vector<std::unique_ptr<Variable> > > > ()), &error) == false) {
|
||||
if (driver.m_trail->m_exceptions.loadUpdateTargetByTag(yystack_[1].value.as< std::string > (), std::move(yystack_[0].value.as< std::unique_ptr<std::vector<std::unique_ptr<Variable> > > > ()), &error) == false) {
|
||||
std::stringstream ss;
|
||||
ss << "SecRuleUpdateTargetByTag: failed to load:";
|
||||
ss << yystack_[1].value.as< std::string > ();
|
||||
@ -2587,7 +2587,7 @@ namespace yy {
|
||||
#line 1464 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
std::string error;
|
||||
if (driver.m_exceptions.loadUpdateTargetByMsg(yystack_[1].value.as< std::string > (), std::move(yystack_[0].value.as< std::unique_ptr<std::vector<std::unique_ptr<Variable> > > > ()), &error) == false) {
|
||||
if (driver.m_trail->m_exceptions.loadUpdateTargetByMsg(yystack_[1].value.as< std::string > (), std::move(yystack_[0].value.as< std::unique_ptr<std::vector<std::unique_ptr<Variable> > > > ()), &error) == false) {
|
||||
std::stringstream ss;
|
||||
ss << "SecRuleUpdateTargetByMsg: failed to load:";
|
||||
ss << yystack_[1].value.as< std::string > ();
|
||||
@ -2617,7 +2617,7 @@ namespace yy {
|
||||
YYERROR;
|
||||
}
|
||||
|
||||
if (driver.m_exceptions.loadUpdateTargetById(ruleId, std::move(yystack_[0].value.as< std::unique_ptr<std::vector<std::unique_ptr<Variable> > > > ()), &error) == false) {
|
||||
if (driver.m_trail->m_exceptions.loadUpdateTargetById(ruleId, std::move(yystack_[0].value.as< std::unique_ptr<std::vector<std::unique_ptr<Variable> > > > ()), &error) == false) {
|
||||
std::stringstream ss;
|
||||
ss << "SecRuleUpdateTargetById: failed to load:";
|
||||
ss << yystack_[1].value.as< std::string > ();
|
||||
@ -2648,7 +2648,7 @@ namespace yy {
|
||||
}
|
||||
|
||||
|
||||
if (driver.m_exceptions.loadUpdateActionById(ruleId, std::move(yystack_[0].value.as< std::unique_ptr<std::vector<std::unique_ptr<actions::Action> > > > ()), &error) == false) {
|
||||
if (driver.m_trail->m_exceptions.loadUpdateActionById(ruleId, std::move(yystack_[0].value.as< std::unique_ptr<std::vector<std::unique_ptr<actions::Action> > > > ()), &error) == false) {
|
||||
std::stringstream ss;
|
||||
ss << "SecRuleUpdateActionById: failed to load:";
|
||||
ss << yystack_[1].value.as< std::string > ();
|
||||
@ -2664,8 +2664,8 @@ namespace yy {
|
||||
case 123:
|
||||
#line 1531 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
if (driver.m_debugLog != NULL) {
|
||||
driver.m_debugLog->setDebugLogLevel(atoi(yystack_[0].value.as< std::string > ().c_str()));
|
||||
if (driver.m_trail->m_debugLog != NULL) {
|
||||
driver.m_trail->m_debugLog->setDebugLogLevel(atoi(yystack_[0].value.as< std::string > ().c_str()));
|
||||
} else {
|
||||
std::stringstream ss;
|
||||
ss << "Internal error, there is no DebugLog ";
|
||||
@ -2680,9 +2680,9 @@ namespace yy {
|
||||
case 124:
|
||||
#line 1543 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
if (driver.m_debugLog != NULL) {
|
||||
if (driver.m_trail->m_debugLog != NULL) {
|
||||
std::string error;
|
||||
driver.m_debugLog->setDebugLogFile(yystack_[0].value.as< std::string > (), &error);
|
||||
driver.m_trail->m_debugLog->setDebugLogFile(yystack_[0].value.as< std::string > (), &error);
|
||||
if (error.size() > 0) {
|
||||
std::stringstream ss;
|
||||
ss << "Failed to start DebugLog: " << error;
|
||||
@ -2706,7 +2706,7 @@ namespace yy {
|
||||
#if defined(WITH_GEOIP) or defined(WITH_MAXMIND)
|
||||
std::string err;
|
||||
std::string file = modsecurity::utils::find_resource(yystack_[0].value.as< std::string > (),
|
||||
driver.ref.back(), &err);
|
||||
driver.m_reference.back(), &err);
|
||||
if (file.empty()) {
|
||||
std::stringstream ss;
|
||||
ss << "Failed to load locate the GeoDB file from: " << yystack_[0].value.as< std::string > () << " ";
|
||||
@ -2734,8 +2734,8 @@ namespace yy {
|
||||
case 126:
|
||||
#line 1591 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_requestBodyLimit.m_set = true;
|
||||
driver.m_requestBodyLimit.m_value = atoi(yystack_[0].value.as< std::string > ().c_str());
|
||||
driver.m_trail->m_requestBodyLimit.m_set = true;
|
||||
driver.m_trail->m_requestBodyLimit.m_value = atoi(yystack_[0].value.as< std::string > ().c_str());
|
||||
}
|
||||
#line 2741 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -2743,8 +2743,8 @@ namespace yy {
|
||||
case 127:
|
||||
#line 1596 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_requestBodyNoFilesLimit.m_set = true;
|
||||
driver.m_requestBodyNoFilesLimit.m_value = atoi(yystack_[0].value.as< std::string > ().c_str());
|
||||
driver.m_trail->m_requestBodyNoFilesLimit.m_set = true;
|
||||
driver.m_trail->m_requestBodyNoFilesLimit.m_value = atoi(yystack_[0].value.as< std::string > ().c_str());
|
||||
}
|
||||
#line 2750 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -2765,8 +2765,8 @@ namespace yy {
|
||||
case 129:
|
||||
#line 1610 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_responseBodyLimit.m_set = true;
|
||||
driver.m_responseBodyLimit.m_value = atoi(yystack_[0].value.as< std::string > ().c_str());
|
||||
driver.m_trail->m_responseBodyLimit.m_set = true;
|
||||
driver.m_trail->m_responseBodyLimit.m_value = atoi(yystack_[0].value.as< std::string > ().c_str());
|
||||
}
|
||||
#line 2772 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -2774,7 +2774,7 @@ namespace yy {
|
||||
case 130:
|
||||
#line 1615 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_requestBodyLimitAction = modsecurity::Rules::BodyLimitAction::ProcessPartialBodyLimitAction;
|
||||
driver.m_trail->m_requestBodyLimitAction = modsecurity::Rules::BodyLimitAction::ProcessPartialBodyLimitAction;
|
||||
}
|
||||
#line 2780 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -2782,7 +2782,7 @@ namespace yy {
|
||||
case 131:
|
||||
#line 1619 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_requestBodyLimitAction = modsecurity::Rules::BodyLimitAction::RejectBodyLimitAction;
|
||||
driver.m_trail->m_requestBodyLimitAction = modsecurity::Rules::BodyLimitAction::RejectBodyLimitAction;
|
||||
}
|
||||
#line 2788 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -2790,7 +2790,7 @@ namespace yy {
|
||||
case 132:
|
||||
#line 1623 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_responseBodyLimitAction = modsecurity::Rules::BodyLimitAction::ProcessPartialBodyLimitAction;
|
||||
driver.m_trail->m_responseBodyLimitAction = modsecurity::Rules::BodyLimitAction::ProcessPartialBodyLimitAction;
|
||||
}
|
||||
#line 2796 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -2798,7 +2798,7 @@ namespace yy {
|
||||
case 133:
|
||||
#line 1627 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_responseBodyLimitAction = modsecurity::Rules::BodyLimitAction::RejectBodyLimitAction;
|
||||
driver.m_trail->m_responseBodyLimitAction = modsecurity::Rules::BodyLimitAction::RejectBodyLimitAction;
|
||||
}
|
||||
#line 2804 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -2806,7 +2806,7 @@ namespace yy {
|
||||
case 134:
|
||||
#line 1631 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_remoteRulesActionOnFailed = Rules::OnFailedRemoteRulesAction::AbortOnFailedRemoteRulesAction;
|
||||
driver.m_trail->m_remoteRulesActionOnFailed = Rules::OnFailedRemoteRulesAction::AbortOnFailedRemoteRulesAction;
|
||||
}
|
||||
#line 2812 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -2814,7 +2814,7 @@ namespace yy {
|
||||
case 135:
|
||||
#line 1635 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_remoteRulesActionOnFailed = Rules::OnFailedRemoteRulesAction::WarnOnFailedRemoteRulesAction;
|
||||
driver.m_trail->m_remoteRulesActionOnFailed = Rules::OnFailedRemoteRulesAction::WarnOnFailedRemoteRulesAction;
|
||||
}
|
||||
#line 2820 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -2825,11 +2825,11 @@ namespace yy {
|
||||
std::istringstream buf(yystack_[0].value.as< std::string > ());
|
||||
std::istream_iterator<std::string> beg(buf), end;
|
||||
std::set<std::string> tokens(beg, end);
|
||||
driver.m_responseBodyTypeToBeInspected.m_set = true;
|
||||
driver.m_trail->m_responseBodyTypeToBeInspected.m_set = true;
|
||||
for (std::set<std::string>::iterator it=tokens.begin();
|
||||
it!=tokens.end(); ++it)
|
||||
{
|
||||
driver.m_responseBodyTypeToBeInspected.m_value.insert(*it);
|
||||
driver.m_trail->m_responseBodyTypeToBeInspected.m_value.insert(*it);
|
||||
}
|
||||
}
|
||||
#line 2836 "seclang-parser.cc" // lalr1.cc:906
|
||||
@ -2838,9 +2838,9 @@ namespace yy {
|
||||
case 139:
|
||||
#line 1661 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_responseBodyTypeToBeInspected.m_set = true;
|
||||
driver.m_responseBodyTypeToBeInspected.m_clear = true;
|
||||
driver.m_responseBodyTypeToBeInspected.m_value.clear();
|
||||
driver.m_trail->m_responseBodyTypeToBeInspected.m_set = true;
|
||||
driver.m_trail->m_responseBodyTypeToBeInspected.m_clear = true;
|
||||
driver.m_trail->m_responseBodyTypeToBeInspected.m_value.clear();
|
||||
}
|
||||
#line 2846 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -2848,7 +2848,7 @@ namespace yy {
|
||||
case 140:
|
||||
#line 1667 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_secXMLExternalEntity = modsecurity::RulesProperties::FalseConfigBoolean;
|
||||
driver.m_trail->m_secXMLExternalEntity = modsecurity::RulesProperties::FalseConfigBoolean;
|
||||
}
|
||||
#line 2854 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -2856,7 +2856,7 @@ namespace yy {
|
||||
case 141:
|
||||
#line 1671 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_secXMLExternalEntity = modsecurity::RulesProperties::TrueConfigBoolean;
|
||||
driver.m_trail->m_secXMLExternalEntity = modsecurity::RulesProperties::TrueConfigBoolean;
|
||||
}
|
||||
#line 2862 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
@ -2934,7 +2934,7 @@ namespace yy {
|
||||
param.pop_back();
|
||||
}
|
||||
|
||||
file = modsecurity::utils::find_resource(f, driver.ref.back(), &err);
|
||||
file = modsecurity::utils::find_resource(f, driver.m_reference.back(), &err);
|
||||
if (file.empty()) {
|
||||
std::stringstream ss;
|
||||
ss << "Failed to locate the unicode map file from: " << f << " ";
|
||||
@ -2943,7 +2943,7 @@ namespace yy {
|
||||
YYERROR;
|
||||
}
|
||||
|
||||
ConfigUnicodeMap::loadConfig(file, num, &driver, &error);
|
||||
ConfigUnicodeMap::loadConfig(file, num, driver.m_trail, &error);
|
||||
|
||||
if (!error.empty()) {
|
||||
driver.error(yystack_[1].location, error);
|
||||
@ -2968,8 +2968,8 @@ namespace yy {
|
||||
case 150:
|
||||
#line 1774 "seclang-parser.yy" // lalr1.cc:906
|
||||
{
|
||||
driver.m_httpblKey.m_set = true;
|
||||
driver.m_httpblKey.m_value = yystack_[0].value.as< std::string > ();
|
||||
driver.m_trail->m_httpblKey.m_set = true;
|
||||
driver.m_trail->m_httpblKey.m_value = yystack_[0].value.as< std::string > ();
|
||||
}
|
||||
#line 2975 "seclang-parser.cc" // lalr1.cc:906
|
||||
break;
|
||||
|
@ -354,7 +354,7 @@ using modsecurity::operators::Operator;
|
||||
%initial-action
|
||||
{
|
||||
// Initialize the initial location.
|
||||
@$.begin.filename = @$.end.filename = &driver.file;
|
||||
@$.begin.filename = @$.end.filename = &driver.m_file;
|
||||
};
|
||||
%define parse.trace
|
||||
%define parse.error verbose
|
||||
@ -756,92 +756,92 @@ audit_log:
|
||||
/* SecAuditLogDirMode */
|
||||
CONFIG_DIR_AUDIT_DIR_MOD
|
||||
{
|
||||
driver.m_auditLog->setStorageDirMode(strtol($1.c_str(), NULL, 8));
|
||||
driver.m_trail->m_auditLog->setStorageDirMode(strtol($1.c_str(), NULL, 8));
|
||||
}
|
||||
|
||||
/* SecAuditLogStorageDir */
|
||||
| CONFIG_DIR_AUDIT_DIR
|
||||
{
|
||||
driver.m_auditLog->setStorageDir($1);
|
||||
driver.m_trail->m_auditLog->setStorageDir($1);
|
||||
}
|
||||
|
||||
/* SecAuditEngine */
|
||||
| CONFIG_DIR_AUDIT_ENG CONFIG_VALUE_RELEVANT_ONLY
|
||||
{
|
||||
driver.m_auditLog->setStatus(modsecurity::audit_log::AuditLog::RelevantOnlyAuditLogStatus);
|
||||
driver.m_trail->m_auditLog->setStatus(modsecurity::audit_log::AuditLog::RelevantOnlyAuditLogStatus);
|
||||
}
|
||||
| CONFIG_DIR_AUDIT_ENG CONFIG_VALUE_OFF
|
||||
{
|
||||
driver.m_auditLog->setStatus(modsecurity::audit_log::AuditLog::OffAuditLogStatus);
|
||||
driver.m_trail->m_auditLog->setStatus(modsecurity::audit_log::AuditLog::OffAuditLogStatus);
|
||||
}
|
||||
| CONFIG_DIR_AUDIT_ENG CONFIG_VALUE_ON
|
||||
{
|
||||
driver.m_auditLog->setStatus(modsecurity::audit_log::AuditLog::OnAuditLogStatus);
|
||||
driver.m_trail->m_auditLog->setStatus(modsecurity::audit_log::AuditLog::OnAuditLogStatus);
|
||||
}
|
||||
|
||||
/* SecAuditLogFileMode */
|
||||
| CONFIG_DIR_AUDIT_FLE_MOD
|
||||
{
|
||||
driver.m_auditLog->setFileMode(strtol($1.c_str(), NULL, 8));
|
||||
driver.m_trail->m_auditLog->setFileMode(strtol($1.c_str(), NULL, 8));
|
||||
}
|
||||
|
||||
/* SecAuditLog2 */
|
||||
| CONFIG_DIR_AUDIT_LOG2
|
||||
{
|
||||
driver.m_auditLog->setFilePath2($1);
|
||||
driver.m_trail->m_auditLog->setFilePath2($1);
|
||||
}
|
||||
|
||||
/* SecAuditLogParts */
|
||||
| CONFIG_DIR_AUDIT_LOG_P
|
||||
{
|
||||
driver.m_auditLog->setParts($1);
|
||||
driver.m_trail->m_auditLog->setParts($1);
|
||||
}
|
||||
|
||||
/* SecAuditLog */
|
||||
| CONFIG_DIR_AUDIT_LOG
|
||||
{
|
||||
driver.m_auditLog->setFilePath1($1);
|
||||
driver.m_trail->m_auditLog->setFilePath1($1);
|
||||
}
|
||||
|
||||
| CONFIG_DIR_AUDIT_LOG_FMT JSON
|
||||
{
|
||||
driver.m_auditLog->setFormat(modsecurity::audit_log::AuditLog::JSONAuditLogFormat);
|
||||
driver.m_trail->m_auditLog->setFormat(modsecurity::audit_log::AuditLog::JSONAuditLogFormat);
|
||||
}
|
||||
|
||||
| CONFIG_DIR_AUDIT_LOG_FMT NATIVE
|
||||
{
|
||||
driver.m_auditLog->setFormat(modsecurity::audit_log::AuditLog::NativeAuditLogFormat);
|
||||
driver.m_trail->m_auditLog->setFormat(modsecurity::audit_log::AuditLog::NativeAuditLogFormat);
|
||||
}
|
||||
|
||||
/* SecAuditLogRelevantStatus */
|
||||
| CONFIG_DIR_AUDIT_STS
|
||||
{
|
||||
std::string relevant_status($1);
|
||||
driver.m_auditLog->setRelevantStatus(relevant_status);
|
||||
driver.m_trail->m_auditLog->setRelevantStatus(relevant_status);
|
||||
}
|
||||
|
||||
/* SecAuditLogType */
|
||||
| CONFIG_DIR_AUDIT_TPE CONFIG_VALUE_SERIAL
|
||||
{
|
||||
driver.m_auditLog->setType(modsecurity::audit_log::AuditLog::SerialAuditLogType);
|
||||
driver.m_trail->m_auditLog->setType(modsecurity::audit_log::AuditLog::SerialAuditLogType);
|
||||
}
|
||||
| CONFIG_DIR_AUDIT_TPE CONFIG_VALUE_PARALLEL
|
||||
{
|
||||
driver.m_auditLog->setType(modsecurity::audit_log::AuditLog::ParallelAuditLogType);
|
||||
driver.m_trail->m_auditLog->setType(modsecurity::audit_log::AuditLog::ParallelAuditLogType);
|
||||
}
|
||||
| CONFIG_DIR_AUDIT_TPE CONFIG_VALUE_HTTPS
|
||||
{
|
||||
driver.m_auditLog->setType(modsecurity::audit_log::AuditLog::HttpsAuditLogType);
|
||||
driver.m_trail->m_auditLog->setType(modsecurity::audit_log::AuditLog::HttpsAuditLogType);
|
||||
}
|
||||
|
||||
/* Upload */
|
||||
| CONFIG_UPDLOAD_KEEP_FILES CONFIG_VALUE_ON
|
||||
{
|
||||
driver.m_uploadKeepFiles = modsecurity::RulesProperties::TrueConfigBoolean;
|
||||
driver.m_trail->m_uploadKeepFiles = modsecurity::RulesProperties::TrueConfigBoolean;
|
||||
}
|
||||
| CONFIG_UPDLOAD_KEEP_FILES CONFIG_VALUE_OFF
|
||||
{
|
||||
driver.m_uploadKeepFiles = modsecurity::RulesProperties::FalseConfigBoolean;
|
||||
driver.m_trail->m_uploadKeepFiles = modsecurity::RulesProperties::FalseConfigBoolean;
|
||||
}
|
||||
| CONFIG_UPDLOAD_KEEP_FILES CONFIG_VALUE_RELEVANT_ONLY
|
||||
{
|
||||
@ -850,26 +850,26 @@ audit_log:
|
||||
}
|
||||
| CONFIG_UPLOAD_FILE_LIMIT
|
||||
{
|
||||
driver.m_uploadFileLimit.m_set = true;
|
||||
driver.m_uploadFileLimit.m_value = strtol($1.c_str(), NULL, 10);
|
||||
driver.m_trail->m_uploadFileLimit.m_set = true;
|
||||
driver.m_trail->m_uploadFileLimit.m_value = strtol($1.c_str(), NULL, 10);
|
||||
}
|
||||
| CONFIG_UPLOAD_FILE_MODE
|
||||
{
|
||||
driver.m_uploadFileMode.m_set = true;
|
||||
driver.m_uploadFileMode.m_value = strtol($1.c_str(), NULL, 8);
|
||||
driver.m_trail->m_uploadFileMode.m_set = true;
|
||||
driver.m_trail->m_uploadFileMode.m_value = strtol($1.c_str(), NULL, 8);
|
||||
}
|
||||
| CONFIG_UPLOAD_DIR
|
||||
{
|
||||
driver.m_uploadDirectory.m_set = true;
|
||||
driver.m_uploadDirectory.m_value = $1;
|
||||
driver.m_trail->m_uploadDirectory.m_set = true;
|
||||
driver.m_trail->m_uploadDirectory.m_value = $1;
|
||||
}
|
||||
| CONFIG_UPDLOAD_SAVE_TMP_FILES CONFIG_VALUE_ON
|
||||
{
|
||||
driver.m_tmpSaveUploadedFiles = modsecurity::RulesProperties::TrueConfigBoolean;
|
||||
driver.m_trail->m_tmpSaveUploadedFiles = modsecurity::RulesProperties::TrueConfigBoolean;
|
||||
}
|
||||
| CONFIG_UPDLOAD_SAVE_TMP_FILES CONFIG_VALUE_OFF
|
||||
{
|
||||
driver.m_tmpSaveUploadedFiles = modsecurity::RulesProperties::FalseConfigBoolean;
|
||||
driver.m_trail->m_tmpSaveUploadedFiles = modsecurity::RulesProperties::FalseConfigBoolean;
|
||||
}
|
||||
;
|
||||
|
||||
@ -905,7 +905,7 @@ op:
|
||||
{
|
||||
$$ = std::move($1);
|
||||
std::string error;
|
||||
if ($$->init(driver.ref.back(), &error) == false) {
|
||||
if ($$->init(driver.m_reference.back(), &error) == false) {
|
||||
driver.error(@0, error);
|
||||
YYERROR;
|
||||
}
|
||||
@ -915,7 +915,7 @@ op:
|
||||
$$ = std::move($2);
|
||||
$$->m_negation = true;
|
||||
std::string error;
|
||||
if ($$->init(driver.ref.back(), &error) == false) {
|
||||
if ($$->init(driver.m_reference.back(), &error) == false) {
|
||||
driver.error(@0, error);
|
||||
YYERROR;
|
||||
}
|
||||
@ -924,7 +924,7 @@ op:
|
||||
{
|
||||
OPERATOR_CONTAINER($$, new operators::Rx(std::move($1)));
|
||||
std::string error;
|
||||
if ($$->init(driver.ref.back(), &error) == false) {
|
||||
if ($$->init(driver.m_reference.back(), &error) == false) {
|
||||
driver.error(@0, error);
|
||||
YYERROR;
|
||||
}
|
||||
@ -934,7 +934,7 @@ op:
|
||||
OPERATOR_CONTAINER($$, new operators::Rx(std::move($2)));
|
||||
$$->m_negation = true;
|
||||
std::string error;
|
||||
if ($$->init(driver.ref.back(), &error) == false) {
|
||||
if ($$->init(driver.m_reference.back(), &error) == false) {
|
||||
driver.error(@0, error);
|
||||
YYERROR;
|
||||
}
|
||||
@ -1112,7 +1112,7 @@ expression:
|
||||
/* op */ op,
|
||||
/* variables */ v,
|
||||
/* actions */ a,
|
||||
/* file name */ driver.ref.back(),
|
||||
/* file name */ driver.m_reference.back(),
|
||||
/* line number */ @1.end.line
|
||||
);
|
||||
|
||||
@ -1132,7 +1132,7 @@ expression:
|
||||
/* op */ $3.release(),
|
||||
/* variables */ v,
|
||||
/* actions */ NULL,
|
||||
/* file name */ driver.ref.back(),
|
||||
/* file name */ driver.m_reference.back(),
|
||||
/* line number */ @1.end.line
|
||||
);
|
||||
if (driver.addSecRule(rule) == false) {
|
||||
@ -1150,7 +1150,7 @@ expression:
|
||||
/* op */ NULL,
|
||||
/* variables */ NULL,
|
||||
/* actions */ a,
|
||||
/* file name */ driver.ref.back(),
|
||||
/* file name */ driver.m_reference.back(),
|
||||
/* line number */ @1.end.line
|
||||
);
|
||||
driver.addSecAction(rule);
|
||||
@ -1165,7 +1165,7 @@ expression:
|
||||
RuleScript *r = new RuleScript(
|
||||
/* path to script */ $1,
|
||||
/* actions */ a,
|
||||
/* file name */ driver.ref.back(),
|
||||
/* file name */ driver.m_reference.back(),
|
||||
/* line number */ @1.end.line
|
||||
);
|
||||
|
||||
@ -1220,7 +1220,7 @@ expression:
|
||||
YYERROR;
|
||||
}
|
||||
|
||||
if (!driver.m_defaultActions[definedPhase].empty()) {
|
||||
if (!driver.m_trail->m_defaultActions[definedPhase].empty()) {
|
||||
std::stringstream ss;
|
||||
ss << "SecDefaultActions can only be placed once per phase and configuration context. Phase ";
|
||||
ss << secRuleDefinedPhase;
|
||||
@ -1230,7 +1230,7 @@ expression:
|
||||
}
|
||||
|
||||
for (actions::Action *a : checkedActions) {
|
||||
driver.m_defaultActions[definedPhase].push_back(a);
|
||||
driver.m_trail->m_defaultActions[definedPhase].push_back(a);
|
||||
}
|
||||
|
||||
delete actions;
|
||||
@ -1241,31 +1241,31 @@ expression:
|
||||
}
|
||||
| CONFIG_DIR_RULE_ENG CONFIG_VALUE_OFF
|
||||
{
|
||||
driver.m_secRuleEngine = modsecurity::Rules::DisabledRuleEngine;
|
||||
driver.m_trail->m_secRuleEngine = modsecurity::Rules::DisabledRuleEngine;
|
||||
}
|
||||
| CONFIG_DIR_RULE_ENG CONFIG_VALUE_ON
|
||||
{
|
||||
driver.m_secRuleEngine = modsecurity::Rules::EnabledRuleEngine;
|
||||
driver.m_trail->m_secRuleEngine = modsecurity::Rules::EnabledRuleEngine;
|
||||
}
|
||||
| CONFIG_DIR_RULE_ENG CONFIG_VALUE_DETC
|
||||
{
|
||||
driver.m_secRuleEngine = modsecurity::Rules::DetectionOnlyRuleEngine;
|
||||
driver.m_trail->m_secRuleEngine = modsecurity::Rules::DetectionOnlyRuleEngine;
|
||||
}
|
||||
| CONFIG_DIR_REQ_BODY CONFIG_VALUE_ON
|
||||
{
|
||||
driver.m_secRequestBodyAccess = modsecurity::RulesProperties::TrueConfigBoolean;
|
||||
driver.m_trail->m_secRequestBodyAccess = modsecurity::RulesProperties::TrueConfigBoolean;
|
||||
}
|
||||
| CONFIG_DIR_REQ_BODY CONFIG_VALUE_OFF
|
||||
{
|
||||
driver.m_secRequestBodyAccess = modsecurity::RulesProperties::FalseConfigBoolean;
|
||||
driver.m_trail->m_secRequestBodyAccess = modsecurity::RulesProperties::FalseConfigBoolean;
|
||||
}
|
||||
| CONFIG_DIR_RES_BODY CONFIG_VALUE_ON
|
||||
{
|
||||
driver.m_secResponseBodyAccess = modsecurity::RulesProperties::TrueConfigBoolean;
|
||||
driver.m_trail->m_secResponseBodyAccess = modsecurity::RulesProperties::TrueConfigBoolean;
|
||||
}
|
||||
| CONFIG_DIR_RES_BODY CONFIG_VALUE_OFF
|
||||
{
|
||||
driver.m_secResponseBodyAccess = modsecurity::RulesProperties::FalseConfigBoolean;
|
||||
driver.m_trail->m_secResponseBodyAccess = modsecurity::RulesProperties::FalseConfigBoolean;
|
||||
}
|
||||
| CONFIG_SEC_ARGUMENT_SEPARATOR
|
||||
{
|
||||
@ -1273,12 +1273,12 @@ expression:
|
||||
driver.error(@0, "Argument separator should be set to a single character.");
|
||||
YYERROR;
|
||||
}
|
||||
driver.m_secArgumentSeparator.m_value = $1;
|
||||
driver.m_secArgumentSeparator.m_set = true;
|
||||
driver.m_trail->m_secArgumentSeparator.m_value = $1;
|
||||
driver.m_trail->m_secArgumentSeparator.m_set = true;
|
||||
}
|
||||
| CONFIG_COMPONENT_SIG
|
||||
{
|
||||
driver.m_components.push_back($1);
|
||||
driver.m_trail->m_components.push_back($1);
|
||||
}
|
||||
| CONFIG_CONN_ENGINE CONFIG_VALUE_ON
|
||||
{
|
||||
@ -1290,8 +1290,8 @@ expression:
|
||||
}
|
||||
| CONFIG_SEC_WEB_APP_ID
|
||||
{
|
||||
driver.m_secWebAppId.m_value = $1;
|
||||
driver.m_secWebAppId.m_set = true;
|
||||
driver.m_trail->m_secWebAppId.m_value = $1;
|
||||
driver.m_trail->m_secWebAppId.m_set = true;
|
||||
}
|
||||
| CONFIG_SEC_SERVER_SIG
|
||||
{
|
||||
@ -1411,7 +1411,7 @@ expression:
|
||||
| CONFIG_SEC_RULE_REMOVE_BY_ID
|
||||
{
|
||||
std::string error;
|
||||
if (driver.m_exceptions.load($1, &error) == false) {
|
||||
if (driver.m_trail->m_exceptions.load($1, &error) == false) {
|
||||
std::stringstream ss;
|
||||
ss << "SecRuleRemoveById: failed to load:";
|
||||
ss << $1;
|
||||
@ -1424,7 +1424,7 @@ expression:
|
||||
| CONFIG_SEC_RULE_REMOVE_BY_TAG
|
||||
{
|
||||
std::string error;
|
||||
if (driver.m_exceptions.loadRemoveRuleByTag($1, &error) == false) {
|
||||
if (driver.m_trail->m_exceptions.loadRemoveRuleByTag($1, &error) == false) {
|
||||
std::stringstream ss;
|
||||
ss << "SecRuleRemoveByTag: failed to load:";
|
||||
ss << $1;
|
||||
@ -1437,7 +1437,7 @@ expression:
|
||||
| CONFIG_SEC_RULE_REMOVE_BY_MSG
|
||||
{
|
||||
std::string error;
|
||||
if (driver.m_exceptions.loadRemoveRuleByMsg($1, &error) == false) {
|
||||
if (driver.m_trail->m_exceptions.loadRemoveRuleByMsg($1, &error) == false) {
|
||||
std::stringstream ss;
|
||||
ss << "SecRuleRemoveByMsg: failed to load:";
|
||||
ss << $1;
|
||||
@ -1450,7 +1450,7 @@ expression:
|
||||
| CONFIG_SEC_RULE_UPDATE_TARGET_BY_TAG variables_pre_process
|
||||
{
|
||||
std::string error;
|
||||
if (driver.m_exceptions.loadUpdateTargetByTag($1, std::move($2), &error) == false) {
|
||||
if (driver.m_trail->m_exceptions.loadUpdateTargetByTag($1, std::move($2), &error) == false) {
|
||||
std::stringstream ss;
|
||||
ss << "SecRuleUpdateTargetByTag: failed to load:";
|
||||
ss << $1;
|
||||
@ -1463,7 +1463,7 @@ expression:
|
||||
| CONFIG_SEC_RULE_UPDATE_TARGET_BY_MSG variables_pre_process
|
||||
{
|
||||
std::string error;
|
||||
if (driver.m_exceptions.loadUpdateTargetByMsg($1, std::move($2), &error) == false) {
|
||||
if (driver.m_trail->m_exceptions.loadUpdateTargetByMsg($1, std::move($2), &error) == false) {
|
||||
std::stringstream ss;
|
||||
ss << "SecRuleUpdateTargetByMsg: failed to load:";
|
||||
ss << $1;
|
||||
@ -1489,7 +1489,7 @@ expression:
|
||||
YYERROR;
|
||||
}
|
||||
|
||||
if (driver.m_exceptions.loadUpdateTargetById(ruleId, std::move($2), &error) == false) {
|
||||
if (driver.m_trail->m_exceptions.loadUpdateTargetById(ruleId, std::move($2), &error) == false) {
|
||||
std::stringstream ss;
|
||||
ss << "SecRuleUpdateTargetById: failed to load:";
|
||||
ss << $1;
|
||||
@ -1516,7 +1516,7 @@ expression:
|
||||
}
|
||||
|
||||
|
||||
if (driver.m_exceptions.loadUpdateActionById(ruleId, std::move($2), &error) == false) {
|
||||
if (driver.m_trail->m_exceptions.loadUpdateActionById(ruleId, std::move($2), &error) == false) {
|
||||
std::stringstream ss;
|
||||
ss << "SecRuleUpdateActionById: failed to load:";
|
||||
ss << $1;
|
||||
@ -1529,8 +1529,8 @@ expression:
|
||||
/* Debug log: start */
|
||||
| CONFIG_DIR_DEBUG_LVL
|
||||
{
|
||||
if (driver.m_debugLog != NULL) {
|
||||
driver.m_debugLog->setDebugLogLevel(atoi($1.c_str()));
|
||||
if (driver.m_trail->m_debugLog != NULL) {
|
||||
driver.m_trail->m_debugLog->setDebugLogLevel(atoi($1.c_str()));
|
||||
} else {
|
||||
std::stringstream ss;
|
||||
ss << "Internal error, there is no DebugLog ";
|
||||
@ -1541,9 +1541,9 @@ expression:
|
||||
}
|
||||
| CONFIG_DIR_DEBUG_LOG
|
||||
{
|
||||
if (driver.m_debugLog != NULL) {
|
||||
if (driver.m_trail->m_debugLog != NULL) {
|
||||
std::string error;
|
||||
driver.m_debugLog->setDebugLogFile($1, &error);
|
||||
driver.m_trail->m_debugLog->setDebugLogFile($1, &error);
|
||||
if (error.size() > 0) {
|
||||
std::stringstream ss;
|
||||
ss << "Failed to start DebugLog: " << error;
|
||||
@ -1564,7 +1564,7 @@ expression:
|
||||
#if defined(WITH_GEOIP) or defined(WITH_MAXMIND)
|
||||
std::string err;
|
||||
std::string file = modsecurity::utils::find_resource($1,
|
||||
driver.ref.back(), &err);
|
||||
driver.m_reference.back(), &err);
|
||||
if (file.empty()) {
|
||||
std::stringstream ss;
|
||||
ss << "Failed to load locate the GeoDB file from: " << $1 << " ";
|
||||
@ -1589,13 +1589,13 @@ expression:
|
||||
/* Body limits */
|
||||
| CONFIG_DIR_REQ_BODY_LIMIT
|
||||
{
|
||||
driver.m_requestBodyLimit.m_set = true;
|
||||
driver.m_requestBodyLimit.m_value = atoi($1.c_str());
|
||||
driver.m_trail->m_requestBodyLimit.m_set = true;
|
||||
driver.m_trail->m_requestBodyLimit.m_value = atoi($1.c_str());
|
||||
}
|
||||
| CONFIG_DIR_REQ_BODY_NO_FILES_LIMIT
|
||||
{
|
||||
driver.m_requestBodyNoFilesLimit.m_set = true;
|
||||
driver.m_requestBodyNoFilesLimit.m_value = atoi($1.c_str());
|
||||
driver.m_trail->m_requestBodyNoFilesLimit.m_set = true;
|
||||
driver.m_trail->m_requestBodyNoFilesLimit.m_value = atoi($1.c_str());
|
||||
}
|
||||
| CONFIG_DIR_REQ_BODY_IN_MEMORY_LIMIT
|
||||
{
|
||||
@ -1608,32 +1608,32 @@ expression:
|
||||
}
|
||||
| CONFIG_DIR_RES_BODY_LIMIT
|
||||
{
|
||||
driver.m_responseBodyLimit.m_set = true;
|
||||
driver.m_responseBodyLimit.m_value = atoi($1.c_str());
|
||||
driver.m_trail->m_responseBodyLimit.m_set = true;
|
||||
driver.m_trail->m_responseBodyLimit.m_value = atoi($1.c_str());
|
||||
}
|
||||
| CONFIG_DIR_REQ_BODY_LIMIT_ACTION CONFIG_VALUE_PROCESS_PARTIAL
|
||||
{
|
||||
driver.m_requestBodyLimitAction = modsecurity::Rules::BodyLimitAction::ProcessPartialBodyLimitAction;
|
||||
driver.m_trail->m_requestBodyLimitAction = modsecurity::Rules::BodyLimitAction::ProcessPartialBodyLimitAction;
|
||||
}
|
||||
| CONFIG_DIR_REQ_BODY_LIMIT_ACTION CONFIG_VALUE_REJECT
|
||||
{
|
||||
driver.m_requestBodyLimitAction = modsecurity::Rules::BodyLimitAction::RejectBodyLimitAction;
|
||||
driver.m_trail->m_requestBodyLimitAction = modsecurity::Rules::BodyLimitAction::RejectBodyLimitAction;
|
||||
}
|
||||
| CONFIG_DIR_RES_BODY_LIMIT_ACTION CONFIG_VALUE_PROCESS_PARTIAL
|
||||
{
|
||||
driver.m_responseBodyLimitAction = modsecurity::Rules::BodyLimitAction::ProcessPartialBodyLimitAction;
|
||||
driver.m_trail->m_responseBodyLimitAction = modsecurity::Rules::BodyLimitAction::ProcessPartialBodyLimitAction;
|
||||
}
|
||||
| CONFIG_DIR_RES_BODY_LIMIT_ACTION CONFIG_VALUE_REJECT
|
||||
{
|
||||
driver.m_responseBodyLimitAction = modsecurity::Rules::BodyLimitAction::RejectBodyLimitAction;
|
||||
driver.m_trail->m_responseBodyLimitAction = modsecurity::Rules::BodyLimitAction::RejectBodyLimitAction;
|
||||
}
|
||||
| CONFIG_SEC_REMOTE_RULES_FAIL_ACTION CONFIG_VALUE_ABORT
|
||||
{
|
||||
driver.m_remoteRulesActionOnFailed = Rules::OnFailedRemoteRulesAction::AbortOnFailedRemoteRulesAction;
|
||||
driver.m_trail->m_remoteRulesActionOnFailed = Rules::OnFailedRemoteRulesAction::AbortOnFailedRemoteRulesAction;
|
||||
}
|
||||
| CONFIG_SEC_REMOTE_RULES_FAIL_ACTION CONFIG_VALUE_WARN
|
||||
{
|
||||
driver.m_remoteRulesActionOnFailed = Rules::OnFailedRemoteRulesAction::WarnOnFailedRemoteRulesAction;
|
||||
driver.m_trail->m_remoteRulesActionOnFailed = Rules::OnFailedRemoteRulesAction::WarnOnFailedRemoteRulesAction;
|
||||
}
|
||||
| CONFIG_DIR_PCRE_MATCH_LIMIT_RECURSION
|
||||
/* Parser error disabled to avoid breaking default installations with modsecurity.conf-recommended
|
||||
@ -1650,26 +1650,26 @@ expression:
|
||||
std::istringstream buf($1);
|
||||
std::istream_iterator<std::string> beg(buf), end;
|
||||
std::set<std::string> tokens(beg, end);
|
||||
driver.m_responseBodyTypeToBeInspected.m_set = true;
|
||||
driver.m_trail->m_responseBodyTypeToBeInspected.m_set = true;
|
||||
for (std::set<std::string>::iterator it=tokens.begin();
|
||||
it!=tokens.end(); ++it)
|
||||
{
|
||||
driver.m_responseBodyTypeToBeInspected.m_value.insert(*it);
|
||||
driver.m_trail->m_responseBodyTypeToBeInspected.m_value.insert(*it);
|
||||
}
|
||||
}
|
||||
| CONGIG_DIR_RESPONSE_BODY_MP_CLEAR
|
||||
{
|
||||
driver.m_responseBodyTypeToBeInspected.m_set = true;
|
||||
driver.m_responseBodyTypeToBeInspected.m_clear = true;
|
||||
driver.m_responseBodyTypeToBeInspected.m_value.clear();
|
||||
driver.m_trail->m_responseBodyTypeToBeInspected.m_set = true;
|
||||
driver.m_trail->m_responseBodyTypeToBeInspected.m_clear = true;
|
||||
driver.m_trail->m_responseBodyTypeToBeInspected.m_value.clear();
|
||||
}
|
||||
| CONFIG_XML_EXTERNAL_ENTITY CONFIG_VALUE_OFF
|
||||
{
|
||||
driver.m_secXMLExternalEntity = modsecurity::RulesProperties::FalseConfigBoolean;
|
||||
driver.m_trail->m_secXMLExternalEntity = modsecurity::RulesProperties::FalseConfigBoolean;
|
||||
}
|
||||
| CONFIG_XML_EXTERNAL_ENTITY CONFIG_VALUE_ON
|
||||
{
|
||||
driver.m_secXMLExternalEntity = modsecurity::RulesProperties::TrueConfigBoolean;
|
||||
driver.m_trail->m_secXMLExternalEntity = modsecurity::RulesProperties::TrueConfigBoolean;
|
||||
}
|
||||
| CONGIG_DIR_SEC_TMP_DIR
|
||||
{
|
||||
@ -1746,7 +1746,7 @@ expression:
|
||||
param.pop_back();
|
||||
}
|
||||
|
||||
file = modsecurity::utils::find_resource(f, driver.ref.back(), &err);
|
||||
file = modsecurity::utils::find_resource(f, driver.m_reference.back(), &err);
|
||||
if (file.empty()) {
|
||||
std::stringstream ss;
|
||||
ss << "Failed to locate the unicode map file from: " << f << " ";
|
||||
@ -1755,7 +1755,7 @@ expression:
|
||||
YYERROR;
|
||||
}
|
||||
|
||||
ConfigUnicodeMap::loadConfig(file, num, &driver, &error);
|
||||
ConfigUnicodeMap::loadConfig(file, num, driver.m_trail, &error);
|
||||
|
||||
if (!error.empty()) {
|
||||
driver.error(@0, error);
|
||||
@ -1772,8 +1772,8 @@ expression:
|
||||
}
|
||||
| CONFIG_SEC_HTTP_BLKEY
|
||||
{
|
||||
driver.m_httpblKey.m_set = true;
|
||||
driver.m_httpblKey.m_value = $1;
|
||||
driver.m_trail->m_httpblKey.m_set = true;
|
||||
driver.m_trail->m_httpblKey.m_value = $1;
|
||||
}
|
||||
;
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -147,7 +147,7 @@ int Rules::load(const char *plainRules) {
|
||||
|
||||
|
||||
std::string Rules::getParserError() {
|
||||
return this->m_parserError.str();
|
||||
return m_parserError.str();
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user