diff --git a/headers/modsecurity/rule.h b/headers/modsecurity/rule.h index b46abcfdb..e73f73d38 100644 --- a/headers/modsecurity/rule.h +++ b/headers/modsecurity/rule.h @@ -64,8 +64,8 @@ using MatchActions = std::vector; class Rule { public: - Rule(std::unique_ptr fileName, int lineNumber) - : m_fileName(*fileName), + Rule(const std::string &fileName, int lineNumber) + : m_fileName(fileName), m_lineNumber(lineNumber), m_phase(modsecurity::Phases::RequestHeadersPhase) { } diff --git a/headers/modsecurity/rule_marker.h b/headers/modsecurity/rule_marker.h index bd66ddcf5..9710cab2e 100644 --- a/headers/modsecurity/rule_marker.h +++ b/headers/modsecurity/rule_marker.h @@ -33,9 +33,9 @@ class RuleMarker : public Rule { public: RuleMarker( const std::string &name, - std::unique_ptr fileName, + const std::string &fileName, int lineNumber) - : Rule(std::move(fileName), lineNumber), + : Rule(fileName, lineNumber), m_name(name) { } RuleMarker(const RuleMarker &r) = delete; diff --git a/headers/modsecurity/rule_unconditional.h b/headers/modsecurity/rule_unconditional.h index 2acf4dd5a..9769dc219 100644 --- a/headers/modsecurity/rule_unconditional.h +++ b/headers/modsecurity/rule_unconditional.h @@ -37,9 +37,9 @@ class RuleUnconditional : public RuleWithActions { RuleUnconditional( std::vector *actions, Transformations *transformations, - std::unique_ptr fileName, + const std::string &fileName, int lineNumber) - : RuleWithActions(actions, transformations, std::move(fileName), lineNumber) { } + : RuleWithActions(actions, transformations, fileName, lineNumber) { } RuleUnconditional(const RuleUnconditional& r) = delete; diff --git a/headers/modsecurity/rule_with_actions.h b/headers/modsecurity/rule_with_actions.h index 4e7344488..21c989681 100644 --- a/headers/modsecurity/rule_with_actions.h +++ b/headers/modsecurity/rule_with_actions.h @@ -40,7 +40,7 @@ class RuleWithActions : public Rule { RuleWithActions( Actions *a, Transformations *t, - std::unique_ptr fileName, + const std::string &fileName, int lineNumber); virtual ~RuleWithActions(); diff --git a/headers/modsecurity/rule_with_operator.h b/headers/modsecurity/rule_with_operator.h index 42fa0f9ec..a1048b986 100644 --- a/headers/modsecurity/rule_with_operator.h +++ b/headers/modsecurity/rule_with_operator.h @@ -42,7 +42,7 @@ class RuleWithOperator : public RuleWithActions { variables::Variables *variables, std::vector *actions, Transformations *transformations, - std::unique_ptr fileName, + const std::string &fileName, int lineNumber); virtual ~RuleWithOperator(); diff --git a/src/parser/driver.cc b/src/parser/driver.cc index a6a9755c9..a42942fbd 100644 --- a/src/parser/driver.cc +++ b/src/parser/driver.cc @@ -43,11 +43,10 @@ Driver::~Driver() { } -int Driver::addSecMarker(const std::string& marker, std::unique_ptr fileName, int lineNumber) { +int Driver::addSecMarker(const std::string& marker, const std::string &fileName, int lineNumber) { // FIXME: we might move this to the parser. for (int i = 0; i < modsecurity::Phases::NUMBER_OF_PHASES; i++) { - RuleMarker *r = new RuleMarker(marker, std::unique_ptr(new std::string(*fileName)), lineNumber); - std::unique_ptr rule(r); + auto rule = std::make_unique(marker, fileName, lineNumber); rule->setPhase(i); m_rulesSetPhases.insert(std::move(rule)); } diff --git a/src/parser/driver.h b/src/parser/driver.h index 20e7ef3c6..dadb978d9 100644 --- a/src/parser/driver.h +++ b/src/parser/driver.h @@ -60,7 +60,7 @@ class Driver : public RulesSetProperties { int addSecRule(std::unique_ptr rule); int addSecAction(std::unique_ptr rule); - int addSecMarker(const std::string& marker, std::unique_ptr fileName, int lineNumber); + int addSecMarker(const std::string& marker, const std::string &fileName, int lineNumber); int addSecRuleScript(std::unique_ptr rule); bool scan_begin(); diff --git a/src/parser/seclang-parser.cc b/src/parser/seclang-parser.cc index fbce57040..3d90430af 100644 --- a/src/parser/seclang-parser.cc +++ b/src/parser/seclang-parser.cc @@ -2313,7 +2313,7 @@ namespace yy { /* variables */ v, /* actions */ a, /* transformations */ t, - /* file name */ std::unique_ptr(new std::string(*yystack_[3].location.end.filename)), + /* file name */ std::string(*yystack_[3].location.end.filename), /* line number */ yystack_[3].location.end.line )); @@ -2337,7 +2337,7 @@ namespace yy { /* variables */ v, /* actions */ NULL, /* transformations */ NULL, - /* file name */ std::unique_ptr(new std::string(*yystack_[2].location.end.filename)), + /* file name */ std::string(*yystack_[2].location.end.filename), /* line number */ yystack_[2].location.end.line )); if (driver.addSecRule(std::move(rule)) == false) { @@ -2363,7 +2363,7 @@ namespace yy { std::unique_ptr rule(new RuleUnconditional( /* actions */ a, /* transformations */ t, - /* file name */ std::unique_ptr(new std::string(*yystack_[1].location.end.filename)), + /* file name */ std::string(*yystack_[1].location.end.filename), /* line number */ yystack_[1].location.end.line )); driver.addSecAction(std::move(rule)); @@ -2389,7 +2389,7 @@ namespace yy { /* path to script */ yystack_[1].value.as < std::string > (), /* actions */ a, /* transformations */ t, - /* file name */ std::unique_ptr(new std::string(*yystack_[1].location.end.filename)), + /* file name */ std::string(*yystack_[1].location.end.filename), /* line number */ yystack_[1].location.end.line )); @@ -2469,7 +2469,7 @@ namespace yy { #line 1241 "seclang-parser.yy" { driver.addSecMarker(modsecurity::utils::string::removeBracketsIfNeeded(yystack_[0].value.as < std::string > ()), - /* file name */ std::unique_ptr(new std::string(*yystack_[0].location.end.filename)), + /* file name */ std::string(*yystack_[0].location.end.filename), /* line number */ yystack_[0].location.end.line ); } diff --git a/src/parser/seclang-parser.yy b/src/parser/seclang-parser.yy index 41583768f..5de56e218 100644 --- a/src/parser/seclang-parser.yy +++ b/src/parser/seclang-parser.yy @@ -1104,7 +1104,7 @@ expression: /* variables */ v, /* actions */ a, /* transformations */ t, - /* file name */ std::unique_ptr(new std::string(*@1.end.filename)), + /* file name */ std::string(*@1.end.filename), /* line number */ @1.end.line )); @@ -1124,7 +1124,7 @@ expression: /* variables */ v, /* actions */ NULL, /* transformations */ NULL, - /* file name */ std::unique_ptr(new std::string(*@1.end.filename)), + /* file name */ std::string(*@1.end.filename), /* line number */ @1.end.line )); if (driver.addSecRule(std::move(rule)) == false) { @@ -1146,7 +1146,7 @@ expression: std::unique_ptr rule(new RuleUnconditional( /* actions */ a, /* transformations */ t, - /* file name */ std::unique_ptr(new std::string(*@1.end.filename)), + /* file name */ std::string(*@1.end.filename), /* line number */ @1.end.line )); driver.addSecAction(std::move(rule)); @@ -1168,7 +1168,7 @@ expression: /* path to script */ $1, /* actions */ a, /* transformations */ t, - /* file name */ std::unique_ptr(new std::string(*@1.end.filename)), + /* file name */ std::string(*@1.end.filename), /* line number */ @1.end.line )); @@ -1240,7 +1240,7 @@ expression: | CONFIG_DIR_SEC_MARKER { driver.addSecMarker(modsecurity::utils::string::removeBracketsIfNeeded($1), - /* file name */ std::unique_ptr(new std::string(*@1.end.filename)), + /* file name */ std::string(*@1.end.filename), /* line number */ @1.end.line ); } diff --git a/src/rule_script.h b/src/rule_script.h index 1c22ad60e..d7fb8174b 100644 --- a/src/rule_script.h +++ b/src/rule_script.h @@ -47,9 +47,9 @@ class RuleScript : public RuleWithActions { RuleScript(const std::string &name, std::vector *actions, Transformations *t, - std::unique_ptr fileName, + const std::string &fileName, int lineNumber) - : RuleWithActions(actions, t, std::move(fileName), lineNumber), + : RuleWithActions(actions, t, fileName, lineNumber), m_name(name), m_lua() { } diff --git a/src/rule_with_actions.cc b/src/rule_with_actions.cc index 33f600cf5..8f9eae2f4 100644 --- a/src/rule_with_actions.cc +++ b/src/rule_with_actions.cc @@ -59,9 +59,9 @@ using actions::transformations::Transformation; RuleWithActions::RuleWithActions( Actions *actions, Transformations *transformations, - std::unique_ptr fileName, + const std::string &fileName, int lineNumber) - : Rule(std::move(fileName), lineNumber), + : Rule(fileName, lineNumber), m_rev(""), m_ver(""), m_accuracy(0), diff --git a/src/rule_with_operator.cc b/src/rule_with_operator.cc index b043af5c1..edcde6aa9 100644 --- a/src/rule_with_operator.cc +++ b/src/rule_with_operator.cc @@ -55,7 +55,7 @@ RuleWithOperator::RuleWithOperator(Operator *op, variables::Variables *_variables, std::vector *actions, Transformations *transformations, - std::unique_ptr fileName, + const std::string &fileName, int lineNumber) : RuleWithActions(actions, transformations, std::move(fileName), lineNumber), m_variables(_variables), diff --git a/src/variables/variable.h b/src/variables/variable.h index fc4671bbb..2d8c6ec02 100644 --- a/src/variables/variable.h +++ b/src/variables/variable.h @@ -379,7 +379,7 @@ class VariableMonkeyResolution { static std::string stringMatchResolve(Transaction *t, const std::string &variable) { - std::unique_ptr vv = nullptr; + std::unique_ptr vv; size_t collection = variable.find("."); if (collection == std::string::npos) { collection = variable.find(":");