mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
Places class Driver under the Parser namespace
This commit is contained in:
parent
9c2158958e
commit
b5ca607e76
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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_
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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 () {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -26,6 +26,8 @@
|
||||
#include "src/utils.h"
|
||||
#include "parser/driver.h"
|
||||
|
||||
using ModSecurity::Parser::Driver;
|
||||
|
||||
namespace ModSecurity {
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user