mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
Adds all variables to the 'Variables' name space
This commit is contained in:
parent
261ee9f115
commit
16bb253d0e
@ -28,7 +28,12 @@ pkginclude_HEADERS = \
|
||||
../headers/modsecurity/debug_log.h \
|
||||
../headers/modsecurity/intervention.h
|
||||
|
||||
|
||||
VARIABLES = \
|
||||
variables/duration.cc \
|
||||
variables/env.cc \
|
||||
variables/highest_severity.cc \
|
||||
variables/modsec_build.cc \
|
||||
variables/time.cc \
|
||||
variables/time_day.cc \
|
||||
variables/time_epoch.cc \
|
||||
@ -37,7 +42,10 @@ VARIABLES = \
|
||||
variables/time_mon.cc \
|
||||
variables/time_sec.cc \
|
||||
variables/time_wday.cc \
|
||||
variables/time_year.cc
|
||||
variables/time_year.cc \
|
||||
variables/variable.cc
|
||||
|
||||
|
||||
|
||||
ACTIONS = \
|
||||
actions/action.cc \
|
||||
@ -108,11 +116,6 @@ libmodsecurity_la_SOURCES = \
|
||||
request_body_processor/multipart_blob.cc \
|
||||
rule.cc \
|
||||
unique_id.cc \
|
||||
variable.cc \
|
||||
variable_duration.cc \
|
||||
variable_env.cc \
|
||||
variable_modsec_build.cc \
|
||||
variable_highest_severity.cc \
|
||||
operators/operator.cc \
|
||||
operators/detect_sqli.cc \
|
||||
operators/detect_xss.cc \
|
||||
|
@ -15,14 +15,15 @@ class Driver;
|
||||
#include "actions/transformations/transformation.h"
|
||||
#include "operators/operator.h"
|
||||
#include "rule.h"
|
||||
#include "variable_duration.h"
|
||||
#include "variable_env.h"
|
||||
#include "variable_modsec_build.h"
|
||||
#include "variable_highest_severity.h"
|
||||
#include "utils/geo_lookup.h"
|
||||
#include "variables/time.h"
|
||||
|
||||
#include "variables/duration.h"
|
||||
#include "variables/env.h"
|
||||
#include "variables/highest_severity.h"
|
||||
#include "variables/modsec_build.h"
|
||||
#include "variables/time_day.h"
|
||||
#include "variables/time_epoch.h"
|
||||
#include "variables/time.h"
|
||||
#include "variables/time_hour.h"
|
||||
#include "variables/time_min.h"
|
||||
#include "variables/time_mon.h"
|
||||
@ -33,13 +34,13 @@ class Driver;
|
||||
using ModSecurity::actions::Action;
|
||||
using ModSecurity::actions::transformations::Transformation;
|
||||
using ModSecurity::operators::Operator;
|
||||
using ModSecurity::Variable;
|
||||
using ModSecurity::VariableDuration;
|
||||
using ModSecurity::VariableEnv;
|
||||
using ModSecurity::VariableModsecBuild;
|
||||
using ModSecurity::VariableHighestSeverity;
|
||||
using ModSecurity::Rule;
|
||||
using ModSecurity::Utils::GeoLookup;
|
||||
|
||||
using ModSecurity::Variables::Duration;
|
||||
using ModSecurity::Variables::Env;
|
||||
using ModSecurity::Variables::HighestSeverity;
|
||||
using ModSecurity::Variables::ModsecBuild;
|
||||
using ModSecurity::Variables::Time;
|
||||
using ModSecurity::Variables::TimeDay;
|
||||
using ModSecurity::Variables::TimeEpoch;
|
||||
@ -49,6 +50,7 @@ using ModSecurity::Variables::TimeMon;
|
||||
using ModSecurity::Variables::TimeSec;
|
||||
using ModSecurity::Variables::TimeWDay;
|
||||
using ModSecurity::Variables::TimeYear;
|
||||
using ModSecurity::Variables::Variable;
|
||||
|
||||
}
|
||||
// The parsing context.
|
||||
@ -326,61 +328,61 @@ variables:
|
||||
| variables PIPE RUN_TIME_VAR_DUR
|
||||
{
|
||||
std::vector<Variable *> *v = $1;
|
||||
v->push_back(new VariableDuration($3));
|
||||
v->push_back(new Duration($3));
|
||||
$$ = $1;
|
||||
}
|
||||
| RUN_TIME_VAR_DUR
|
||||
{
|
||||
std::vector<Variable *> *variables = new std::vector<Variable *>;
|
||||
variables->push_back(new VariableDuration($1));
|
||||
variables->push_back(new Duration($1));
|
||||
$$ = variables;
|
||||
}
|
||||
| variables PIPE RUN_TIME_VAR_ENV
|
||||
{
|
||||
std::vector<Variable *> *v = $1;
|
||||
v->push_back(new VariableEnv($3));
|
||||
v->push_back(new Env($3));
|
||||
$$ = $1;
|
||||
}
|
||||
| RUN_TIME_VAR_ENV
|
||||
{
|
||||
std::vector<Variable *> *variables = new std::vector<Variable *>;
|
||||
variables->push_back(new VariableEnv($1));
|
||||
variables->push_back(new Env($1));
|
||||
$$ = variables;
|
||||
}
|
||||
| variables PIPE RUN_TIME_VAR_BLD
|
||||
{
|
||||
std::vector<Variable *> *v = $1;
|
||||
v->push_back(new VariableModsecBuild($3));
|
||||
v->push_back(new ModsecBuild($3));
|
||||
$$ = $1;
|
||||
}
|
||||
| RUN_TIME_VAR_BLD
|
||||
{
|
||||
std::vector<Variable *> *variables = new std::vector<Variable *>;
|
||||
variables->push_back(new VariableModsecBuild($1));
|
||||
variables->push_back(new ModsecBuild($1));
|
||||
$$ = variables;
|
||||
}
|
||||
| variables PIPE RUN_TIME_VAR_HSV
|
||||
{
|
||||
std::vector<Variable *> *v = $1;
|
||||
v->push_back(new VariableHighestSeverity($3));
|
||||
v->push_back(new HighestSeverity($3));
|
||||
$$ = $1;
|
||||
}
|
||||
| RUN_TIME_VAR_HSV
|
||||
{
|
||||
std::vector<Variable *> *variables = new std::vector<Variable *>;
|
||||
variables->push_back(new VariableHighestSeverity($1));
|
||||
variables->push_back(new HighestSeverity($1));
|
||||
$$ = variables;
|
||||
}
|
||||
| RUN_TIME_VAR_TIME
|
||||
{
|
||||
std::vector<Variable *> *variables = new std::vector<Variable *>;
|
||||
variables->push_back(new ModSecurity::Variables::Time($1));
|
||||
variables->push_back(new Time($1));
|
||||
$$ = variables;
|
||||
}
|
||||
| RUN_TIME_VAR_TIME_DAY
|
||||
{
|
||||
std::vector<Variable *> *variables = new std::vector<Variable *>;
|
||||
variables->push_back(new ModSecurity::Variables::TimeDay($1));
|
||||
variables->push_back(new TimeDay($1));
|
||||
$$ = variables;
|
||||
}
|
||||
| RUN_TIME_VAR_TIME_EPOCH
|
||||
|
@ -32,6 +32,7 @@ namespace ModSecurity {
|
||||
|
||||
using operators::Operator;
|
||||
using actions::Action;
|
||||
using Variables::Variable;
|
||||
|
||||
Rule::Rule(Operator *_op,
|
||||
std::vector<Variable *> *_variables,
|
||||
|
@ -22,7 +22,7 @@
|
||||
#define SRC_RULE_H_
|
||||
|
||||
#include "modsecurity/modsecurity.h"
|
||||
#include "src/variable.h"
|
||||
#include "variables/variable.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@ -31,7 +31,7 @@ namespace ModSecurity {
|
||||
class Rule {
|
||||
public:
|
||||
Rule(operators::Operator *_op,
|
||||
std::vector<Variable *> *_variables,
|
||||
std::vector<Variables::Variable *> *_variables,
|
||||
std::vector<actions::Action *> *_actions);
|
||||
|
||||
bool evaluate(Assay *assay);
|
||||
@ -41,7 +41,7 @@ class Rule {
|
||||
std::vector<actions::Action *> actions_runtime_pre;
|
||||
std::vector<actions::Action *> actions_runtime_pos;
|
||||
|
||||
std::vector<Variable *> *variables;
|
||||
std::vector<Variables::Variable *> *variables;
|
||||
int phase;
|
||||
double rule_id;
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "src/variable_duration.h"
|
||||
#include "variables/duration.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
@ -25,9 +25,10 @@
|
||||
#include "modsecurity/assay.h"
|
||||
|
||||
namespace ModSecurity {
|
||||
namespace Variables {
|
||||
|
||||
std::list<std::pair<std::string, std::string>>
|
||||
VariableDuration::evaluate(Assay *assay) {
|
||||
Duration::evaluate(Assay *assay) {
|
||||
std::list<std::pair<std::string, std::string>> resl;
|
||||
std::string res;
|
||||
std::pair<std::string, std::string> pair;
|
||||
@ -44,4 +45,5 @@ std::list<std::pair<std::string, std::string>>
|
||||
}
|
||||
|
||||
|
||||
} // namespace Variables
|
||||
} // namespace ModSecurity
|
@ -18,24 +18,27 @@
|
||||
#include <list>
|
||||
#include <utility>
|
||||
|
||||
#ifndef SRC_VARIABLE_HIGHEST_SEVERITY_H_
|
||||
#define SRC_VARIABLE_HIGHEST_SEVERITY_H_
|
||||
#ifndef SRC_VARIABLES_DURATION_H_
|
||||
#define SRC_VARIABLES_DURATION_H_
|
||||
|
||||
#include "src/variable.h"
|
||||
#include "variables/variable.h"
|
||||
|
||||
namespace ModSecurity {
|
||||
|
||||
class Assay;
|
||||
namespace Variables {
|
||||
|
||||
class VariableHighestSeverity : public Variable {
|
||||
class Duration : public Variable {
|
||||
public:
|
||||
explicit VariableHighestSeverity(std::string _name)
|
||||
explicit Duration(std::string _name)
|
||||
: Variable(_name) { }
|
||||
|
||||
std::list<std::pair<std::string, std::string>>
|
||||
evaluate(Assay *assay) override;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Variables
|
||||
} // namespace ModSecurity
|
||||
|
||||
#endif // SRC_VARIABLE_HIGHEST_SEVERITY_H_
|
||||
#endif // SRC_VARIABLES_DURATION_H_
|
@ -13,7 +13,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "src/variable_env.h"
|
||||
#include "variables/env.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
@ -31,9 +31,10 @@
|
||||
extern char **environ;
|
||||
|
||||
namespace ModSecurity {
|
||||
namespace Variables {
|
||||
|
||||
std::list<std::pair<std::string, std::string>>
|
||||
VariableEnv::evaluate(Assay *assay) {
|
||||
Env::evaluate(Assay *assay) {
|
||||
std::list<std::pair<std::string, std::string>> resl;
|
||||
|
||||
std::map<std::string, std::string> envs;
|
||||
@ -64,4 +65,5 @@ std::list<std::pair<std::string, std::string>>
|
||||
}
|
||||
|
||||
|
||||
} // namespace Variables
|
||||
} // namespace ModSecurity
|
@ -18,24 +18,27 @@
|
||||
#include <list>
|
||||
#include <utility>
|
||||
|
||||
#ifndef SRC_VARIABLE_DURATION_H_
|
||||
#define SRC_VARIABLE_DURATION_H_
|
||||
#ifndef SRC_VARIABLES_ENV_H_
|
||||
#define SRC_VARIABLES_ENV_H_
|
||||
|
||||
#include "src/variable.h"
|
||||
#include "variables/variable.h"
|
||||
|
||||
namespace ModSecurity {
|
||||
|
||||
class Assay;
|
||||
namespace Variables {
|
||||
|
||||
class VariableDuration : public Variable {
|
||||
class Env : public Variable {
|
||||
public:
|
||||
explicit VariableDuration(std::string _name)
|
||||
explicit Env(std::string _name)
|
||||
: Variable(_name) { }
|
||||
|
||||
std::list<std::pair<std::string, std::string>>
|
||||
evaluate(Assay *assay) override;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Variables
|
||||
} // namespace ModSecurity
|
||||
|
||||
#endif // SRC_VARIABLE_DURATION_H_
|
||||
#endif // SRC_VARIABLES_ENV_H_
|
@ -13,7 +13,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "src/variable_highest_severity.h"
|
||||
#include "variables/highest_severity.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
@ -24,9 +24,10 @@
|
||||
#include "modsecurity/assay.h"
|
||||
|
||||
namespace ModSecurity {
|
||||
namespace Variables {
|
||||
|
||||
std::list<std::pair<std::string, std::string>>
|
||||
VariableHighestSeverity::evaluate(Assay *assay) {
|
||||
HighestSeverity::evaluate(Assay *assay) {
|
||||
std::list<std::pair<std::string, std::string>> resl;
|
||||
std::pair<std::string, std::string> pair;
|
||||
|
||||
@ -38,4 +39,5 @@ std::list<std::pair<std::string, std::string>>
|
||||
}
|
||||
|
||||
|
||||
} // namespace Variables
|
||||
} // namespace ModSecurity
|
@ -18,24 +18,27 @@
|
||||
#include <list>
|
||||
#include <utility>
|
||||
|
||||
#ifndef SRC_VARIABLE_ENV_H_
|
||||
#define SRC_VARIABLE_ENV_H_
|
||||
#ifndef SRC_VARIABLES_HIGHEST_SEVERITY_H_
|
||||
#define SRC_VARIABLES_HIGHEST_SEVERITY_H_
|
||||
|
||||
#include "src/variable.h"
|
||||
#include "variables/variable.h"
|
||||
|
||||
namespace ModSecurity {
|
||||
|
||||
class Assay;
|
||||
namespace Variables {
|
||||
|
||||
class VariableEnv : public Variable {
|
||||
class HighestSeverity : public Variable {
|
||||
public:
|
||||
explicit VariableEnv(std::string _name)
|
||||
explicit HighestSeverity(std::string _name)
|
||||
: Variable(_name) { }
|
||||
|
||||
std::list<std::pair<std::string, std::string>>
|
||||
evaluate(Assay *assay) override;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Variables
|
||||
} // namespace ModSecurity
|
||||
|
||||
#endif // SRC_VARIABLE_ENV_H_
|
||||
#endif // SRC_VARIABLES_HIGHEST_SEVERITY_H_
|
@ -13,7 +13,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "src/variable_modsec_build.h"
|
||||
#include "variables/modsec_build.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
@ -25,9 +25,10 @@
|
||||
#include "modsecurity/modsecurity.h"
|
||||
|
||||
namespace ModSecurity {
|
||||
namespace Variables {
|
||||
|
||||
std::list<std::pair<std::string, std::string>>
|
||||
VariableModsecBuild::evaluate(Assay *assay) {
|
||||
ModsecBuild::evaluate(Assay *assay) {
|
||||
std::list<std::pair<std::string, std::string>> resl;
|
||||
std::pair<std::string, std::string> pair;
|
||||
|
||||
@ -44,4 +45,5 @@ std::list<std::pair<std::string, std::string>>
|
||||
}
|
||||
|
||||
|
||||
} // namespace Variables
|
||||
} // namespace ModSecurity
|
@ -18,24 +18,27 @@
|
||||
#include <list>
|
||||
#include <utility>
|
||||
|
||||
#ifndef SRC_VARIABLE_MODSEC_BUILD_H_
|
||||
#define SRC_VARIABLE_MODSEC_BUILD_H_
|
||||
#ifndef SRC_VARIABLES_MODSEC_BUILD_H_
|
||||
#define SRC_VARIABLES_MODSEC_BUILD_H_
|
||||
|
||||
#include "src/variable.h"
|
||||
#include "variables/variable.h"
|
||||
|
||||
namespace ModSecurity {
|
||||
|
||||
class Assay;
|
||||
namespace Variables {
|
||||
|
||||
class VariableModsecBuild : public Variable {
|
||||
class ModsecBuild : public Variable {
|
||||
public:
|
||||
explicit VariableModsecBuild(std::string _name)
|
||||
explicit ModsecBuild(std::string _name)
|
||||
: Variable(_name) { }
|
||||
|
||||
std::list<std::pair<std::string, std::string>>
|
||||
evaluate(Assay *assay) override;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Variables
|
||||
} // namespace ModSecurity
|
||||
|
||||
#endif // SRC_VARIABLE_MODSEC_BUILD_H_
|
||||
#endif // SRC_VARIABLES_MODSEC_BUILD_H_
|
@ -22,7 +22,7 @@
|
||||
#ifndef SRC_VARIABLES_TIME_H_
|
||||
#define SRC_VARIABLES_TIME_H_
|
||||
|
||||
#include "src/variable.h"
|
||||
#include "variables/variable.h"
|
||||
|
||||
namespace ModSecurity {
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
#ifndef SRC_VARIABLES_TIME_DAY_H_
|
||||
#define SRC_VARIABLES_TIME_DAY_H_
|
||||
|
||||
#include "src/variable.h"
|
||||
#include "variables/variable.h"
|
||||
|
||||
namespace ModSecurity {
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
#ifndef SRC_VARIABLES_TIME_EPOCH_H_
|
||||
#define SRC_VARIABLES_TIME_EPOCH_H_
|
||||
|
||||
#include "src/variable.h"
|
||||
#include "variables/variable.h"
|
||||
|
||||
namespace ModSecurity {
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
#ifndef SRC_VARIABLES_TIME_HOUR_H_
|
||||
#define SRC_VARIABLES_TIME_HOUR_H_
|
||||
|
||||
#include "src/variable.h"
|
||||
#include "variables/variable.h"
|
||||
|
||||
namespace ModSecurity {
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
#ifndef SRC_VARIABLES_TIME_MIN_H_
|
||||
#define SRC_VARIABLES_TIME_MIN_H_
|
||||
|
||||
#include "src/variable.h"
|
||||
#include "variables/variable.h"
|
||||
|
||||
namespace ModSecurity {
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
#ifndef SRC_VARIABLES_TIME_MON_H_
|
||||
#define SRC_VARIABLES_TIME_MON_H_
|
||||
|
||||
#include "src/variable.h"
|
||||
#include "variables/variable.h"
|
||||
|
||||
namespace ModSecurity {
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
#ifndef SRC_VARIABLES_TIME_SEC_H_
|
||||
#define SRC_VARIABLES_TIME_SEC_H_
|
||||
|
||||
#include "src/variable.h"
|
||||
#include "variables/variable.h"
|
||||
|
||||
namespace ModSecurity {
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
#ifndef SRC_VARIABLES_TIME_WDAY_H_
|
||||
#define SRC_VARIABLES_TIME_WDAY_H_
|
||||
|
||||
#include "src/variable.h"
|
||||
#include "variables/variable.h"
|
||||
|
||||
namespace ModSecurity {
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
#ifndef SRC_VARIABLES_TIME_YEAR_H_
|
||||
#define SRC_VARIABLES_TIME_YEAR_H_
|
||||
|
||||
#include "src/variable.h"
|
||||
#include "variables/variable.h"
|
||||
|
||||
namespace ModSecurity {
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "src/variable.h"
|
||||
#include "variables/variable.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
@ -23,6 +23,7 @@
|
||||
#include "modsecurity/assay.h"
|
||||
|
||||
namespace ModSecurity {
|
||||
namespace Variables {
|
||||
|
||||
std::list<std::pair<std::string, std::string>>
|
||||
Variable::evaluate(Assay *assay) {
|
||||
@ -45,4 +46,6 @@ std::string Variable::to_s(
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Variables
|
||||
} // namespace ModSecurity
|
@ -18,12 +18,13 @@
|
||||
#include <list>
|
||||
#include <utility>
|
||||
|
||||
#ifndef SRC_VARIABLE_H_
|
||||
#define SRC_VARIABLE_H_
|
||||
#ifndef SRC_VARIABLES_VARIABLE_H_
|
||||
#define SRC_VARIABLES_VARIABLE_H_
|
||||
|
||||
namespace ModSecurity {
|
||||
|
||||
class Assay;
|
||||
namespace Variables {
|
||||
|
||||
class Variable {
|
||||
public:
|
||||
@ -36,6 +37,8 @@ class Variable {
|
||||
std::string name;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Variables
|
||||
} // namespace ModSecurity
|
||||
|
||||
#endif // SRC_VARIABLE_H_
|
||||
#endif // SRC_VARIABLES_VARIABLE_H_
|
Loading…
x
Reference in New Issue
Block a user