Places class Driver under the Parser namespace

This commit is contained in:
Felipe Zimmerle 2015-07-23 01:31:37 -03:00
parent 9c2158958e
commit b5ca607e76
6 changed files with 35 additions and 9 deletions

View File

@ -34,11 +34,13 @@ typedef struct Assay_t Assay;
#include "modsecurity/assay.h"
#ifdef __cplusplus
class Driver;
namespace ModSecurity {
class Rule;
class AuditLog;
namespace Parser {
class Driver;
}
/** @ingroup ModSecurity_CPP_API */
class Rules {
@ -68,7 +70,7 @@ class Rules {
int loadRemote(char *key, char *uri);
int load(const char *rules);
int merge(Driver *driver);
int merge(Parser::Driver *driver);
int merge(Rules *rules);
int evaluate(int phase, Assay *assay);

View File

@ -18,11 +18,16 @@
#include "parser/seclang-parser.hh"
#include "src/audit_log.h"
using ModSecurity::AuditLog;
using ModSecurity::Rule;
namespace ModSecurity {
namespace Parser {
Driver::Driver()
: trace_scanning(false),
trace_parsing(false) {
audit_log = new ModSecurity::AuditLog();
audit_log = new AuditLog();
}
@ -30,8 +35,8 @@ Driver::~Driver() {
}
int Driver::addSecRule(ModSecurity::Rule *rule) {
if (rule->phase >= ModSecurity::ModSecurity::Phases::NUMBER_OF_PHASES) {
int Driver::addSecRule(Rule *rule) {
if (rule->phase >= ModSecurity::Phases::NUMBER_OF_PHASES) {
/** TODO: return an error message */
return -1;
}
@ -43,13 +48,13 @@ int Driver::addSecRule(ModSecurity::Rule *rule) {
return true;
}
ModSecurity::Rule *lastRule = this->rules[rule->phase][size-1];
Rule *lastRule = this->rules[rule->phase][size-1];
if (lastRule->chained && lastRule->chainedRule == NULL) {
lastRule->chainedRule = rule;
return true;
}
if (lastRule->chained && lastRule->chainedRule != NULL) {
ModSecurity::Rule *a = lastRule->chainedRule;
Rule *a = lastRule->chainedRule;
while (a->chained && a->chainedRule != NULL) {
a = a->chainedRule;
}
@ -113,3 +118,6 @@ void Driver::parser_error(const yy::location& l, const std::string& m) {
parserError << ". " << m << "." << std::endl;
}
} // namespace Parser
} // namespace ModSecurity

View File

@ -36,10 +36,12 @@ using ModSecurity::Rules;
# define YY_DECL \
yy::seclang_parser::symbol_type yylex(Driver& driver)
yy::seclang_parser::symbol_type yylex(ModSecurity::Parser::Driver& driver)
YY_DECL;
namespace ModSecurity {
namespace Parser {
#ifdef __cplusplus
class Driver;
@ -89,4 +91,7 @@ class Driver : public Rules {
};
} // namespace Parser
} // namespace ModSecurity
#endif // SRC_PARSER_DRIVER_H_

View File

@ -9,7 +9,11 @@
{
# include <string>
namespace ModSecurity {
namespace Parser {
class Driver;
}
}
#include "actions/action.h"
#include "actions/transformations/transformation.h"
@ -55,7 +59,7 @@ using ModSecurity::Variables::Variable;
}
// The parsing context.
%param { Driver& driver }
%param { ModSecurity::Parser::Driver& driver }
%locations
%initial-action
{

View File

@ -6,6 +6,8 @@
# include "parser/driver.h"
# include "seclang-parser.hh"
using ModSecurity::Parser::Driver;
// Work around an incompatibility in flex (at least versions
// 2.5.31 through 2.5.33): it generates code that does
// not conform to C89. See Debian bug 333231
@ -185,6 +187,8 @@ FREE_TEXT_NEW_LINE [^\"|\n]+
%%
namespace ModSecurity {
void Driver::scan_begin () {
yy_flex_debug = trace_scanning;
if (buffer.empty() == false) {
@ -206,3 +210,4 @@ void Driver::scan_end () {
}
}
}

View File

@ -26,6 +26,8 @@
#include "src/utils.h"
#include "parser/driver.h"
using ModSecurity::Parser::Driver;
namespace ModSecurity {