Very first commit: libmodsecurity

Check the README.md file for further information about the libmodsecurity.
This commit is contained in:
Felipe Zimmerle
2015-06-26 14:35:15 -03:00
parent 33cbe0452a
commit 95cb4c56ab
153 changed files with 12862 additions and 0 deletions

108
src/Makefile.am Normal file
View File

@@ -0,0 +1,108 @@
libmodsecuritydir = $(prefix)/lib
libmodsecurity_LTLIBRARIES = libmodsecurity.la
libmodsecurity_ladir = $(prefix)/include
CLEANFILES = \
location.hh \
position.hh \
parser/seclang-parser.cc \
parser/seclang-parser.hh \
parser/seclang-scanner.cc \
stack.hh
MAINTAINERCLEANFILES = \
Makefile.in \
config.h.in \
config.h.in~
pkginclude_HEADERS = \
../headers/modsecurity/modsecurity.h \
../headers/modsecurity/assay.h \
../headers/modsecurity/rules.h \
../headers/modsecurity/debug_log.h \
../headers/modsecurity/intervention.h
libmodsecurity_la_SOURCES = \
parser/seclang-parser.yy \
parser/seclang-scanner.ll \
parser/driver.cc \
assay.cc \
modsecurity.cc \
rules.cc \
utils.cc \
debug_log.cc \
rule.cc \
variable.cc \
operators/operator.cc \
operators/detect_sqli.cc \
operators/detect_xss.cc \
operators/inspect_file.cc \
operators/fuzzy_hash.cc \
operators/validate_byte_range.cc \
operators/validate_dtd.cc \
operators/validate_hash.cc \
operators/validate_schema.cc \
operators/validate_url_encoding.cc \
operators/validate_utf8_encoding.cc \
operators/verify_cc.cc \
operators/verify_cpf.cc \
operators/verify_ssn.cc \
operators/geolookup.cc \
operators/gsblookup.cc \
operators/rsub.cc \
operators/within.cc \
operators/contains_word.cc \
operators/contains.cc \
operators/ends_with.cc \
operators/eq.cc \
operators/ge.cc \
operators/gt.cc \
operators/ip_match_f.cc \
operators/ip_match.cc \
operators/ip_match_from_file.cc \
operators/le.cc \
operators/lt.cc \
operators/pm_f.cc \
operators/pm.cc \
operators/pm_from_file.cc \
operators/rbl.cc \
operators/rx.cc \
operators/str_eq.cc \
operators/str_match.cc \
operators/begins_with.cc \
actions/rule_id.cc \
actions/phase.cc \
actions/action.cc \
actions/block.cc \
actions/redirect.cc \
actions/status.cc \
actions/transformations/transformation.cc \
actions/transformations/trim.cc \
actions/transformations/lowercase.cc
libmodsecurity_la_CFLAGS =
libmodsecurity_la_CPPFLAGS = \
-std=c++11 \
-I.. \
-g \
-O0 \
-I ../headers
libmodsecurity_la_LIBADD = \
@LEXLIB@
libmodsecurity_la_LDFLAGS = \
-version-info @MSC_VERSION_INFO@

78
src/actions/action.cc Normal file
View File

@@ -0,0 +1,78 @@
/**
* 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 "actions/action.h"
#include <iostream>
#include <string>
#include "modsecurity/assay.h"
#include "actions/block.h"
#include "actions/redirect.h"
#include "actions/status.h"
#include "actions/rule_id.h"
#include "actions/phase.h"
namespace ModSecurity {
namespace actions {
std::string & Action::evaluate(std::string value,
Assay *assay) {
return value;
}
bool Action::evaluate(Assay *assay) {
return true;
}
bool Action::evaluate(Rule *rule) {
return true;
}
void Action::fill_intervention(ModSecurityIntervention *i) {
}
Action *Action::instantiate(std::string name) {
std::string status("status:");
std::string redirect("redirect:");
std::string block("block");
std::string phase("phase:");
std::string rule_id("id:");
if (name.compare(0, status.length(), status) == 0) {
return new Status(name);
}
if (name.compare(0, redirect.length(), redirect) == 0) {
return new Redirect(name);
}
if (name.compare(0, block.length(), block) == 0) {
return new Block(name);
}
if (name.compare(0, phase.length(), phase) == 0) {
return new Phase(name);
}
if (name.compare(0, rule_id.length(), rule_id) == 0) {
return new RuleId(name);
}
return new Action(name);
}
} // namespace actions
} // namespace ModSecurity

90
src/actions/action.h Normal file
View File

@@ -0,0 +1,90 @@
/**
* 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 <string>
#include "modsecurity/intervention.h"
#ifndef SRC_ACTIONS_ACTION_H_
#define SRC_ACTIONS_ACTION_H_
#ifdef __cplusplus
namespace ModSecurity {
class Assay;
class Rule;
namespace actions {
class Action {
public:
explicit Action(std::string _action)
: action_kind(2),
action(_action) { }
/**
*
* Define the action kind regarding to the execution time.
*
*
*/
enum Kind {
/**
*
* Action that are executed while loading the configuration. For instance
* the rule ID or the rule phase.
*
*/
ConfigurationKind,
/**
*
* Those are actions that demands to be executed before call the operator.
* For instance the tranformations.
*
*
*/
RunTimeBeforeMatchAttemptKind,
/**
*
* Actions that are executed after the execution of the operator, only if
* the operator returned Match (or True). For instance the disruptive
* actions.
*
*/
RunTimeOnlyIfMatchKind,
};
std::string action;
int action_kind;
std::string name;
virtual std::string& evaluate(std::string exp,
Assay *assay);
virtual bool evaluate(Assay *assay);
virtual bool evaluate(Rule *rule);
static Action *instantiate(std::string action);
virtual void fill_intervention(ModSecurityIntervention *intervention);
};
} // namespace actions
} // namespace ModSecurity
#endif
#endif // SRC_ACTIONS_ACTION_H_

44
src/actions/block.cc Normal file
View File

@@ -0,0 +1,44 @@
/**
* 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 "actions/block.h"
#include <iostream>
#include <string>
#include "modsecurity/assay.h"
namespace ModSecurity {
namespace actions {
Block::Block(std::string action)
: Action(action) {
this->action = action;
this->action_kind = 2;
}
bool Block::evaluate(Assay *assay) {
assay->actions.push_back(this);
return true;
}
void Block::fill_intervention(ModSecurityIntervention *i) {
i->status = 403;
i->log = "Blocked request!";
}
} // namespace actions
} // namespace ModSecurity

44
src/actions/block.h Normal file
View File

@@ -0,0 +1,44 @@
/**
* 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 <string>
#include "actions/action.h"
#ifndef SRC_ACTIONS_BLOCK_H_
#define SRC_ACTIONS_BLOCK_H_
#ifdef __cplusplus
class Assay;
namespace ModSecurity {
class Assay;
namespace actions {
class Block : public Action {
public:
explicit Block(std::string action);
bool evaluate(Assay *assay) override;
void fill_intervention(ModSecurityIntervention *i) override;
};
} // namespace actions
} // namespace ModSecurity
#endif
#endif // SRC_ACTIONS_BLOCK_H_

50
src/actions/phase.cc Normal file
View File

@@ -0,0 +1,50 @@
/**
* 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 "actions/phase.h"
#include <iostream>
#include <string>
#include "modsecurity/assay.h"
#include "src/rule.h"
#include "modsecurity/modsecurity.h"
namespace ModSecurity {
namespace actions {
Phase::Phase(std::string action)
: Action(action) {
this->action_kind = ConfigurationKind;
std::string a = action;
a.erase(0, 6);
this->phase = std::stoi(a);
if (this->phase == 0) {
/* Phase 0 is something new, we want to use as ConnectionPhase */
this->phase = ModSecurity::Phases::ConnectionPhase;
} else {
/* Otherwise we want to shift the rule to the correct phase */
this->phase = phase + ModSecurity::Phases::RequestHeadersPhase - 1;
}
}
bool Phase::evaluate(Rule *rule) {
rule->phase = this->phase;
return true;
}
} // namespace actions
} // namespace ModSecurity

45
src/actions/phase.h Normal file
View File

@@ -0,0 +1,45 @@
/**
* 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 <string>
#include "actions/action.h"
#ifndef SRC_ACTIONS_PHASE_H_
#define SRC_ACTIONS_PHASE_H_
#ifdef __cplusplus
class Assay;
namespace ModSecurity {
class Assay;
class Rule;
namespace actions {
class Phase : public Action {
public:
explicit Phase(std::string action);
bool evaluate(Rule *rule) override;
int phase;
};
} // namespace actions
} // namespace ModSecurity
#endif
#endif // SRC_ACTIONS_PHASE_H_

52
src/actions/redirect.cc Normal file
View File

@@ -0,0 +1,52 @@
/**
* 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 "actions/redirect.h"
#include <iostream>
#include <string>
#include "modsecurity/assay.h"
namespace ModSecurity {
namespace actions {
Redirect::Redirect(std::string action)
: Action(action) {
this->url = action;
this->url.erase(0, 9);
this->action = action;
this->action_kind = 2;
this->status = 302;
}
bool Redirect::evaluate(Assay *assay) {
assay->actions.push_back(this);
return true;
}
void Redirect::fill_intervention(ModSecurityIntervention *i) {
/* if it was changed before, lets keep it. */
if (i->status == 200) {
i->status = this->status;
}
// reinterpret_cast<char *>
i->url = (char *) this->url.c_str(); //** TODO: wheee */
i->log = "Redirecting";
}
} // namespace actions
} // namespace ModSecurity

45
src/actions/redirect.h Normal file
View File

@@ -0,0 +1,45 @@
/**
* 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 <string>
#include "actions/action.h"
#ifndef SRC_ACTIONS_REDIRECT_H_
#define SRC_ACTIONS_REDIRECT_H_
#ifdef __cplusplus
class Assay;
namespace ModSecurity {
class Assay;
namespace actions {
class Redirect : public Action {
public:
explicit Redirect(std::string action);
bool evaluate(Assay *assay) override;
int status;
std::string url;
void fill_intervention(ModSecurityIntervention *i) override;
};
} // namespace actions
} // namespace ModSecurity
#endif
#endif // SRC_ACTIONS_REDIRECT_H_

42
src/actions/rule_id.cc Normal file
View File

@@ -0,0 +1,42 @@
/**
* 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 "actions/rule_id.h"
#include <iostream>
#include <string>
#include "modsecurity/assay.h"
#include "src/rule.h"
namespace ModSecurity {
namespace actions {
RuleId::RuleId(std::string action)
: Action(action) {
this->action_kind = ConfigurationKind;
std::string a = action;
a.erase(0, 3);
this->rule_id = std::stod(a);
}
bool RuleId::evaluate(Rule *rule) {
rule->rule_id = this->rule_id;
return true;
}
} // namespace actions
} // namespace ModSecurity

45
src/actions/rule_id.h Normal file
View File

@@ -0,0 +1,45 @@
/**
* 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 <string>
#include "actions/action.h"
#ifndef SRC_ACTIONS_RULE_ID_H_
#define SRC_ACTIONS_RULE_ID_H_
#ifdef __cplusplus
class Assay;
namespace ModSecurity {
class Assay;
class Rule;
namespace actions {
class RuleId : public Action {
public:
explicit RuleId(std::string action);
bool evaluate(Rule *rule) override;
double rule_id;
};
} // namespace actions
} // namespace ModSecurity
#endif
#endif // SRC_ACTIONS_RULE_ID_H_

48
src/actions/status.cc Normal file
View File

@@ -0,0 +1,48 @@
/**
* 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 "actions/status.h"
#include <iostream>
#include <string>
#include "modsecurity/assay.h"
namespace ModSecurity {
namespace actions {
Status::Status(std::string action)
: Action(action) {
std::string a = action;
a.erase(0, 7);
this->action = action;
this->action_kind = 2;
this->status = stoi(a);
}
bool Status::evaluate(Assay *assay) {
assay->actions.push_back(this);
return true;
}
void Status::fill_intervention(ModSecurityIntervention *i) {
i->status = this->status;
i->log = "Status";
}
} // namespace actions
} // namespace ModSecurity

43
src/actions/status.h Normal file
View File

@@ -0,0 +1,43 @@
/**
* 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 <string>
#include "actions/action.h"
#ifndef SRC_ACTIONS_STATUS_H_
#define SRC_ACTIONS_STATUS_H_
#ifdef __cplusplus
class Assay;
namespace ModSecurity {
class Assay;
namespace actions {
class Status : public Action {
public:
explicit Status(std::string actions);
bool evaluate(Assay *assay) override;
void fill_intervention(ModSecurityIntervention *i) override;
int status;
};
} // namespace actions
} // namespace ModSecurity
#endif
#endif // SRC_ACTIONS_STATUS_H_

View File

@@ -0,0 +1,47 @@
/**
* 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 "actions/transformations/lowercase.h"
#include <algorithm>
#include <string>
#include "modsecurity/assay.h"
#include "actions/transformations/transformation.h"
#include "actions/action.h"
namespace ModSecurity {
namespace actions {
namespace transformations {
LowerCase::LowerCase(std::string a)
: Transformation(a) {
}
std::string & LowerCase::evaluate(std::string value,
Assay *assay) {
std::locale loc;
for (std::string::size_type i=0; i < value.length(); ++i) {
value[i] = std::tolower(value[i], loc);
}
return value;
}
} // namespace transformations
} // namespace actions
} // namespace ModSecurity

View File

@@ -0,0 +1,45 @@
/**
* 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 <string>
#include "actions/action.h"
#include "actions/transformations/transformation.h"
#ifndef SRC_ACTIONS_TRANSFORMATIONS_LOWERCASE_H_
#define SRC_ACTIONS_TRANSFORMATIONS_LOWERCASE_H_
#ifdef __cplusplus
namespace ModSecurity {
class Assay;
namespace actions {
namespace transformations {
class LowerCase : public Transformation {
public:
explicit LowerCase(std::string action);
std::string& evaluate(std::string exp,
Assay *assay) override;
};
} // namespace transformations
} // namespace actions
} // namespace ModSecurity
#endif
#endif // SRC_ACTIONS_TRANSFORMATIONS_LOWERCASE_H_

View File

@@ -0,0 +1,55 @@
/**
* 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 "actions/transformations/transformation.h"
#include <iostream>
#include <string>
#include "modsecurity/assay.h"
#include "actions/transformations/trim.h"
#include "actions/transformations/lowercase.h"
#include "actions/action.h"
namespace ModSecurity {
namespace actions {
namespace transformations {
Transformation::Transformation(std::string action)
: Action(action) {
this->name = this->action;
this->name.erase(0, 2);
this->action_kind = 1;
}
std::string &Transformation::evaluate(std::string value,
Assay *assay) {
return value;
}
Transformation* Transformation::instantiate(std::string a) {
if (a == "t:trim") {
return new transformations::Trim(a);
}
if (a == "t:lowercase") {
return new LowerCase(a);
}
return new Transformation(a);
}
} // namespace transformations
} // namespace actions
} // namespace ModSecurity

View File

@@ -0,0 +1,46 @@
/**
* 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 <string>
#include "actions/action.h"
#ifndef SRC_ACTIONS_TRANSFORMATIONS_TRANSFORMATION_H_
#define SRC_ACTIONS_TRANSFORMATIONS_TRANSFORMATION_H_
#ifdef __cplusplus
namespace ModSecurity {
class Assay;
namespace actions {
namespace transformations {
class Transformation : public Action {
public:
explicit Transformation(std::string action);
static Transformation* instantiate(std::string);
std::string& evaluate(std::string exp,
Assay *assay) override;
};
} // namespace transformations
} // namespace actions
} // namespace ModSecurity
#endif
#endif // SRC_ACTIONS_TRANSFORMATIONS_TRANSFORMATION_H_

View File

@@ -0,0 +1,61 @@
/**
* 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 "actions/transformations/trim.h"
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <cctype>
#include <locale>
#include "modsecurity/assay.h"
#include "actions/transformations/transformation.h"
#include "actions/action.h"
namespace ModSecurity {
namespace actions {
namespace transformations {
static inline std::string *ltrim(std::string *s) {
s->erase(s->begin(), std::find_if(s->begin(), s->end(),
std::not1(std::ptr_fun<int, int>(std::isspace))));
return s;
}
static inline std::string *rtrim(std::string *s) {
s->erase(std::find_if(s->rbegin(), s->rend(),
std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s->end());
return s;
}
static inline std::string *trim(std::string *s) {
return ltrim(rtrim(s));
}
Trim::Trim(std::string action)
: Transformation(action) {
this->action_kind = 1;
}
std::string & Trim::evaluate(std::string value,
Assay *assay) {
return *trim(&value);
}
} // namespace transformations
} // namespace actions
} // namespace ModSecurity

View File

@@ -0,0 +1,44 @@
/**
* 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 <string>
#include "actions/action.h"
#include "actions/transformations/transformation.h"
#ifndef SRC_ACTIONS_TRANSFORMATIONS_TRIM_H_
#define SRC_ACTIONS_TRANSFORMATIONS_TRIM_H_
#ifdef __cplusplus
namespace ModSecurity {
class Assay;
namespace actions {
namespace transformations {
class Trim : public Transformation {
public:
explicit Trim(std::string action);
std::string& evaluate(std::string exp,
Assay *assay) override;
};
} // namespace transformations
} // namespace actions
} // namespace ModSecurity
#endif
#endif // SRC_ACTIONS_TRANSFORMATIONS_TRIM_H_

1086
src/assay.cc Normal file

File diff suppressed because it is too large Load Diff

126
src/debug_log.cc Normal file
View File

@@ -0,0 +1,126 @@
/**
* 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 "modsecurity/debug_log.h"
#include <stddef.h>
#include <fstream>
namespace ModSecurity {
/**
* @name new_instance
* @brief Create a new instance of the DebugLog.
*
* @return Debug log pointer
* @retval >0 Debug log structure was initialized correctly
* @retval NULL Debug log could not be initialized.
*
*/
DebugLog *DebugLog::new_instance() {
return new DebugLog();
}
/**
* @name setOutputFile
* @brief Set an output file where the log will be saved
*
* @param file_path Path to the log file.
*
* @return If the operation successful or not.
* @retval true Operation was successful.
* @retval false Operation failed.
*
*/
bool DebugLog::setOutputFile(const std::string& file_path) {
if (is_open()) {
close();
}
open(file_path, std::fstream::out | std::fstream::app);
if (!is_open()) {
return false;
}
return true;
}
/**
* @name write_log
* @brief Write a message into the debug log.
*
* @param debug_level Debug level of the given message.
* @param text Message to be written.
*
* @return If the operation successful or not.
* @retval true Operation was successful.
* @retval false Operation failed.
*
*/
bool DebugLog::write_log(int debug_level, const std::string &text) {
if (!is_open()) {
return false;
}
if (debug_level <= m_debug_level) {
*this << "[" << debug_level << "] " << text << std::endl;
}
return true;
}
/**
* @name setDebugLevel
* @brief Changes the default debug level.
*
* @param level Debug level.
*
* @return If the operation successful or not.
* @retval true Operation was successful.
* @retval false Operation failed.
*
*/
bool DebugLog::setDebugLevel(int level) {
if (level < 0 || level > 9) {
return false;
}
m_debug_level = level;
return true;
}
/**
* @name isConfigured
* @brief Returns if debug log is configured or not.
*
* @return If the debug log is configured or not
* @retval true It is configured.
* @retval false It is not configured.
*
*/
bool DebugLog::isConfigured() {
return m_is_configured;
}
} // namespace ModSecurity

68
src/modsecurity.cc Normal file
View File

@@ -0,0 +1,68 @@
/**
* 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 <ctime>
#include <iostream>
#include "modsecurity/modsecurity.h"
#include "src/utils.h"
namespace ModSecurity {
/**
* @name ModSecurity
* @brief Initilizes ModSecurity CPP API
*
* ModSecurity initializer. Although it is not really doing anything
* in this version, further versions of this API may demands this to
* be executed.
*
* Example Usage:
* @code
*
* using ModSecurity::ModSecurity;
*
* ModSecurity *msc = new ModSecurity();
*
* @endcode
*/
ModSecurity::ModSecurity() {
}
/**
* @name msc_init
* @brief Initilizes ModSecurity C API
*
* ModSecurity initializer. Although it is not really doing anything
* in this version, further versions of this API may demands this to
* be executed.
*
* Example Usage:
* @code
*
* ModSecurity msc = msc_init();
*
* @endcode
*/
extern "C" ModSecurity *msc_init() {
ModSecurity *modsec = new ModSecurity();
return modsec;
}
} // namespace ModSecurity

6
src/operators/.directory Normal file
View File

@@ -0,0 +1,6 @@
[Dolphin]
SortRole=type
Timestamp=2015,6,11,13,57,39
Version=3
ViewMode=1
VisibleRoles=Details_text,Details_size,Details_date,Details_type,CustomizedDetails

View File

@@ -0,0 +1,44 @@
/**
* 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 "operators/begins_with.h"
#include <string>
#include "operators/operator.h"
namespace ModSecurity {
namespace operators {
bool BeginsWith::evaluate(Assay *assay) {
/**
* @todo Implement the operator BeginsWith.
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#beginswith
*/
return true;
}
BeginsWith::BeginsWith(std::string op, std::string param,
bool negation)
: Operator() {
this->op = op;
this->param = param;
}
} // namespace operators
} // namespace ModSecurity

View File

@@ -0,0 +1,39 @@
/**
* 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.
*
*/
#ifndef SRC_OPERATORS_BEGINS_WITH_H_
#define SRC_OPERATORS_BEGINS_WITH_H_
#include <string>
#include "operators/operator.h"
#ifdef __cplusplus
namespace ModSecurity {
namespace operators {
class BeginsWith : public Operator {
public:
/** @ingroup ModSecurity_Operator */
BeginsWith(std::string o, std::string p, bool i);
bool evaluate(Assay *assay);
};
} // namespace operators
} // namespace ModSecurity
#endif
#endif // SRC_OPERATORS_BEGINS_WITH_H_

35
src/operators/contains.cc Normal file
View File

@@ -0,0 +1,35 @@
/**
* 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 "operators/contains.h"
#include <string>
namespace ModSecurity {
namespace operators {
bool Contains::evaluate(Assay *assay, const std::string &input) {
return input.find(this->param) != std::string::npos;
}
Contains::Contains(std::string _op, std::string _param,
bool negation)
: Operator() {
this->op = _op;
this->param = _param;
}
} // namespace operators
} // namespace ModSecurity

40
src/operators/contains.h Normal file
View File

@@ -0,0 +1,40 @@
/**
* 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.
*
*/
#ifndef SRC_OPERATORS_CONTAINS_H_
#define SRC_OPERATORS_CONTAINS_H_
#include <string>
#include "modsecurity/assay.h"
#include "operators/operator.h"
#ifdef __cplusplus
namespace ModSecurity {
namespace operators {
class Contains : public Operator {
public:
/** @ingroup ModSecurity_Operator */
Contains(std::string o, std::string p, bool i);
bool evaluate(Assay *assay, const std::string &exp) override;
};
} // namespace operators
} // namespace ModSecurity
#endif
#endif // SRC_OPERATORS_CONTAINS_H_

View File

@@ -0,0 +1,65 @@
/**
* 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 "operators/contains_word.h"
#include <string>
#include <regex>
#include "operators/operator.h"
namespace ModSecurity {
namespace operators {
bool ContainsWord::evaluate(Assay *assay,
std::string input) {
/**
* @todo Implement the operator ContainsWord in a performative way.
*/
// FIXME: This is odd logic and should be removed in a future version
if (this->param == "") {
return 1;
}
// If our length is too long we will never match
if (this->param.length() > input.length()) {
return 0;
}
// If they are exact matches shortcut
if (this->param == input) {
return 1;
}
std::regex r("\\b" + this->param + "\\b");
std::smatch m;
if (std::regex_search(input, m, r)) {
// this won't find anything because 'spoons' is not
// the word you're searching for
return 1;
}
return 0;
}
ContainsWord::ContainsWord(std::string op,
std::string param, bool negation)
: Operator() {
this->op = op;
this->param = param;
}
} // namespace operators
} // namespace ModSecurity

View File

@@ -0,0 +1,40 @@
/**
* 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.
*
*/
#ifndef SRC_OPERATORS_CONTAINS_WORD_H_
#define SRC_OPERATORS_CONTAINS_WORD_H_
#include <string>
#include "operators/operator.h"
#ifdef __cplusplus
namespace ModSecurity {
namespace operators {
class ContainsWord : public Operator {
public:
/** @ingroup ModSecurity_Operator */
ContainsWord(std::string o, std::string p, bool i);
bool evaluate(Assay *assay, std::string exp);
};
} // namespace operators
} // namespace ModSecurity
#endif
#endif // SRC_OPERATORS_CONTAINS_WORD_H_

View File

@@ -0,0 +1,43 @@
/**
* 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 "operators/detect_sqli.h"
#include <string>
#include "operators/operator.h"
namespace ModSecurity {
namespace operators {
bool DetectSQLi::evaluate(Assay *assay) {
/**
* @todo Implement the operator BeginsWith.
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#detectsqli
*/
return true;
}
DetectSQLi::DetectSQLi(std::string op, std::string param,
bool negation)
: Operator() {
this->op = op;
this->param = param;
}
} // namespace operators
} // namespace ModSecurity

View File

@@ -0,0 +1,39 @@
/**
* 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.
*
*/
#ifndef SRC_OPERATORS_DETECT_SQLI_H_
#define SRC_OPERATORS_DETECT_SQLI_H_
#include <string>
#include "operators/operator.h"
#ifdef __cplusplus
namespace ModSecurity {
namespace operators {
class DetectSQLi : public Operator {
public:
/** @ingroup ModSecurity_Operator */
DetectSQLi(std::string o, std::string p, bool i);
bool evaluate(Assay *assay);
};
} // namespace operators
} // namespace ModSecurity
#endif
#endif // SRC_OPERATORS_DETECT_SQLI_H_

View File

@@ -0,0 +1,42 @@
/**
* 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 "operators/detect_xss.h"
#include <string>
#include "operators/operator.h"
namespace ModSecurity {
namespace operators {
bool DetectXSS::evaluate(Assay *assay) {
/**
* @todo Implement the operator DetectXSS.
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#detectxss
*/
return true;
}
DetectXSS::DetectXSS(std::string op, std::string param, bool negation)
: Operator() {
this->op = op;
this->param = param;
}
} // namespace operators
} // namespace ModSecurity

View File

@@ -0,0 +1,39 @@
/**
* 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.
*
*/
#ifndef SRC_OPERATORS_DETECT_XSS_H_
#define SRC_OPERATORS_DETECT_XSS_H_
#include <string>
#include "operators/operator.h"
#ifdef __cplusplus
namespace ModSecurity {
namespace operators {
class DetectXSS : public Operator {
public:
/** @ingroup ModSecurity_Operator */
DetectXSS(std::string o, std::string p, bool i);
bool evaluate(Assay *assay);
};
} // namespace operators
} // namespace ModSecurity
#endif
#endif // SRC_OPERATORS_DETECT_XSS_H_

View 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.
*
*/
#include "operators/ends_with.h"
#include <string>
#include "operators/operator.h"
namespace ModSecurity {
namespace operators {
bool EndsWith::evaluate(Assay *assay,
std::string input) {
// Check that the param is not longer than the input
if (this->param.length() > input.length()) {
return 0;
}
// Check that the input != the param
if (this->param == input) {
return 1;
}
// Start at the end of the input minus the size of the input
std::string endString = input.substr(input.length() - \
(this->param.length()), (this->param.length()));
// FIXME: We can make this smalle
if (endString == this->param) {
return 1;
}
return 0;
}
EndsWith::EndsWith(std::string op, std::string param,
bool negation)
: Operator() {
this->op = op;
this->param = param;
}
} // namespace operators
} // namespace ModSecurity

40
src/operators/ends_with.h Normal file
View File

@@ -0,0 +1,40 @@
/**
* 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.
*
*/
#ifndef SRC_OPERATORS_ENDS_WITH_H_
#define SRC_OPERATORS_ENDS_WITH_H_
#include <string>
#include "operators/operator.h"
#ifdef __cplusplus
namespace ModSecurity {
namespace operators {
class EndsWith : public Operator {
public:
/** @ingroup ModSecurity_Operator */
EndsWith(std::string o, std::string p, bool i);
bool evaluate(Assay *assay, std::string exp);
};
} // namespace operators
} // namespace ModSecurity
#endif
#endif // SRC_OPERATORS_ENDS_WITH_H_

42
src/operators/eq.cc Normal file
View File

@@ -0,0 +1,42 @@
/**
* 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 "operators/eq.h"
#include <string>
#include "operators/operator.h"
namespace ModSecurity {
namespace operators {
bool Eq::evaluate(Assay *assay) {
/**
* @todo Implement the operator Eq.
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#eq
*/
return true;
}
Eq::Eq(std::string op, std::string param,
bool negation)
: Operator() {
this->op = op;
this->param = param;
}
} // namespace operators
} // namespace ModSecurity

39
src/operators/eq.h Normal file
View File

@@ -0,0 +1,39 @@
/**
* 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.
*
*/
#ifndef SRC_OPERATORS_EQ_H_
#define SRC_OPERATORS_EQ_H_
#include <string>
#include "operators/operator.h"
#ifdef __cplusplus
namespace ModSecurity {
namespace operators {
class Eq : public Operator {
public:
/** @ingroup ModSecurity_Operator */
Eq(std::string o, std::string p, bool i);
bool evaluate(Assay *assay);
};
} // namespace operators
} // namespace ModSecurity
#endif
#endif // SRC_OPERATORS_EQ_H_

View File

@@ -0,0 +1,41 @@
/**
* 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 "operators/fuzzy_hash.h"
#include <string>
#include "operators/operator.h"
namespace ModSecurity {
namespace operators {
bool FuzzyHash::evaluate(Assay *assay) {
/**
* @todo Implement the operator FuzzyHash.
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#fuzzyhash
*/
return true;
}
FuzzyHash::FuzzyHash(std::string op, std::string param,
bool negation)
: Operator() {
this->op = op;
this->param = param;
}
} // namespace operators
} // namespace ModSecurity

View File

@@ -0,0 +1,40 @@
/**
* 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.
*
*/
#ifndef SRC_OPERATORS_FUZZY_HASH_H_
#define SRC_OPERATORS_FUZZY_HASH_H_
#include <string>
#include "operators/operator.h"
#ifdef __cplusplus
namespace ModSecurity {
namespace operators {
class FuzzyHash : public Operator {
public:
/** @ingroup ModSecurity_Operator */
FuzzyHash(std::string o, std::string p, bool i);
bool evaluate(Assay *assay);
};
} // namespace operators
} // namespace ModSecurity
#endif
#endif // SRC_OPERATORS_FUZZY_HASH_H_

43
src/operators/ge.cc Normal file
View File

@@ -0,0 +1,43 @@
/**
* 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 "operators/ge.h"
#include <string>
#include "operators/operator.h"
namespace ModSecurity {
namespace operators {
bool Ge::evaluate(Assay *assay) {
/**
* @todo Implement the operator Ge.
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#ge
*/
return true;
}
Ge::Ge(std::string op, std::string param,
bool negation)
: Operator() {
this->op = op;
this->param = param;
}
} // namespace operators
} // namespace ModSecurity

39
src/operators/ge.h Normal file
View File

@@ -0,0 +1,39 @@
/**
* 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.
*
*/
#ifndef SRC_OPERATORS_GE_H_
#define SRC_OPERATORS_GE_H_
#include <string>
#include "operators/operator.h"
#ifdef __cplusplus
namespace ModSecurity {
namespace operators {
class Ge : public Operator {
public:
/** @ingroup ModSecurity_Operator */
Ge(std::string o, std::string p, bool i);
bool evaluate(Assay *assay);
};
} // namespace operators
} // namespace ModSecurity
#endif
#endif // SRC_OPERATORS_GE_H_

View File

@@ -0,0 +1,41 @@
/**
* 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 "operators/geolookup.h"
#include <string>
#include "operators/operator.h"
namespace ModSecurity {
namespace operators {
bool GeoLookup::evaluate(Assay *assay) {
/**
* @todo Implement the operator GeoLookup.
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#geolookup
*/
return true;
}
GeoLookup::GeoLookup(std::string op, std::string param,
bool negation)
: Operator() {
this->op = op;
this->param = param;
}
} // namespace operators
} // namespace ModSecurity

39
src/operators/geolookup.h Normal file
View File

@@ -0,0 +1,39 @@
/**
* 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.
*
*/
#ifndef SRC_OPERATORS_GEOLOOKUP_H_
#define SRC_OPERATORS_GEOLOOKUP_H_
#include <string>
#include "operators/operator.h"
#ifdef __cplusplus
namespace ModSecurity {
namespace operators {
class GeoLookup : public Operator {
public:
/** @ingroup ModSecurity_Operator */
GeoLookup(std::string o, std::string p, bool i);
bool evaluate(Assay *assay);
};
} // namespace operators
} // namespace ModSecurity
#endif
#endif // SRC_OPERATORS_GEOLOOKUP_H_

View File

@@ -0,0 +1,42 @@
/**
* 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 "operators/gsblookup.h"
#include <string>
#include "operators/operator.h"
namespace ModSecurity {
namespace operators {
bool GsbLookup::evaluate(Assay *assay) {
/**
* @todo Implement the operator GeoLookup.
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#gsblookup
*/
return true;
}
GsbLookup::GsbLookup(std::string op, std::string param,
bool negation)
: Operator() {
this->op = op;
this->param = param;
}
} // namespace operators
} // namespace ModSecurity

40
src/operators/gsblookup.h Normal file
View File

@@ -0,0 +1,40 @@
/**
* 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.
*
*/
#ifndef SRC_OPERATORS_GSBLOOKUP_H_
#define SRC_OPERATORS_GSBLOOKUP_H_
#include <string>
#include "operators/operator.h"
#ifdef __cplusplus
namespace ModSecurity {
namespace operators {
class GsbLookup : public Operator {
public:
/** @ingroup ModSecurity_Operator */
GsbLookup(std::string o, std::string p, bool i);
bool evaluate(Assay *assay);
};
} // namespace operators
} // namespace ModSecurity
#endif
#endif // SRC_OPERATORS_GSBLOOKUP_H_

42
src/operators/gt.cc Normal file
View File

@@ -0,0 +1,42 @@
/**
* 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 "operators/gt.h"
#include <string>
#include "operators/operator.h"
namespace ModSecurity {
namespace operators {
bool Gt::evaluate(Assay *assay) {
/**
* @todo Implement the operator Gt.
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#gt
*/
return true;
}
Gt::Gt(std::string op, std::string param,
bool negation)
: Operator() {
this->op = op;
this->param = param;
}
} // namespace operators
} // namespace ModSecurity

38
src/operators/gt.h Normal file
View File

@@ -0,0 +1,38 @@
/**
* 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.
*
*/
#ifndef SRC_OPERATORS_GT_H_
#define SRC_OPERATORS_GT_H_
#include <string>
#include "operators/operator.h"
#ifdef __cplusplus
namespace ModSecurity {
namespace operators {
class Gt : public Operator {
public:
/** @ingroup ModSecurity_Operator */
Gt(std::string o, std::string p, bool i);
bool evaluate(Assay *assay);
};
} // namespace operators
} // namespace ModSecurity
#endif
#endif // SRC_OPERATORS_GT_H_

View File

@@ -0,0 +1,42 @@
/**
* 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 "operators/inspect_file.h"
#include <string>
#include "operators/operator.h"
namespace ModSecurity {
namespace operators {
bool InspectFile::evaluate(Assay *assay) {
/**
* @todo Implement the operator InspectFile.
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#inspectfile
*/
return true;
}
InspectFile::InspectFile(std::string op, std::string param,
bool negation)
: Operator() {
this->op = op;
this->param = param;
}
} // namespace operators
} // namespace ModSecurity

View File

@@ -0,0 +1,39 @@
/**
* 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.
*
*/
#ifndef SRC_OPERATORS_INSPECT_FILE_H_
#define SRC_OPERATORS_INSPECT_FILE_H_
#include <string>
#include "operators/operator.h"
#ifdef __cplusplus
namespace ModSecurity {
namespace operators {
class InspectFile : public Operator {
public:
/** @ingroup ModSecurity_Operator */
InspectFile(std::string o, std::string p, bool i);
bool evaluate(Assay *assay);
};
} // namespace operators
} // namespace ModSecurity
#endif
#endif // SRC_OPERATORS_INSPECT_FILE_H_

43
src/operators/ip_match.cc Normal file
View File

@@ -0,0 +1,43 @@
/**
* 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 "operators/ip_match.h"
#include <string>
#include "operators/operator.h"
namespace ModSecurity {
namespace operators {
bool IpMatch::evaluate(Assay *assay) {
/**
* @todo Implement the operator IpMatch.
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#ipmatch
*/
return true;
}
IpMatch::IpMatch(std::string op, std::string param,
bool negation)
: Operator() {
this->op = op;
this->param = param;
}
} // namespace operators
} // namespace ModSecurity

39
src/operators/ip_match.h Normal file
View File

@@ -0,0 +1,39 @@
/**
* 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.
*
*/
#ifndef SRC_OPERATORS_IP_MATCH_H_
#define SRC_OPERATORS_IP_MATCH_H_
#include <string>
#include "operators/operator.h"
#ifdef __cplusplus
namespace ModSecurity {
namespace operators {
class IpMatch : public Operator {
public:
/** @ingroup ModSecurity_Operator */
IpMatch(std::string o, std::string p, bool i);
bool evaluate(Assay *assay);
};
} // namespace operators
} // namespace ModSecurity
#endif
#endif // SRC_OPERATORS_IP_MATCH_H_

View File

@@ -0,0 +1,42 @@
/**
* 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 "operators/ip_match_f.h"
#include <string>
#include "operators/operator.h"
namespace ModSecurity {
namespace operators {
bool IpMatchF::evaluate(Assay *assay) {
/**
* @todo Implement the operator IpMatchF.
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#ipmatchf
*/
return true;
}
IpMatchF::IpMatchF(std::string op, std::string param,
bool negation)
: Operator() {
this->op = op;
this->param = param;
}
} // namespace operators
} // namespace ModSecurity

View File

@@ -0,0 +1,39 @@
/**
* 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.
*
*/
#ifndef SRC_OPERATORS_IP_MATCH_F_H_
#define SRC_OPERATORS_IP_MATCH_F_H_
#include <string>
#include "operators/operator.h"
#ifdef __cplusplus
namespace ModSecurity {
namespace operators {
class IpMatchF : public Operator {
public:
/** @ingroup ModSecurity_Operator */
IpMatchF(std::string p, std::string o, bool i);
bool evaluate(Assay *assay);
};
} // namespace operators
} // namespace ModSecurity
#endif
#endif // SRC_OPERATORS_IP_MATCH_F_H_

View File

@@ -0,0 +1,42 @@
/**
* 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 "operators/ip_match_from_file.h"
#include <string>
#include "operators/operator.h"
namespace ModSecurity {
namespace operators {
bool IpMatchFromFile::evaluate(Assay *assay) {
/**
* @todo Implement the operator IpMatchFromFile.
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#ipmatchfromfile
*/
return true;
}
IpMatchFromFile::IpMatchFromFile(std::string op, std::string param,
bool negation)
: Operator() {
this->op = op;
this->param = param;
}
} // namespace operators
} // namespace ModSecurity

View File

@@ -0,0 +1,38 @@
/**
* 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.
*
*/
#ifndef SRC_OPERATORS_IP_MATCH_FROM_FILE_H_
#define SRC_OPERATORS_IP_MATCH_FROM_FILE_H_
#include <string>
#include "operators/operator.h"
#ifdef __cplusplus
namespace ModSecurity {
namespace operators {
class IpMatchFromFile : public Operator {
public:
/** @ingroup ModSecurity_Operator */
IpMatchFromFile(std::string o, std::string p, bool i);
bool evaluate(Assay *assay);
};
} // namespace operators
} // namespace ModSecurity
#endif
#endif // SRC_OPERATORS_IP_MATCH_FROM_FILE_H_

41
src/operators/le.cc Normal file
View File

@@ -0,0 +1,41 @@
/**
* 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 "operators/le.h"
#include <string>
#include "operators/operator.h"
namespace ModSecurity {
namespace operators {
bool Le::evaluate(Assay *assay) {
/**
* @todo Implement the operator Le.
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#le
*/
return true;
}
Le::Le(std::string op, std::string param, bool negation)
: Operator() {
this->op = op;
this->param = param;
}
} // namespace operators
} // namespace ModSecurity

41
src/operators/le.h Normal file
View File

@@ -0,0 +1,41 @@
/**
* 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.
*
*/
#ifndef SRC_OPERATORS_LE_H_
#define SRC_OPERATORS_LE_H_
#include <string>
#include "operators/operator.h"
#ifdef __cplusplus
namespace ModSecurity {
namespace operators {
class Le : public Operator {
public:
/** @ingroup ModSecurity_Operator */
Le(std::string o, std::string p, bool i);
bool evaluate(Assay *assay);
};
} // namespace operators
} // namespace ModSecurity
#endif
#endif // SRC_OPERATORS_LE_H_

41
src/operators/lt.cc Normal file
View File

@@ -0,0 +1,41 @@
/**
* 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 "operators/lt.h"
#include <string>
#include "operators/operator.h"
namespace ModSecurity {
namespace operators {
bool Lt::evaluate(Assay *assay) {
/**
* @todo Implement the operator Lt.
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#lt
*/
return true;
}
Lt::Lt(std::string op, std::string param, bool negation)
: Operator() {
this->op = op;
this->param = param;
}
} // namespace operators
} // namespace ModSecurity

40
src/operators/lt.h Normal file
View File

@@ -0,0 +1,40 @@
/**
* 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.
*
*/
#ifndef SRC_OPERATORS_LT_H_
#define SRC_OPERATORS_LT_H_
#include <string>
#include "operators/operator.h"
#ifdef __cplusplus
namespace ModSecurity {
namespace operators {
class Lt : public Operator {
public:
/** @ingroup ModSecurity_Operator */
Lt(std::string o, std::string p, bool i);
bool evaluate(Assay *assay);
};
} // namespace operators
} // namespace ModSecurity
#endif
#endif // SRC_OPERATORS_LT_H_

177
src/operators/operator.cc Normal file
View File

@@ -0,0 +1,177 @@
/**
* 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 "operators/operator.h"
#include <cstring>
#include <string>
#include "modsecurity/assay.h"
#include "operators/detect_sqli.h"
#include "operators/detect_xss.h"
#include "operators/inspect_file.h"
#include "operators/fuzzy_hash.h"
#include "operators/validate_byte_range.h"
#include "operators/validate_dtd.h"
#include "operators/validate_hash.h"
#include "operators/validate_schema.h"
#include "operators/validate_url_encoding.h"
#include "operators/validate_utf8_encoding.h"
#include "operators/verify_cc.h"
#include "operators/verify_cpf.h"
#include "operators/verify_ssn.h"
#include "operators/geolookup.h"
#include "operators/gsblookup.h"
#include "operators/rsub.h"
#include "operators/within.h"
#include "operators/contains_word.h"
#include "operators/contains.h"
#include "operators/ends_with.h"
#include "operators/eq.h"
#include "operators/ge.h"
#include "operators/gt.h"
#include "operators/ip_match_f.h"
#include "operators/ip_match.h"
#include "operators/ip_match_from_file.h"
#include "operators/le.h"
#include "operators/lt.h"
#include "operators/pm_f.h"
#include "operators/pm.h"
#include "operators/pm_from_file.h"
#include "operators/rbl.h"
#include "operators/rx.h"
#include "operators/str_eq.h"
#include "operators/str_match.h"
#include "operators/begins_with.h"
#define IF_MATCH(a) \
if (op.compare(1, std::strlen(#a), #a) == 0)
namespace ModSecurity {
namespace operators {
Operator::Operator() {
}
Operator::Operator(std::string op, std::string param, bool negation) {
this->op = op;
this->param = param;
}
bool Operator::evaluate(Assay *assay) {
if (assay) {
assay->debug(2, "Operator: " + this->op + \
" is not implemented or malfunctioning.");
}
return true;
}
bool Operator::evaluate(Assay *assay, const std::string& a) {
if (assay) {
assay->debug(2, "Operator: " + this->op + \
" is not implemented or malfunctioning.");
}
return true;
}
Operator *Operator::instantiate(std::string op_string) {
// Sanity check.
if (op_string.size() <= 2) {
return NULL;
}
std::string op = op_string;
op = op.substr(1, op_string.size() - 2);
// We assume no negation by default
bool negation = false;
// If there is a '!' in front substring and assign negation
if (op.at(0) == '!') {
op = op.substr(1, op.size() - 1);
negation = true;
}
// Check to see if there is a parameter, if not param is an empty string
std::string param = "";
if (op.find(" ") != std::string::npos) {
param = op;
param.erase(0, op_string.find(" "));
op.erase(op_string.find(" "),
op_string.length() - op_string.find(" "));
}
for (std::basic_string<char>::iterator p = op.begin();
p != op.end(); ++p) {
*p = tolower(*p);
}
IF_MATCH(beginswith) { return new BeginsWith(op, param, negation); }
IF_MATCH(contains) { return new Contains(op, param, negation); }
IF_MATCH(containsword) { return new ContainsWord(op, param, negation); }
IF_MATCH(detectsqli) { return new DetectSQLi(op, param, negation); }
IF_MATCH(detectxss) { return new DetectXSS(op, param, negation); }
IF_MATCH(endswith) { return new EndsWith(op, param, negation); }
IF_MATCH(eq) { return new Eq(op, param, negation); }
IF_MATCH(fuzzyhash) { return new FuzzyHash(op, param, negation); }
IF_MATCH(geolookup) { return new GeoLookup(op, param, negation); }
IF_MATCH(ge) { return new Ge(op, param, negation); }
IF_MATCH(gsblookup) { return new GsbLookup(op, param, negation); }
IF_MATCH(gt) { return new Gt(op, param, negation); }
IF_MATCH(inspectfile) { return new InspectFile(op, param, negation); }
IF_MATCH(ipmatchf) { return new IpMatchF(op, param, negation); }
IF_MATCH(ipmatchfromfile) {
return new IpMatchFromFile(op, param, negation);
}
IF_MATCH(ipmatch) { return new IpMatch(op, param, negation); }
IF_MATCH(le) { return new Le(op, param, negation); }
IF_MATCH(lt) { return new Lt(op, param, negation); }
IF_MATCH(pmf) { return new PmF(op, param, negation); }
IF_MATCH(pmfromfile) { return new PmFromFile(op, param, negation); }
IF_MATCH(pm) { return new Pm(op, param, negation); }
IF_MATCH(rbl) { return new Rbl(op, param, negation); }
IF_MATCH(rsub) { return new Rsub(op, param, negation); }
IF_MATCH(rx) { return new Rx(op, param, negation); }
IF_MATCH(streq) { return new StrEq(op, param, negation); }
IF_MATCH(strmatch) { return new StrMatch(op, param, negation); }
IF_MATCH(validatebyterange) {
return new ValidateByteRange(op, param, negation);
}
IF_MATCH(validatedtd) { return new ValidateDTD(op, param, negation); }
IF_MATCH(validatehash) { return new ValidateHash(op, param, negation); }
IF_MATCH(validateschema) { return new ValidateSchema(op, param, negation); }
IF_MATCH(validateurlencoding) {
return new ValidateUrlEncoding(op, param, negation);
}
IF_MATCH(validateutf8encoding) {
return new ValidateUtf8Encoding(op, param, negation);
}
IF_MATCH(verifycc) { return new VerifyCC(op, param, negation); }
IF_MATCH(verifycpf) { return new VerifyCPF(op, param, negation); }
IF_MATCH(verifyssn) { return new VerifySSN(op, param, negation); }
IF_MATCH(within) { return new Within(op, param, negation); }
return new Operator(op, param, negation);
}
} // namespace operators
} // namespace ModSecurity

49
src/operators/operator.h Normal file
View File

@@ -0,0 +1,49 @@
/**
* 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>
#endif
#ifndef SRC_OPERATORS_OPERATOR_H__
#define SRC_OPERATORS_OPERATOR_H__
#include "modsecurity/assay.h"
#ifdef __cplusplus
namespace ModSecurity {
namespace operators {
class Operator {
public:
/** @ingroup ModSecurity_Operator */
Operator();
Operator(std::string po, std::string param, bool invert);
std::string op;
std::string param;
virtual bool evaluate(Assay *assay);
virtual bool evaluate(Assay *assay, const std::string &str);
static Operator *instantiate(std::string op);
protected:
};
} // namespace operators
} // namespace ModSecurity
#endif
#endif // SRC_OPERATORS_OPERATOR_H__

41
src/operators/pm.cc Normal file
View File

@@ -0,0 +1,41 @@
/**
* 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 "operators/pm.h"
#include <string>
#include "operators/operator.h"
namespace ModSecurity {
namespace operators {
bool Pm::evaluate(Assay *assay) {
/**
* @todo Implement the operator Pm.
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#pm
*/
return true;
}
Pm::Pm(std::string op, std::string param, bool negation)
: Operator() {
this->op = op;
this->param = param;
}
} // namespace operators
} // namespace ModSecurity

39
src/operators/pm.h Normal file
View File

@@ -0,0 +1,39 @@
/**
* 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.
*
*/
#ifndef SRC_OPERATORS_PM_H_
#define SRC_OPERATORS_PM_H_
#include <string>
#include "operators/operator.h"
#ifdef __cplusplus
namespace ModSecurity {
namespace operators {
class Pm : public Operator {
public:
/** @ingroup ModSecurity_Operator */
Pm(std::string o, std::string p, bool i);
bool evaluate(Assay *assay);
};
} // namespace operators
} // namespace ModSecurity
#endif
#endif // SRC_OPERATORS_PM_H_

41
src/operators/pm_f.cc Normal file
View File

@@ -0,0 +1,41 @@
/**
* 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 "operators/pm_f.h"
#include <string>
#include "operators/operator.h"
namespace ModSecurity {
namespace operators {
bool PmF::evaluate(Assay *assay) {
/**
* @todo Implement the operator PmF.
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#pmf
*/
return true;
}
PmF::PmF(std::string op, std::string param, bool negation)
: Operator() {
this->op = op;
this->param = param;
}
} // namespace operators
} // namespace ModSecurity

39
src/operators/pm_f.h Normal file
View File

@@ -0,0 +1,39 @@
/**
* 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.
*
*/
#ifndef SRC_OPERATORS_PM_F_H_
#define SRC_OPERATORS_PM_F_H_
#include <string>
#include "operators/operator.h"
#ifdef __cplusplus
namespace ModSecurity {
namespace operators {
class PmF : public Operator {
public:
/** @ingroup ModSecurity_Operator */
PmF(std::string o, std::string p, bool i);
bool evaluate(Assay *assay);
};
} // namespace operators
} // namespace ModSecurity
#endif
#endif // SRC_OPERATORS_PM_F_H_

View File

@@ -0,0 +1,41 @@
/**
* 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 "operators/pm_from_file.h"
#include <string>
#include "operators/operator.h"
namespace ModSecurity {
namespace operators {
bool PmFromFile::evaluate(Assay *assay) {
/**
* @todo Implement the operator PmFromFile.
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#pmfromfile
*/
return true;
}
PmFromFile::PmFromFile(std::string op, std::string param, bool negation)
: Operator() {
this->op = op;
this->param = param;
}
} // namespace operators
} // namespace ModSecurity

View File

@@ -0,0 +1,40 @@
/**
* 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.
*
*/
#ifndef SRC_OPERATORS_PM_FROM_FILE_H_
#define SRC_OPERATORS_PM_FROM_FILE_H_
#include <string>
#include "operators/operator.h"
#ifdef __cplusplus
namespace ModSecurity {
namespace operators {
class PmFromFile : public Operator {
public:
/** @ingroup ModSecurity_Operator */
PmFromFile(std::string o, std::string p, bool i);
bool evaluate(Assay *assay);
};
} // namespace operators
} // namespace ModSecurity
#endif
#endif // SRC_OPERATORS_PM_FROM_FILE_H_

41
src/operators/rbl.cc Normal file
View File

@@ -0,0 +1,41 @@
/**
* 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 "operators/rbl.h"
#include <string>
#include "operators/operator.h"
namespace ModSecurity {
namespace operators {
bool Rbl::evaluate(Assay *assay) {
/**
* @todo Implement the operator Rbl.
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#rbl
*/
return true;
}
Rbl::Rbl(std::string op, std::string param, bool negation)
: Operator() {
this->op = op;
this->param = param;
}
} // namespace operators
} // namespace ModSecurity

40
src/operators/rbl.h Normal file
View File

@@ -0,0 +1,40 @@
/**
* 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.
*
*/
#ifndef SRC_OPERATORS_RBL_H_
#define SRC_OPERATORS_RBL_H_
#include <string>
#include "operators/operator.h"
#ifdef __cplusplus
namespace ModSecurity {
namespace operators {
class Rbl : public Operator {
public:
/** @ingroup ModSecurity_Operator */
Rbl(std::string o, std::string p, bool i);
bool evaluate(Assay *assay);
};
} // namespace operators
} // namespace ModSecurity
#endif
#endif // SRC_OPERATORS_RBL_H_

41
src/operators/rsub.cc Normal file
View File

@@ -0,0 +1,41 @@
/**
* 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 "operators/rsub.h"
#include <string>
#include "operators/operator.h"
namespace ModSecurity {
namespace operators {
bool Rsub::evaluate(Assay *assay) {
/**
* @todo Implement the operator Rsub.
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#rsub
*/
return true;
}
Rsub::Rsub(std::string op, std::string param, bool negation)
: Operator() {
this->op = op;
this->param = param;
}
} // namespace operators
} // namespace ModSecurity

38
src/operators/rsub.h Normal file
View File

@@ -0,0 +1,38 @@
/**
* 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.
*
*/
#ifndef SRC_OPERATORS_RSUB_H_
#define SRC_OPERATORS_RSUB_H_
#include <string>
#include "operators/operator.h"
#ifdef __cplusplus
namespace ModSecurity {
namespace operators {
class Rsub : public Operator {
public:
/** @ingroup ModSecurity_Operator */
Rsub(std::string o, std::string p, bool i);
bool evaluate(Assay *assay);
};
} // namespace operators
} // namespace ModSecurity
#endif
#endif // SRC_OPERATORS_RSUB_H_

41
src/operators/rx.cc Normal file
View File

@@ -0,0 +1,41 @@
/**
* 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 "operators/rx.h"
#include <string>
#include "operators/operator.h"
namespace ModSecurity {
namespace operators {
bool Rx::evaluate(Assay *assay) {
/**
* @todo Implement the operator Rx.
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#rx
*/
return true;
}
Rx::Rx(std::string op, std::string param, bool negation)
: Operator() {
this->op = op;
this->param = param;
}
} // namespace operators
} // namespace ModSecurity

39
src/operators/rx.h Normal file
View File

@@ -0,0 +1,39 @@
/**
* 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.
*
*/
#ifndef SRC_OPERATORS_RX_H_
#define SRC_OPERATORS_RX_H_
#include <string>
#include "operators/operator.h"
#ifdef __cplusplus
namespace ModSecurity {
namespace operators {
class Rx : public Operator {
public:
/** @ingroup ModSecurity_Operator */
Rx(std::string o, std::string p, bool i);
bool evaluate(Assay *assay);
};
} // namespace operators
} // namespace ModSecurity
#endif
#endif // SRC_OPERATORS_RX_H_

39
src/operators/str_eq.cc Normal file
View File

@@ -0,0 +1,39 @@
/**
* 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 "operators/str_eq.h"
#include <string>
namespace ModSecurity {
namespace operators {
bool StrEq::evaluate(Assay *assay, const std::string &str) {
/**
* @todo Implement the operator StrEq.
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#streq
*/
return !this->param.compare(str);
}
StrEq::StrEq(std::string op, std::string param, bool negation)
: Operator() {
this->op = op;
this->param = param;
}
} // namespace operators
} // namespace ModSecurity

43
src/operators/str_eq.h Normal file
View File

@@ -0,0 +1,43 @@
/**
* 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 <string>
#include "modsecurity/assay.h"
#include "operators/operator.h"
#ifndef SRC_OPERATORS_STR_EQ_H_
#define SRC_OPERATORS_STR_EQ_H_
#ifdef __cplusplus
namespace ModSecurity {
namespace operators {
class StrEq : public Operator {
public:
/** @ingroup ModSecurity_Operator */
StrEq(std::string o, std::string p, bool i);
bool evaluate(Assay *assay, const std::string &str) override;
};
} // namespace operators
} // namespace ModSecurity
#endif
#endif // SRC_OPERATORS_STR_EQ_H_

View File

@@ -0,0 +1,41 @@
/**
* 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 "operators/str_match.h"
#include <string>
#include "operators/operator.h"
namespace ModSecurity {
namespace operators {
bool StrMatch::evaluate(Assay *assay) {
/**
* @todo Implement the operator StrMatch.
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#strmatch
*/
return true;
}
StrMatch::StrMatch(std::string op, std::string param, bool negation)
: Operator() {
this->op = op;
this->param = param;
}
} // namespace operators
} // namespace ModSecurity

39
src/operators/str_match.h Normal file
View File

@@ -0,0 +1,39 @@
/**
* 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.
*
*/
#ifndef SRC_OPERATORS_STR_MATCH_H_
#define SRC_OPERATORS_STR_MATCH_H_
#include <string>
#include "operators/operator.h"
#ifdef __cplusplus
namespace ModSecurity {
namespace operators {
class StrMatch : public Operator {
public:
/** @ingroup ModSecurity_Operator */
StrMatch(std::string o, std::string p, bool i);
bool evaluate(Assay *assay);
};
} // namespace operators
} // namespace ModSecurity
#endif
#endif // SRC_OPERATORS_STR_MATCH_H_

View File

@@ -0,0 +1,42 @@
/**
* 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 "operators/validate_byte_range.h"
#include <string>
#include "operators/operator.h"
namespace ModSecurity {
namespace operators {
bool ValidateByteRange::evaluate(Assay *assay) {
/**
* @todo Implement the operator ValidateByteRange.
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#validateByteRange
*/
return true;
}
ValidateByteRange::ValidateByteRange(std::string op, std::string param,
bool negation)
: Operator() {
this->op = op;
this->param = param;
}
} // namespace operators
} // namespace ModSecurity

View File

@@ -0,0 +1,40 @@
/**
* 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.
*
*/
#ifndef SRC_OPERATORS_VALIDATE_BYTE_RANGE_H_
#define SRC_OPERATORS_VALIDATE_BYTE_RANGE_H_
#include <string>
#include "operators/operator.h"
#ifdef __cplusplus
namespace ModSecurity {
namespace operators {
class ValidateByteRange : public Operator {
public:
/** @ingroup ModSecurity_Operator */
ValidateByteRange(std::string o, std::string p, bool i);
bool evaluate(Assay *assay);
};
} // namespace operators
} // namespace ModSecurity
#endif
#endif // SRC_OPERATORS_VALIDATE_BYTE_RANGE_H_

View File

@@ -0,0 +1,41 @@
/**
* 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 "operators/validate_dtd.h"
#include <string>
#include "operators/operator.h"
namespace ModSecurity {
namespace operators {
bool ValidateDTD::evaluate(Assay *assay) {
/**
* @todo Implement the operator ValidateDTD.
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#validateDTD
*/
return true;
}
ValidateDTD::ValidateDTD(std::string op, std::string param, bool negation)
: Operator() {
this->op = op;
this->param = param;
}
} // namespace operators
} // namespace ModSecurity

View File

@@ -0,0 +1,39 @@
/**
* 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.
*
*/
#ifndef SRC_OPERATORS_VALIDATE_DTD_H_
#define SRC_OPERATORS_VALIDATE_DTD_H_
#include <string>
#include "operators/operator.h"
#ifdef __cplusplus
namespace ModSecurity {
namespace operators {
class ValidateDTD : public Operator {
public:
/** @ingroup ModSecurity_Operator */
ValidateDTD(std::string o, std::string p, bool i);
bool evaluate(Assay *assay);
};
} // namespace operators
} // namespace ModSecurity
#endif
#endif // SRC_OPERATORS_VALIDATE_DTD_H_

View File

@@ -0,0 +1,41 @@
/**
* 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 "operators/validate_hash.h"
#include <string>
#include "operators/operator.h"
namespace ModSecurity {
namespace operators {
bool ValidateHash::evaluate(Assay *assay) {
/**
* @todo Implement the operator ValidateHash.
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#validateHash
*/
return true;
}
ValidateHash::ValidateHash(std::string op, std::string param, bool negation)
: Operator() {
this->op = op;
this->param = param;
}
} // namespace operators
} // namespace ModSecurity

View File

@@ -0,0 +1,39 @@
/**
* 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.
*
*/
#ifndef SRC_OPERATORS_VALIDATE_HASH_H_
#define SRC_OPERATORS_VALIDATE_HASH_H_
#include <string>
#include "operators/operator.h"
#ifdef __cplusplus
namespace ModSecurity {
namespace operators {
class ValidateHash : public Operator {
public:
/** @ingroup ModSecurity_Operator */
ValidateHash(std::string o, std::string p, bool i);
bool evaluate(Assay *assay);
};
} // namespace operators
} // namespace ModSecurity
#endif
#endif // SRC_OPERATORS_VALIDATE_HASH_H_

View File

@@ -0,0 +1,41 @@
/**
* 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 "operators/validate_schema.h"
#include <string>
#include "operators/operator.h"
namespace ModSecurity {
namespace operators {
bool ValidateSchema::evaluate(Assay *assay) {
/**
* @todo Implement the operator ValidateSchema.
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#validateSchema
*/
return true;
}
ValidateSchema::ValidateSchema(std::string op, std::string param, bool negation)
: Operator() {
this->op = op;
this->param = param;
}
} // namespace operators
} // namespace ModSecurity

View File

@@ -0,0 +1,39 @@
/**
* 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.
*
*/
#ifndef SRC_OPERATORS_VALIDATE_SCHEMA_H_
#define SRC_OPERATORS_VALIDATE_SCHEMA_H_
#include <string>
#include "operators/operator.h"
#ifdef __cplusplus
namespace ModSecurity {
namespace operators {
class ValidateSchema : public Operator {
public:
/** @ingroup ModSecurity_Operator */
ValidateSchema(std::string o, std::string p, bool i);
bool evaluate(Assay *assay);
};
} // namespace operators
} // namespace ModSecurity
#endif
#endif // SRC_OPERATORS_VALIDATE_SCHEMA_H_

View File

@@ -0,0 +1,42 @@
/**
* 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 "operators/validate_url_encoding.h"
#include <string>
#include "operators/operator.h"
namespace ModSecurity {
namespace operators {
bool ValidateUrlEncoding::evaluate(Assay *assay) {
/**
* @todo Implement the operator ValidateUrlEncoding.
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#validateUrlEncoding
*/
return true;
}
ValidateUrlEncoding::ValidateUrlEncoding(std::string op, std::string param,
bool negation)
: Operator() {
this->op = op;
this->param = param;
}
} // namespace operators
} // namespace ModSecurity

View File

@@ -0,0 +1,39 @@
/**
* 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.
*
*/
#ifndef SRC_OPERATORS_VALIDATE_URL_ENCODING_H_
#define SRC_OPERATORS_VALIDATE_URL_ENCODING_H_
#include <string>
#include "operators/operator.h"
#ifdef __cplusplus
namespace ModSecurity {
namespace operators {
class ValidateUrlEncoding : public Operator {
public:
/** @ingroup ModSecurity_Operator */
ValidateUrlEncoding(std::string o, std::string p, bool i);
bool evaluate(Assay *assay);
};
} // namespace operators
} // namespace ModSecurity
#endif
#endif // SRC_OPERATORS_VALIDATE_URL_ENCODING_H_

View File

@@ -0,0 +1,42 @@
/**
* 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 "operators/validate_utf8_encoding.h"
#include <string>
#include "operators/operator.h"
namespace ModSecurity {
namespace operators {
bool ValidateUtf8Encoding::evaluate(Assay *assay) {
/**
* @todo Implement the operator ValidateUtf8Encoding.
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#validateUtf8Encoding
*/
return true;
}
ValidateUtf8Encoding::ValidateUtf8Encoding(std::string op, std::string param,
bool negation)
: Operator() {
this->op = op;
this->param = param;
}
} // namespace operators
} // namespace ModSecurity

View File

@@ -0,0 +1,41 @@
/**
* 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.
*
*/
#ifndef SRC_OPERATORS_VALIDATE_UTF8_ENCODING_H_
#define SRC_OPERATORS_VALIDATE_UTF8_ENCODING_H_
#include <string>
#include "operators/operator.h"
#ifdef __cplusplus
namespace ModSecurity {
namespace operators {
class ValidateUtf8Encoding : public Operator {
public:
/** @ingroup ModSecurity_Operator */
ValidateUtf8Encoding(std::string o, std::string p, bool i);
bool evaluate(Assay *assay);
};
} // namespace operators
} // namespace ModSecurity
#endif
#endif // SRC_OPERATORS_VALIDATE_UTF8_ENCODING_H_

View File

@@ -0,0 +1,41 @@
/**
* 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 "operators/verify_cc.h"
#include <iostream>
#include "operators/operator.h"
namespace ModSecurity {
namespace operators {
bool VerifyCC::evaluate(Assay *assay) {
/**
* @todo Implement the operator VerifyCC.
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#verifyCC
*/
return true;
}
VerifyCC::VerifyCC(std::string op, std::string param, bool negation)
: Operator() {
this->op = op;
this->param = param;
}
} // namespace operators
} // namespace ModSecurity

40
src/operators/verify_cc.h Normal file
View File

@@ -0,0 +1,40 @@
/**
* 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.
*
*/
#ifndef SRC_OPERATORS_VERIFY_CC_H_
#define SRC_OPERATORS_VERIFY_CC_H_
#include <string>
#include "operators/operator.h"
#ifdef __cplusplus
namespace ModSecurity {
namespace operators {
class VerifyCC : public Operator {
public:
/** @ingroup ModSecurity_Operator */
VerifyCC(std::string o, std::string p, bool i);
bool evaluate(Assay *assay);
};
} // namespace operators
} // namespace ModSecurity
#endif
#endif // SRC_OPERATORS_VERIFY_CC_H_

View File

@@ -0,0 +1,41 @@
/**
* 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 "operators/verify_cpf.h"
#include <string>
#include "operators/operator.h"
namespace ModSecurity {
namespace operators {
bool VerifyCPF::evaluate(Assay *assay) {
/**
* @todo Implement the operator VerifyCPF.
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#verifyCPF
*/
return true;
}
VerifyCPF::VerifyCPF(std::string op, std::string param, bool negation)
: Operator() {
this->op = op;
this->param = param;
}
} // namespace operators
} // namespace ModSecurity

View File

@@ -0,0 +1,40 @@
/**
* 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.
*
*/
#ifndef SRC_OPERATORS_VERIFY_CPF_H_
#define SRC_OPERATORS_VERIFY_CPF_H_
#include <string>
#include "operators/operator.h"
#ifdef __cplusplus
namespace ModSecurity {
namespace operators {
class VerifyCPF : public Operator {
public:
/** @ingroup ModSecurity_Operator */
VerifyCPF(std::string o, std::string p, bool i);
bool evaluate(Assay *assay);
};
} // namespace operators
} // namespace ModSecurity
#endif
#endif // SRC_OPERATORS_VERIFY_CPF_H_

View File

@@ -0,0 +1,40 @@
/**
* 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 "operators/verify_ssn.h"
#include <string>
#include "operators/operator.h"
namespace ModSecurity {
namespace operators {
bool VerifySSN::evaluate(Assay *assay) {
/**
* @todo Implement the operator VerifySSN.
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#verifySSN
*/
return true;
}
VerifySSN::VerifySSN(std::string op, std::string param, bool negation)
: Operator() {
this->op = op;
this->param = param;
}
} // namespace operators
} // namespace ModSecurity

View File

@@ -0,0 +1,40 @@
/**
* 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.
*
*/
#ifndef SRC_OPERATORS_VERIFY_SSN_H_
#define SRC_OPERATORS_VERIFY_SSN_H_
#include <string>
#include "operators/operator.h"
#ifdef __cplusplus
namespace ModSecurity {
namespace operators {
class VerifySSN : public Operator {
public:
/** @ingroup ModSecurity_Operator */
VerifySSN(std::string o, std::string p, bool i);
bool evaluate(Assay *assay);
};
} // namespace operators
} // namespace ModSecurity
#endif
#endif // SRC_OPERATORS_VERIFY_SSN_H_

41
src/operators/within.cc Normal file
View File

@@ -0,0 +1,41 @@
/**
* 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 "operators/within.h"
#include <string>
#include "operators/operator.h"
namespace ModSecurity {
namespace operators {
bool Within::evaluate(Assay *assay) {
/**
* @todo Implement the operator Within.
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#within
*/
return true;
}
Within::Within(std::string op, std::string param, bool negation)
: Operator() {
this->op = op;
this->param = param;
}
} // namespace operators
} // namespace ModSecurity

39
src/operators/within.h Normal file
View File

@@ -0,0 +1,39 @@
/**
* 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.
*
*/
#ifndef SRC_OPERATORS_WITHIN_H_
#define SRC_OPERATORS_WITHIN_H_
#include <string>
#include "operators/operator.h"
#ifdef __cplusplus
namespace ModSecurity {
namespace operators {
class Within : public Operator {
public:
/** @ingroup ModSecurity_Operator */
Within(std::string o, std::string p, bool i);
bool evaluate(Assay *assay);
};
} // namespace operators
} // namespace ModSecurity
#endif
#endif // SRC_OPERATORS_WITHIN_H_

75
src/parser/driver.cc Normal file
View File

@@ -0,0 +1,75 @@
/**
* 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 "parser/driver.h"
#include "parser/seclang-parser.hh"
Driver::Driver()
: trace_scanning(false), trace_parsing(false) {
}
Driver::~Driver() {
}
int Driver::addSecRule(ModSecurity::Rule *rule) {
if (rule->phase >= ModSecurity::ModSecurity::Phases::NUMBER_OF_PHASES) {
/** TODO: return an error message */
return -1;
}
this->rules[rule->phase].push_back(rule);
return 1;
}
int Driver::parse(const std::string &f) {
file = f;
scan_begin();
yy::seclang_parser parser(*this);
parser.set_debug_level(trace_parsing);
// yy_scan_buffer
int res = parser.parse();
scan_end();
return res;
}
int Driver::parseFile(const std::string &f) {
file = f;
scan_begin();
yy::seclang_parser parser(*this);
parser.set_debug_level(trace_parsing);
int res = parser.parse();
//std::cout << "Leaving the parser: " << res << std::endl;
scan_end();
return res;
}
void Driver::error(const yy::location& l, const std::string& m) {
std::cerr << l << ": " << m << std::endl;
}
void Driver::error(const std::string& m) {
std::cerr << m << std::endl;
}

94
src/parser/driver.h Normal file
View File

@@ -0,0 +1,94 @@
/**
* 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>
#endif
#ifndef SRC_PARSER_DRIVER_H_
#define SRC_PARSER_DRIVER_H_
#include "modsecurity/modsecurity.h"
#include "src/rule.h"
#include "parser/seclang-parser.hh"
using ModSecurity::Rule;
# define YY_DECL \
yy::seclang_parser::symbol_type yylex(Driver& driver)
YY_DECL;
#ifdef __cplusplus
class Driver;
#else
typedef struct Driver_t Driver;
#endif
class Driver {
/**
* @todo Place driver and parser under the correct namespace.
*
*/
public:
Driver();
virtual ~Driver();
int addSecRule(Rule *rule);
int result;
// Handling the scanner.
void scan_begin();
void scan_end();
bool trace_scanning;
// Run the parser on file F.
// Return 0 on success.
int parseFile(const std::string& f);
int parse(const std::string& f);
// The name of the file being parsed.
// Used later to pass the file name to the location tracker.
std::string file;
// Whether parser traces should be generated.
bool trace_parsing;
// Error handling.
void error(const yy::location& l, const std::string& m);
void error(const std::string& m);
std::vector<Rule *> rules[7]; // Number of Phases.
int sec_rule_engine;
int sec_audit_type;
bool sec_audit_engine;
bool sec_request_body_access;
bool sec_response_body_access;
std::string audit_log_path;
std::string audit_log_parts;
std::string debug_log_path;
int debug_level;
};
#endif // SRC_PARSER_DRIVER_H_

View File

@@ -0,0 +1,240 @@
%skeleton "lalr1.cc" /* -*- C++ -*- */
%require "3.0.4"
%defines
%define parser_class_name {seclang_parser}
%define api.token.constructor
%define api.value.type variant
%define parse.assert
%code requires
{
# include <string>
class Driver;
#include "actions/action.h"
#include "actions/transformations/transformation.h"
#include "operators/operator.h"
#include "rule.h"
using ModSecurity::actions::Action;
using ModSecurity::actions::transformations::Transformation;
using ModSecurity::operators::Operator;
using ModSecurity::Variable;
using ModSecurity::Rule;
}
// The parsing context.
%param { Driver& driver }
%locations
%initial-action
{
// Initialize the initial location.
@$.begin.filename = @$.end.filename = &driver.file;
};
%define parse.trace
%define parse.error verbose
%code
{
#include "parser/driver.h"
}
%define api.token.prefix {TOK_}
%token
END 0 "end of file"
CONFIG_DIR_VAL "+"
COMMA "*"
QUOTATION_MARK ")"
SPACE
PIPE
NEW_LINE
UNKNOWN
FREE_TEXT
;
%left ARGS CONFIG_VALUE_ON CONFIG_VALUE_OFF CONFIG_VALUE
%token <std::string> DIRECTIVE
%token <std::string> CONFIG_DIRECTIVE
%token <std::string> CONFIG_DIR_RULE_ENG
%token <std::string> CONFIG_DIR_REQ_BODY
%token <std::string> CONFIG_DIR_RES_BODY
%token <std::string> CONFIG_DIR_AUDIT_ENG
%token <std::string> CONFIG_DIR_AUDIT_TPE
%token <std::string> CONFIG_VALUE
%token <std::string> CONFIG_VALUE_ON
%token <std::string> CONFIG_VALUE_OFF
%token <std::string> CONFIG_VALUE_DETC
%token <std::string> CONFIG_VALUE_SERIAL
%token <std::string> CONFIG_VALUE_PARALLEL
%token <std::string> CONFIG_DIR_AUDIT_LOG
%token <std::string> CONFIG_DIR_AUDIT_LOG_P
%token <std::string> CONFIG_DIR_DEBUG_LOG
%token <std::string> CONFIG_DIR_DEBUG_LVL
%token <std::string> OPERATOR
%token <std::string> ACTION
%token <std::string> VARIABLE
%token <std::string> TRANSFORMATION
%type <std::vector<Action *> *> actions
%type <std::vector<Variable> *> variables
%printer { yyoutput << $$; } <*>;
%%
%start secrule;
secrule:
| secrule line
line:
expression NEW_LINE
| SPACE expression NEW_LINE
| NEW_LINE
| SPACE NEW_LINE
| SPACE
expression:
DIRECTIVE SPACE variables SPACE OPERATOR SPACE QUOTATION_MARK actions QUOTATION_MARK
{
Rule *rule = new Rule(
/* op */ Operator::instantiate($5),
/* variables */ $3,
/* actions */ $8
);
driver.addSecRule(rule);
}
| CONFIG_DIR_RULE_ENG SPACE CONFIG_VALUE_OFF
{
driver.sec_rule_engine = 0;
}
| CONFIG_DIR_RULE_ENG SPACE CONFIG_VALUE_ON
{
driver.sec_rule_engine = 1;
}
| CONFIG_DIR_RULE_ENG SPACE CONFIG_VALUE_DETC
{
driver.sec_rule_engine = 2;
}
| CONFIG_DIR_REQ_BODY SPACE CONFIG_VALUE_ON
{
driver.sec_request_body_access = true;
}
| CONFIG_DIR_REQ_BODY SPACE CONFIG_VALUE_OFF
{
driver.sec_request_body_access = false;
}
| CONFIG_DIR_RES_BODY SPACE CONFIG_VALUE_ON
{
driver.sec_request_body_access = true;
}
| CONFIG_DIR_RES_BODY SPACE CONFIG_VALUE_OFF
{
driver.sec_request_body_access = false;
}
| CONFIG_DIR_AUDIT_ENG SPACE CONFIG_VALUE_ON
{
driver.sec_audit_engine = true;
}
| CONFIG_DIR_AUDIT_ENG SPACE CONFIG_VALUE_OFF
{
driver.sec_audit_engine = false;
}
| CONFIG_DIR_AUDIT_TPE SPACE CONFIG_VALUE_SERIAL
{
driver.sec_audit_type = 0;
}
| CONFIG_DIR_AUDIT_TPE SPACE CONFIG_VALUE_PARALLEL
{
driver.sec_audit_type = 1;
}
| CONFIG_DIR_AUDIT_LOG
{
driver.audit_log_path = $1;
}
| CONFIG_DIR_AUDIT_LOG_P
{
driver.audit_log_parts = $1;
}
| CONFIG_DIR_DEBUG_LVL
{
driver.debug_level = atoi($1.c_str());
}
| CONFIG_DIR_DEBUG_LOG
{
driver.debug_log_path = $1;
}
variables:
variables PIPE VARIABLE
{
std::vector<Variable> *v = $1;
v->push_back(Variable($3));
$$ = $1;
}
| VARIABLE
{
std::vector<Variable> *variables = new std::vector<Variable>;
variables->push_back(Variable($1));
$$ = variables;
}
actions:
actions COMMA SPACE ACTION
{
std::vector<Action *> *a = $1;
a->push_back(Action::instantiate($4));
$$ = $1;
}
| actions COMMA ACTION
{
std::vector<Action *> *a = $1;
a->push_back(Action::instantiate($3));
$$ = $1;
}
| SPACE ACTION
{
std::vector<Action *> *actions = new std::vector<Action *>;
actions->push_back(Action::instantiate($2));
$$ = actions;
}
| ACTION
{
std::vector<Action *> *actions = new std::vector<Action *>;
actions->push_back(Action::instantiate($1));
$$ = actions;
}
| actions COMMA SPACE TRANSFORMATION
{
std::vector<Action *> *a = $1;
a->push_back(Transformation::instantiate($4));
$$ = $1;
}
| actions COMMA TRANSFORMATION
{
std::vector<Action *> *a = $1;
a->push_back(Transformation::instantiate($3));
$$ = $1;
}
| SPACE TRANSFORMATION
{
std::vector<Action *> *actions = new std::vector<Action *>;
actions->push_back(Transformation::instantiate($2));
$$ = actions;
}
| TRANSFORMATION
{
std::vector<Action *> *actions = new std::vector<Action *>;
actions->push_back(Transformation::instantiate($1));
$$ = actions;
}
%%
void
yy::seclang_parser::error (const location_type& l,
const std::string& m)
{
driver.error (l, m);
}

Some files were not shown because too many files have changed in this diff Show More