From dc51add253d0915d98ec7bffb49810e3005f9ef7 Mon Sep 17 00:00:00 2001 From: Felipe Zimmerle Date: Tue, 13 Nov 2018 16:08:27 -0300 Subject: [PATCH] Refactoring: Renames RulesProperties to RulesSetProperties --- headers/modsecurity/rules_set.h | 8 +++---- ...es_properties.h => rules_set_properties.h} | 20 ++++++++--------- src/Makefile.am | 6 ++--- src/actions/ctl/request_body_access.cc | 6 ++--- src/actions/ctl/rule_engine.cc | 10 ++++----- src/actions/ctl/rule_engine.h | 6 ++--- src/actions/transformations/url_decode_uni.cc | 2 +- src/actions/transformations/url_decode_uni.h | 2 +- src/parser/driver.cc | 4 ++-- src/parser/driver.h | 4 ++-- src/parser/seclang-parser.cc | 20 ++++++++--------- src/parser/seclang-parser.hh | 2 +- src/parser/seclang-parser.yy | 22 +++++++++---------- src/request_body_processor/multipart.cc | 8 +++---- src/request_body_processor/xml.cc | 2 +- src/{rules.cc => rules_set.cc} | 8 +++---- ..._properties.cc => rules_set_properties.cc} | 5 ++--- src/transaction.cc | 20 ++++++++--------- src/variables/xml.cc | 2 +- test/optimization/optimization.cc | 2 +- 20 files changed, 79 insertions(+), 80 deletions(-) rename headers/modsecurity/{rules_properties.h => rules_set_properties.h} (97%) rename src/{rules.cc => rules_set.cc} (98%) rename src/{rules_properties.cc => rules_set_properties.cc} (97%) diff --git a/headers/modsecurity/rules_set.h b/headers/modsecurity/rules_set.h index 12868e80..7d491cd5 100644 --- a/headers/modsecurity/rules_set.h +++ b/headers/modsecurity/rules_set.h @@ -28,7 +28,7 @@ #ifndef HEADERS_MODSECURITY_RULES_H_ #define HEADERS_MODSECURITY_RULES_H_ -#include "modsecurity/rules_properties.h" +#include "modsecurity/rules_set_properties.h" #include "modsecurity/modsecurity.h" #include "modsecurity/transaction.h" @@ -42,10 +42,10 @@ class Driver; /** @ingroup ModSecurity_CPP_API */ -class RulesSet : public RulesProperties { +class RulesSet : public RulesSetProperties { public: RulesSet() - : RulesProperties(new DebugLog()), + : RulesSetProperties(new DebugLog()), unicode_codepage(0), #ifndef NO_LOGS m_secmarker_skipped(0), @@ -53,7 +53,7 @@ class RulesSet : public RulesProperties { m_referenceCount(0) { } explicit RulesSet(DebugLog *customLog) - : RulesProperties(customLog), + : RulesSetProperties(customLog), unicode_codepage(0), #ifndef NO_LOGS m_secmarker_skipped(0), diff --git a/headers/modsecurity/rules_properties.h b/headers/modsecurity/rules_set_properties.h similarity index 97% rename from headers/modsecurity/rules_properties.h rename to headers/modsecurity/rules_set_properties.h index c43578fa..934c8531 100644 --- a/headers/modsecurity/rules_properties.h +++ b/headers/modsecurity/rules_set_properties.h @@ -25,8 +25,8 @@ #endif -#ifndef HEADERS_MODSECURITY_RULES_PROPERTIES_H_ -#define HEADERS_MODSECURITY_RULES_PROPERTIES_H_ +#ifndef HEADERS_MODSECURITY_RULES_SET_PROPERTIES_H_ +#define HEADERS_MODSECURITY_RULES_SET_PROPERTIES_H_ #include "modsecurity/modsecurity.h" @@ -140,7 +140,7 @@ class UnicodeMapHolder { }; -class RulesProperties; +class RulesSetProperties; class ConfigUnicodeMap { public: ConfigUnicodeMap() : m_set(false), @@ -148,7 +148,7 @@ class ConfigUnicodeMap { m_unicodeMapTable(NULL) { } static void loadConfig(std::string f, double codePage, - RulesProperties *driver, std::string *errg); + RulesSetProperties *driver, std::string *errg); void merge(ConfigUnicodeMap *from) { if (from->m_set == false) { @@ -168,9 +168,9 @@ class ConfigUnicodeMap { }; -class RulesProperties { +class RulesSetProperties { public: - RulesProperties() : + RulesSetProperties() : m_auditLog(new AuditLog()), m_requestBodyLimitAction(PropertyNotSetBodyLimitAction), m_responseBodyLimitAction(PropertyNotSetBodyLimitAction), @@ -184,7 +184,7 @@ class RulesProperties { m_secRuleEngine(PropertyNotSetRuleEngine) { } - explicit RulesProperties(DebugLog *debugLog) : + explicit RulesSetProperties(DebugLog *debugLog) : m_auditLog(new AuditLog()), m_requestBodyLimitAction(PropertyNotSetBodyLimitAction), m_responseBodyLimitAction(PropertyNotSetBodyLimitAction), @@ -198,7 +198,7 @@ class RulesProperties { m_secRuleEngine(PropertyNotSetRuleEngine) { } - ~RulesProperties() { + ~RulesSetProperties() { int i = 0; /** Cleanup the rules */ for (i = 0; i < modsecurity::Phases::NUMBER_OF_PHASES; i++) { @@ -350,7 +350,7 @@ class RulesProperties { } - static int mergeProperties(RulesProperties *from, RulesProperties *to, + static int mergeProperties(RulesSetProperties *from, RulesSetProperties *to, std::ostringstream *err) { int amount_of_rules = 0; @@ -558,4 +558,4 @@ class RulesProperties { } // namespace modsecurity #endif -#endif // HEADERS_MODSECURITY_RULES_PROPERTIES_H_ +#endif // HEADERS_MODSECURITY_RULES_SET_PROPERTIES_H_ diff --git a/src/Makefile.am b/src/Makefile.am index d44bb7f7..22ebf256 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -44,8 +44,8 @@ pkginclude_HEADERS = \ ../headers/modsecurity/rule.h \ ../headers/modsecurity/rule_message.h \ ../headers/modsecurity/rules_set.h \ + ../headers/modsecurity/rules_set_properties.h \ ../headers/modsecurity/rules_exceptions.h \ - ../headers/modsecurity/rules_properties.h \ ../headers/modsecurity/transaction.h \ ../headers/modsecurity/variable_origin.h \ ../headers/modsecurity/variable_value.h @@ -271,7 +271,8 @@ libmodsecurity_la_SOURCES = \ audit_log/writer/serial.cc \ audit_log/writer/parallel.cc \ modsecurity.cc \ - rules.cc \ + rules_set.cc \ + rules_set_properties.cc \ debug_log/debug_log.cc \ debug_log/debug_log_writer.cc \ run_time_string.cc \ @@ -280,7 +281,6 @@ libmodsecurity_la_SOURCES = \ rule_script.cc \ unique_id.cc \ rules_exceptions.cc \ - rules_properties.cc \ ${BODY_PROCESSORS} \ ${ACTIONS} \ ${ENGINES} \ diff --git a/src/actions/ctl/request_body_access.cc b/src/actions/ctl/request_body_access.cc index f811e941..a150bfec 100644 --- a/src/actions/ctl/request_body_access.cc +++ b/src/actions/ctl/request_body_access.cc @@ -18,7 +18,7 @@ #include #include -#include "modsecurity/rules_properties.h" +#include "modsecurity/rules_set_properties.h" #include "modsecurity/transaction.h" namespace modsecurity { @@ -44,9 +44,9 @@ bool RequestBodyAccess::init(std::string *error) { bool RequestBodyAccess::evaluate(Rule *rule, Transaction *transaction) { if (m_request_body_access) { - transaction->m_requestBodyAccess = RulesProperties::TrueConfigBoolean; + transaction->m_requestBodyAccess = RulesSetProperties::TrueConfigBoolean; } else { - transaction->m_requestBodyAccess = RulesProperties::FalseConfigBoolean; + transaction->m_requestBodyAccess = RulesSetProperties::FalseConfigBoolean; } return true; diff --git a/src/actions/ctl/rule_engine.cc b/src/actions/ctl/rule_engine.cc index 18f7bd25..ea27011d 100644 --- a/src/actions/ctl/rule_engine.cc +++ b/src/actions/ctl/rule_engine.cc @@ -18,8 +18,8 @@ #include #include +#include "modsecurity/rules_set_properties.h" #include "modsecurity/rules_set.h" -#include "modsecurity/rules_properties.h" #include "modsecurity/transaction.h" namespace modsecurity { @@ -31,11 +31,11 @@ bool RuleEngine::init(std::string *error) { std::string what(m_parser_payload, 11, m_parser_payload.size() - 11); if (what == "on") { - m_ruleEngine = RulesProperties::EnabledRuleEngine; + m_ruleEngine = RulesSetProperties::EnabledRuleEngine; } else if (what == "off") { - m_ruleEngine = RulesProperties::DisabledRuleEngine; + m_ruleEngine = RulesSetProperties::DisabledRuleEngine; } else if (what == "detectiononly") { - m_ruleEngine = RulesProperties::DetectionOnlyRuleEngine; + m_ruleEngine = RulesSetProperties::DetectionOnlyRuleEngine; } else { error->assign("Internal error. Expected: On, Off or DetectionOnly; " \ "got: " + m_parser_payload); @@ -48,7 +48,7 @@ bool RuleEngine::init(std::string *error) { bool RuleEngine::evaluate(Rule *rule, Transaction *transaction) { std::stringstream a; a << "Setting SecRuleEngine to "; - a << modsecurity::RulesProperties::ruleEngineStateString(m_ruleEngine); + a << modsecurity::RulesSetProperties::ruleEngineStateString(m_ruleEngine); a << " as requested by a ctl:ruleEngine action"; ms_dbg_a(transaction, 8, a.str()); diff --git a/src/actions/ctl/rule_engine.h b/src/actions/ctl/rule_engine.h index 93ef894c..39874e6e 100644 --- a/src/actions/ctl/rule_engine.h +++ b/src/actions/ctl/rule_engine.h @@ -15,9 +15,9 @@ #include +#include "modsecurity/rules_set_properties.h" #include "modsecurity/actions/action.h" #include "modsecurity/transaction.h" -#include "modsecurity/rules_properties.h" #ifndef SRC_ACTIONS_CTL_RULE_ENGINE_H_ @@ -32,12 +32,12 @@ class RuleEngine : public Action { public: explicit RuleEngine(std::string action) : Action(action, RunTimeOnlyIfMatchKind), - m_ruleEngine(RulesProperties::PropertyNotSetRuleEngine) { } + m_ruleEngine(RulesSetProperties::PropertyNotSetRuleEngine) { } bool init(std::string *error) override; bool evaluate(Rule *rule, Transaction *transaction) override; - RulesProperties::RuleEngine m_ruleEngine; + RulesSetProperties::RuleEngine m_ruleEngine; }; diff --git a/src/actions/transformations/url_decode_uni.cc b/src/actions/transformations/url_decode_uni.cc index 4af5c055..e7f260a8 100644 --- a/src/actions/transformations/url_decode_uni.cc +++ b/src/actions/transformations/url_decode_uni.cc @@ -25,12 +25,12 @@ #include #include +#include "modsecurity/rules_set_properties.h" #include "modsecurity/rules_set.h" #include "modsecurity/transaction.h" #include "src/actions/transformations/transformation.h" #include "src/utils/string.h" #include "src/utils/system.h" -#include "modsecurity/rules_properties.h" namespace modsecurity { diff --git a/src/actions/transformations/url_decode_uni.h b/src/actions/transformations/url_decode_uni.h index fc08f9a9..009e7b2f 100644 --- a/src/actions/transformations/url_decode_uni.h +++ b/src/actions/transformations/url_decode_uni.h @@ -15,8 +15,8 @@ #include +#include "modsecurity/rules_set_properties.h" #include "modsecurity/actions/action.h" -#include "modsecurity/rules_properties.h" #include "src/actions/transformations/transformation.h" #ifndef SRC_ACTIONS_TRANSFORMATIONS_URL_DECODE_UNI_H_ diff --git a/src/parser/driver.cc b/src/parser/driver.cc index f4b722ac..6d3a0f3d 100644 --- a/src/parser/driver.cc +++ b/src/parser/driver.cc @@ -15,9 +15,9 @@ #include "src/parser/driver.h" +#include "modsecurity/rules_set_properties.h" #include "src/parser/seclang-parser.hh" #include "modsecurity/audit_log.h" -#include "modsecurity/rules_properties.h" using modsecurity::audit_log::AuditLog; using modsecurity::Rule; @@ -26,7 +26,7 @@ namespace modsecurity { namespace Parser { Driver::Driver() - : RulesProperties(), + : RulesSetProperties(), trace_scanning(false), trace_parsing(false), lastRule(NULL) { } diff --git a/src/parser/driver.h b/src/parser/driver.h index 43f1c40b..a19cda89 100644 --- a/src/parser/driver.h +++ b/src/parser/driver.h @@ -26,7 +26,7 @@ #include "modsecurity/modsecurity.h" #include "modsecurity/rules_set.h" -#include "modsecurity/rules_properties.h" +#include "modsecurity/rules_set_properties.h" #include "modsecurity/audit_log.h" #include "src/rule_script.h" #include "src/parser/seclang-parser.hh" @@ -50,7 +50,7 @@ typedef struct Driver_t Driver; #endif -class Driver : public RulesProperties { +class Driver : public RulesSetProperties { public: Driver(); virtual ~Driver(); diff --git a/src/parser/seclang-parser.cc b/src/parser/seclang-parser.cc index 80837e1e..c388fd5b 100644 --- a/src/parser/seclang-parser.cc +++ b/src/parser/seclang-parser.cc @@ -1585,7 +1585,7 @@ namespace yy { case 21: #line 839 "seclang-parser.yy" // lalr1.cc:906 { - driver.m_uploadKeepFiles = modsecurity::RulesProperties::TrueConfigBoolean; + driver.m_uploadKeepFiles = modsecurity::RulesSetProperties::TrueConfigBoolean; } #line 1591 "seclang-parser.cc" // lalr1.cc:906 break; @@ -1593,7 +1593,7 @@ namespace yy { case 22: #line 843 "seclang-parser.yy" // lalr1.cc:906 { - driver.m_uploadKeepFiles = modsecurity::RulesProperties::FalseConfigBoolean; + driver.m_uploadKeepFiles = modsecurity::RulesSetProperties::FalseConfigBoolean; } #line 1599 "seclang-parser.cc" // lalr1.cc:906 break; @@ -1637,7 +1637,7 @@ namespace yy { case 27: #line 867 "seclang-parser.yy" // lalr1.cc:906 { - driver.m_tmpSaveUploadedFiles = modsecurity::RulesProperties::TrueConfigBoolean; + driver.m_tmpSaveUploadedFiles = modsecurity::RulesSetProperties::TrueConfigBoolean; } #line 1643 "seclang-parser.cc" // lalr1.cc:906 break; @@ -1645,7 +1645,7 @@ namespace yy { case 28: #line 871 "seclang-parser.yy" // lalr1.cc:906 { - driver.m_tmpSaveUploadedFiles = modsecurity::RulesProperties::FalseConfigBoolean; + driver.m_tmpSaveUploadedFiles = modsecurity::RulesSetProperties::FalseConfigBoolean; } #line 1651 "seclang-parser.cc" // lalr1.cc:906 break; @@ -2225,7 +2225,7 @@ namespace yy { case 82: #line 1255 "seclang-parser.yy" // lalr1.cc:906 { - driver.m_secRequestBodyAccess = modsecurity::RulesProperties::TrueConfigBoolean; + driver.m_secRequestBodyAccess = modsecurity::RulesSetProperties::TrueConfigBoolean; } #line 2231 "seclang-parser.cc" // lalr1.cc:906 break; @@ -2233,7 +2233,7 @@ namespace yy { case 83: #line 1259 "seclang-parser.yy" // lalr1.cc:906 { - driver.m_secRequestBodyAccess = modsecurity::RulesProperties::FalseConfigBoolean; + driver.m_secRequestBodyAccess = modsecurity::RulesSetProperties::FalseConfigBoolean; } #line 2239 "seclang-parser.cc" // lalr1.cc:906 break; @@ -2241,7 +2241,7 @@ namespace yy { case 84: #line 1263 "seclang-parser.yy" // lalr1.cc:906 { - driver.m_secResponseBodyAccess = modsecurity::RulesProperties::TrueConfigBoolean; + driver.m_secResponseBodyAccess = modsecurity::RulesSetProperties::TrueConfigBoolean; } #line 2247 "seclang-parser.cc" // lalr1.cc:906 break; @@ -2249,7 +2249,7 @@ namespace yy { case 85: #line 1267 "seclang-parser.yy" // lalr1.cc:906 { - driver.m_secResponseBodyAccess = modsecurity::RulesProperties::FalseConfigBoolean; + driver.m_secResponseBodyAccess = modsecurity::RulesSetProperties::FalseConfigBoolean; } #line 2255 "seclang-parser.cc" // lalr1.cc:906 break; @@ -2848,7 +2848,7 @@ namespace yy { case 140: #line 1667 "seclang-parser.yy" // lalr1.cc:906 { - driver.m_secXMLExternalEntity = modsecurity::RulesProperties::FalseConfigBoolean; + driver.m_secXMLExternalEntity = modsecurity::RulesSetProperties::FalseConfigBoolean; } #line 2854 "seclang-parser.cc" // lalr1.cc:906 break; @@ -2856,7 +2856,7 @@ namespace yy { case 141: #line 1671 "seclang-parser.yy" // lalr1.cc:906 { - driver.m_secXMLExternalEntity = modsecurity::RulesProperties::TrueConfigBoolean; + driver.m_secXMLExternalEntity = modsecurity::RulesSetProperties::TrueConfigBoolean; } #line 2862 "seclang-parser.cc" // lalr1.cc:906 break; diff --git a/src/parser/seclang-parser.hh b/src/parser/seclang-parser.hh index e82347db..796b0180 100644 --- a/src/parser/seclang-parser.hh +++ b/src/parser/seclang-parser.hh @@ -186,7 +186,7 @@ class Driver; #include "modsecurity/audit_log.h" #include "modsecurity/modsecurity.h" -#include "modsecurity/rules_properties.h" +#include "modsecurity/rules_set_properties.h" #include "modsecurity/rule.h" #include "src/operators/operator.h" #include "src/utils/geo_lookup.h" diff --git a/src/parser/seclang-parser.yy b/src/parser/seclang-parser.yy index 0dde8b72..85df48f5 100644 --- a/src/parser/seclang-parser.yy +++ b/src/parser/seclang-parser.yy @@ -148,7 +148,7 @@ class Driver; #include "modsecurity/audit_log.h" #include "modsecurity/modsecurity.h" -#include "modsecurity/rules_properties.h" +#include "modsecurity/rules_set_properties.h" #include "modsecurity/rule.h" #include "src/operators/operator.h" #include "src/utils/geo_lookup.h" @@ -837,11 +837,11 @@ audit_log: /* Upload */ | CONFIG_UPDLOAD_KEEP_FILES CONFIG_VALUE_ON { - driver.m_uploadKeepFiles = modsecurity::RulesProperties::TrueConfigBoolean; + driver.m_uploadKeepFiles = modsecurity::RulesSetProperties::TrueConfigBoolean; } | CONFIG_UPDLOAD_KEEP_FILES CONFIG_VALUE_OFF { - driver.m_uploadKeepFiles = modsecurity::RulesProperties::FalseConfigBoolean; + driver.m_uploadKeepFiles = modsecurity::RulesSetProperties::FalseConfigBoolean; } | CONFIG_UPDLOAD_KEEP_FILES CONFIG_VALUE_RELEVANT_ONLY { @@ -865,11 +865,11 @@ audit_log: } | CONFIG_UPDLOAD_SAVE_TMP_FILES CONFIG_VALUE_ON { - driver.m_tmpSaveUploadedFiles = modsecurity::RulesProperties::TrueConfigBoolean; + driver.m_tmpSaveUploadedFiles = modsecurity::RulesSetProperties::TrueConfigBoolean; } | CONFIG_UPDLOAD_SAVE_TMP_FILES CONFIG_VALUE_OFF { - driver.m_tmpSaveUploadedFiles = modsecurity::RulesProperties::FalseConfigBoolean; + driver.m_tmpSaveUploadedFiles = modsecurity::RulesSetProperties::FalseConfigBoolean; } ; @@ -1253,19 +1253,19 @@ expression: } | CONFIG_DIR_REQ_BODY CONFIG_VALUE_ON { - driver.m_secRequestBodyAccess = modsecurity::RulesProperties::TrueConfigBoolean; + driver.m_secRequestBodyAccess = modsecurity::RulesSetProperties::TrueConfigBoolean; } | CONFIG_DIR_REQ_BODY CONFIG_VALUE_OFF { - driver.m_secRequestBodyAccess = modsecurity::RulesProperties::FalseConfigBoolean; + driver.m_secRequestBodyAccess = modsecurity::RulesSetProperties::FalseConfigBoolean; } | CONFIG_DIR_RES_BODY CONFIG_VALUE_ON { - driver.m_secResponseBodyAccess = modsecurity::RulesProperties::TrueConfigBoolean; + driver.m_secResponseBodyAccess = modsecurity::RulesSetProperties::TrueConfigBoolean; } | CONFIG_DIR_RES_BODY CONFIG_VALUE_OFF { - driver.m_secResponseBodyAccess = modsecurity::RulesProperties::FalseConfigBoolean; + driver.m_secResponseBodyAccess = modsecurity::RulesSetProperties::FalseConfigBoolean; } | CONFIG_SEC_ARGUMENT_SEPARATOR { @@ -1665,11 +1665,11 @@ expression: } | CONFIG_XML_EXTERNAL_ENTITY CONFIG_VALUE_OFF { - driver.m_secXMLExternalEntity = modsecurity::RulesProperties::FalseConfigBoolean; + driver.m_secXMLExternalEntity = modsecurity::RulesSetProperties::FalseConfigBoolean; } | CONFIG_XML_EXTERNAL_ENTITY CONFIG_VALUE_ON { - driver.m_secXMLExternalEntity = modsecurity::RulesProperties::TrueConfigBoolean; + driver.m_secXMLExternalEntity = modsecurity::RulesSetProperties::TrueConfigBoolean; } | CONGIG_DIR_SEC_TMP_DIR { diff --git a/src/request_body_processor/multipart.cc b/src/request_body_processor/multipart.cc index b7fdb4fc..d9f11ce0 100644 --- a/src/request_body_processor/multipart.cc +++ b/src/request_body_processor/multipart.cc @@ -71,12 +71,12 @@ Multipart::Multipart(std:: string header, Transaction *transaction) Multipart::~Multipart() { ms_dbg_a(m_transaction, 4, "Multipart: Cleanup started (remove files " \ - + RulesProperties::configBooleanString( + + RulesSetProperties::configBooleanString( m_transaction->m_rules->m_uploadKeepFiles) \ + ")"); if (m_transaction->m_rules->m_uploadKeepFiles - != RulesProperties::TrueConfigBoolean) { + != RulesSetProperties::TrueConfigBoolean) { for (MultipartPart *m : m_parts) { if (m->m_type == MULTIPART_FILE) { if (!m->m_tmp_file_name.empty()) { @@ -462,9 +462,9 @@ int Multipart::process_part_data(std::string *error, size_t offset) { /* add data to the part we are building */ if (m_mpp->m_type == MULTIPART_FILE) { bool extract = m_transaction->m_rules->m_uploadKeepFiles \ - == RulesProperties::TrueConfigBoolean \ + == RulesSetProperties::TrueConfigBoolean \ || m_transaction->m_rules->m_tmpSaveUploadedFiles \ - == RulesProperties::TrueConfigBoolean; + == RulesSetProperties::TrueConfigBoolean; /* remember where we started */ if (m_mpp->m_length == 0) { diff --git a/src/request_body_processor/xml.cc b/src/request_body_processor/xml.cc index 70796e65..c9efa483 100644 --- a/src/request_body_processor/xml.cc +++ b/src/request_body_processor/xml.cc @@ -48,7 +48,7 @@ XML::~XML() { bool XML::init() { xmlParserInputBufferCreateFilenameFunc entity; if (m_transaction->m_rules->m_secXMLExternalEntity - == RulesProperties::TrueConfigBoolean) { + == RulesSetProperties::TrueConfigBoolean) { entity = xmlParserInputBufferCreateFilenameDefault( __xmlParserInputBufferCreateFilename); } else { diff --git a/src/rules.cc b/src/rules_set.cc similarity index 98% rename from src/rules.cc rename to src/rules_set.cc index 9eac60b0..d7bedd7a 100644 --- a/src/rules.cc +++ b/src/rules_set.cc @@ -263,8 +263,8 @@ int RulesSet::evaluate(int phase, Transaction *t) { int RulesSet::merge(Driver *from) { int amount_of_rules = 0; amount_of_rules = mergeProperties( - dynamic_cast(from), - dynamic_cast(this), + dynamic_cast(from), + dynamic_cast(this), &m_parserError); return amount_of_rules; @@ -274,8 +274,8 @@ int RulesSet::merge(Driver *from) { int RulesSet::merge(RulesSet *from) { int amount_of_rules = 0; amount_of_rules = mergeProperties( - dynamic_cast(from), - dynamic_cast(this), + dynamic_cast(from), + dynamic_cast(this), &m_parserError); return amount_of_rules; diff --git a/src/rules_properties.cc b/src/rules_set_properties.cc similarity index 97% rename from src/rules_properties.cc rename to src/rules_set_properties.cc index 78f0e9d1..bbb80cfc 100644 --- a/src/rules_properties.cc +++ b/src/rules_set_properties.cc @@ -13,10 +13,9 @@ * */ -#include "modsecurity/rules_properties.h" - #include +#include "modsecurity/rules_set_properties.h" #include "src/utils/string.h" #include "src/variables/variable.h" @@ -24,7 +23,7 @@ namespace modsecurity { void ConfigUnicodeMap::loadConfig(std::string f, double configCodePage, - RulesProperties *driver, std::string *errg) { + RulesSetProperties *driver, std::string *errg) { char *buf = NULL; char *hmap = NULL; char *p = NULL; diff --git a/src/transaction.cc b/src/transaction.cc index 021fc0c5..3bff0e27 100644 --- a/src/transaction.cc +++ b/src/transaction.cc @@ -49,7 +49,7 @@ #include "src/utils/random.h" #include "modsecurity/rule.h" #include "modsecurity/rule_message.h" -#include "modsecurity/rules_properties.h" +#include "modsecurity/rules_set_properties.h" #include "src/actions/disruptive/allow.h" #include "src/variables/remote_user.h" @@ -117,7 +117,7 @@ Transaction::Transaction(ModSecurity *ms, RulesSet *rules, void *logCbData) m_creationTimeStamp(utils::cpu_seconds()), m_logCbData(logCbData), m_ms(ms), - m_secRuleEngine(RulesProperties::PropertyNotSetRuleEngine), + m_secRuleEngine(RulesSetProperties::PropertyNotSetRuleEngine), m_collections(ms->m_global_collection, ms->m_ip_collection, ms->m_session_collection, ms->m_user_collection, ms->m_resource_collection), @@ -161,7 +161,7 @@ Transaction::Transaction(ModSecurity *ms, RulesSet *rules, char *id, void *logCb m_creationTimeStamp(utils::cpu_seconds()), m_logCbData(logCbData), m_ms(ms), - m_secRuleEngine(RulesProperties::PropertyNotSetRuleEngine), + m_secRuleEngine(RulesSetProperties::PropertyNotSetRuleEngine), m_collections(ms->m_global_collection, ms->m_ip_collection, ms->m_session_collection, ms->m_user_collection, ms->m_resource_collection), @@ -681,7 +681,7 @@ int Transaction::addRequestHeader(const unsigned char *key, size_t key_n, int Transaction::processRequestBody() { ms_dbg(4, "Starting phase REQUEST_BODY. (SecRules 2)"); - if (getRuleEngineState() == RulesProperties::DisabledRuleEngine) { + if (getRuleEngineState() == RulesSetProperties::DisabledRuleEngine) { ms_dbg(4, "Rule engine disabled, returning..."); return true; } @@ -794,8 +794,8 @@ int Transaction::processRequestBody() { m_variableReqbodyProcessorError.set("0", m_variableOffset); } - if (m_rules->m_secRequestBodyAccess == RulesProperties::FalseConfigBoolean) { - if (m_requestBodyAccess != RulesProperties::TrueConfigBoolean) { + if (m_rules->m_secRequestBodyAccess == RulesSetProperties::FalseConfigBoolean) { + if (m_requestBodyAccess != RulesSetProperties::TrueConfigBoolean) { ms_dbg(4, "Request body processing is disabled"); return true; } else { @@ -804,7 +804,7 @@ int Transaction::processRequestBody() { "action"); } } else { - if (m_requestBodyAccess == RulesProperties::FalseConfigBoolean) { + if (m_requestBodyAccess == RulesSetProperties::FalseConfigBoolean) { ms_dbg(4, "Request body processing is enabled, but " \ "disabled to this transaction due to ctl:requestBodyAccess " \ "action"); @@ -1089,7 +1089,7 @@ int Transaction::processResponseBody() { return true; } - if (m_rules->m_secResponseBodyAccess != RulesProperties::TrueConfigBoolean) { + if (m_rules->m_secResponseBodyAccess != RulesSetProperties::TrueConfigBoolean) { ms_dbg(4, "Response body is disabled, returning... " + std::to_string(m_rules->m_secResponseBodyAccess)); return true; } @@ -1627,7 +1627,7 @@ std::string Transaction::toJSON(int parts) { /* producer > engine state */ LOGFY_ADD("secrules_engine", RulesSet::ruleEngineStateString( - (RulesProperties::RuleEngine) getRuleEngineState())); + (RulesSetProperties::RuleEngine) getRuleEngineState())); /* producer > components */ yajl_gen_string(g, @@ -1714,7 +1714,7 @@ void Transaction::serverLog(std::shared_ptr rm) { int Transaction::getRuleEngineState() { - if (m_secRuleEngine == RulesProperties::PropertyNotSetRuleEngine) { + if (m_secRuleEngine == RulesSetProperties::PropertyNotSetRuleEngine) { return m_rules->m_secRuleEngine; } diff --git a/src/variables/xml.cc b/src/variables/xml.cc index dd8dc022..db9205cf 100644 --- a/src/variables/xml.cc +++ b/src/variables/xml.cc @@ -36,7 +36,7 @@ #include #include "modsecurity/transaction.h" -#include "modsecurity/rules_properties.h" +#include "modsecurity/rules_set_properties.h" #include "modsecurity/rules_set.h" #include "src/request_body_processor/xml.h" diff --git a/test/optimization/optimization.cc b/test/optimization/optimization.cc index 4ba00e89..c69efebc 100644 --- a/test/optimization/optimization.cc +++ b/test/optimization/optimization.cc @@ -20,12 +20,12 @@ #include #include +#include "modsecurity/rules_set_properties.h" #include "modsecurity/rules_set.h" #include "modsecurity/modsecurity.h" #include "src/utils/system.h" #include "src/parser/driver.h" #include "src/utils/https_client.h" -#include "modsecurity/rules_properties.h" #include "modsecurity/transaction.h" void print_help() {