Makes m_fileName a shared pointer

This commit is contained in:
Felipe Zimmerle 2019-01-22 16:07:47 -03:00
parent 14b2bd77a0
commit 343b86c2a7
No known key found for this signature in database
GPG Key ID: E6DFB08CE8B11277
8 changed files with 18 additions and 18 deletions

View File

@ -54,7 +54,7 @@ class Rule {
Rule(operators::Operator *_op, Rule(operators::Operator *_op,
variables::Variables *_variables, variables::Variables *_variables,
std::vector<actions::Action *> *_actions, std::vector<actions::Action *> *_actions,
std::string fileName, std::unique_ptr<std::string> fileName,
int lineNumber); int lineNumber);
explicit Rule(const std::string &marker); explicit Rule(const std::string &marker);
virtual ~Rule(); virtual ~Rule();
@ -128,7 +128,7 @@ class Rule {
operators::Operator *m_op; operators::Operator *m_op;
std::unique_ptr<Rule> m_chainedRuleChild; std::unique_ptr<Rule> m_chainedRuleChild;
Rule *m_chainedRuleParent; Rule *m_chainedRuleParent;
std::string m_fileName; std::shared_ptr<std::string> m_fileName;
std::string m_marker; std::string m_marker;
std::string m_rev; std::string m_rev;
std::string m_ver; std::string m_ver;

View File

@ -104,7 +104,7 @@ class RuleMessage {
std::string m_reference; std::string m_reference;
std::string m_rev; std::string m_rev;
Rule *m_rule; Rule *m_rule;
std::string m_ruleFile; std::shared_ptr<std::string> m_ruleFile;
int m_ruleId; int m_ruleId;
int m_ruleLine; int m_ruleLine;
bool m_saveMessage; bool m_saveMessage;

View File

@ -2318,7 +2318,7 @@ namespace yy {
/* op */ op, /* op */ op,
/* variables */ v, /* variables */ v,
/* actions */ a, /* actions */ a,
/* file name */ *yystack_[3].location.end.filename, /* file name */ std::unique_ptr<std::string>(new std::string(*yystack_[3].location.end.filename)),
/* line number */ yystack_[3].location.end.line /* line number */ yystack_[3].location.end.line
)); ));
@ -2341,7 +2341,7 @@ namespace yy {
/* op */ yystack_[0].value.as < std::unique_ptr<Operator> > ().release(), /* op */ yystack_[0].value.as < std::unique_ptr<Operator> > ().release(),
/* variables */ v, /* variables */ v,
/* actions */ NULL, /* actions */ NULL,
/* file name */ *yystack_[2].location.end.filename, /* file name */ std::unique_ptr<std::string>(new std::string(*yystack_[2].location.end.filename)),
/* line number */ yystack_[2].location.end.line /* line number */ yystack_[2].location.end.line
)); ));
if (driver.addSecRule(std::move(rule)) == false) { if (driver.addSecRule(std::move(rule)) == false) {
@ -2362,7 +2362,7 @@ namespace yy {
/* op */ NULL, /* op */ NULL,
/* variables */ NULL, /* variables */ NULL,
/* actions */ a, /* actions */ a,
/* file name */ *yystack_[1].location.end.filename, /* file name */ std::unique_ptr<std::string>(new std::string(*yystack_[1].location.end.filename)),
/* line number */ yystack_[1].location.end.line /* line number */ yystack_[1].location.end.line
)); ));
driver.addSecAction(std::move(rule)); driver.addSecAction(std::move(rule));
@ -2381,7 +2381,7 @@ namespace yy {
std::unique_ptr<RuleScript> r(new RuleScript( std::unique_ptr<RuleScript> r(new RuleScript(
/* path to script */ yystack_[1].value.as < std::string > (), /* path to script */ yystack_[1].value.as < std::string > (),
/* actions */ a, /* actions */ a,
/* file name */ *yystack_[1].location.end.filename, /* file name */ std::unique_ptr<std::string>(new std::string(*yystack_[1].location.end.filename)),
/* line number */ yystack_[1].location.end.line /* line number */ yystack_[1].location.end.line
)); ));

View File

@ -1080,7 +1080,7 @@ expression:
/* op */ op, /* op */ op,
/* variables */ v, /* variables */ v,
/* actions */ a, /* actions */ a,
/* file name */ *@1.end.filename, /* file name */ std::unique_ptr<std::string>(new std::string(*@1.end.filename)),
/* line number */ @1.end.line /* line number */ @1.end.line
)); ));
@ -1099,7 +1099,7 @@ expression:
/* op */ $3.release(), /* op */ $3.release(),
/* variables */ v, /* variables */ v,
/* actions */ NULL, /* actions */ NULL,
/* file name */ *@1.end.filename, /* file name */ std::unique_ptr<std::string>(new std::string(*@1.end.filename)),
/* line number */ @1.end.line /* line number */ @1.end.line
)); ));
if (driver.addSecRule(std::move(rule)) == false) { if (driver.addSecRule(std::move(rule)) == false) {
@ -1116,7 +1116,7 @@ expression:
/* op */ NULL, /* op */ NULL,
/* variables */ NULL, /* variables */ NULL,
/* actions */ a, /* actions */ a,
/* file name */ *@1.end.filename, /* file name */ std::unique_ptr<std::string>(new std::string(*@1.end.filename)),
/* line number */ @1.end.line /* line number */ @1.end.line
)); ));
driver.addSecAction(std::move(rule)); driver.addSecAction(std::move(rule));
@ -1131,7 +1131,7 @@ expression:
std::unique_ptr<RuleScript> r(new RuleScript( std::unique_ptr<RuleScript> r(new RuleScript(
/* path to script */ $1, /* path to script */ $1,
/* actions */ a, /* actions */ a,
/* file name */ *@1.end.filename, /* file name */ std::unique_ptr<std::string>(new std::string(*@1.end.filename)),
/* line number */ @1.end.line /* line number */ @1.end.line
)); ));

View File

@ -70,7 +70,7 @@ Rule::Rule(const std::string &marker)
m_op(NULL), m_op(NULL),
m_chainedRuleChild(nullptr), m_chainedRuleChild(nullptr),
m_chainedRuleParent(NULL), m_chainedRuleParent(NULL),
m_fileName(""), /* m_fileName(""), */
m_marker(marker), m_marker(marker),
m_rev(""), m_rev(""),
m_ver(""), m_ver(""),
@ -83,7 +83,7 @@ Rule::Rule(const std::string &marker)
Rule::Rule(Operator *_op, Rule::Rule(Operator *_op,
variables::Variables *_variables, variables::Variables *_variables,
std::vector<Action *> *actions, std::vector<Action *> *actions,
std::string fileName, std::unique_ptr<std::string> fileName,
int lineNumber) int lineNumber)
: m_theDisruptiveAction(nullptr), : m_theDisruptiveAction(nullptr),
m_logData(nullptr), m_logData(nullptr),
@ -103,7 +103,7 @@ Rule::Rule(Operator *_op,
m_op(_op), m_op(_op),
m_chainedRuleChild(nullptr), m_chainedRuleChild(nullptr),
m_chainedRuleParent(NULL), m_chainedRuleParent(NULL),
m_fileName(fileName), m_fileName(std::move(fileName)),
m_marker(""), m_marker(""),
m_rev(""), m_rev(""),
m_ver(""), m_ver(""),

View File

@ -26,7 +26,7 @@ namespace modsecurity {
std::string RuleMessage::_details(const RuleMessage *rm) { std::string RuleMessage::_details(const RuleMessage *rm) {
std::string msg; std::string msg;
msg.append(" [file \"" + std::string(rm->m_ruleFile) + "\"]"); msg.append(" [file \"" + std::string(*rm->m_ruleFile.get()) + "\"]");
msg.append(" [line \"" + std::to_string(rm->m_ruleLine) + "\"]"); msg.append(" [line \"" + std::to_string(rm->m_ruleLine) + "\"]");
msg.append(" [id \"" + std::to_string(rm->m_ruleId) + "\"]"); msg.append(" [id \"" + std::to_string(rm->m_ruleId) + "\"]");
msg.append(" [rev \"" + rm->m_rev + "\"]"); msg.append(" [rev \"" + rm->m_rev + "\"]");

View File

@ -46,9 +46,9 @@ class RuleScript : public Rule {
public: public:
RuleScript(const std::string &name, RuleScript(const std::string &name,
std::vector<Action *> *actions, std::vector<Action *> *actions,
const std::string &fileName, std::unique_ptr<std::string> fileName,
int lineNumber) int lineNumber)
: Rule(NULL, NULL, actions, fileName, lineNumber), : Rule(NULL, NULL, actions, std::move(fileName), lineNumber),
m_name(name) { } m_name(name) { }
bool init(std::string *err); bool init(std::string *err);

View File

@ -1764,7 +1764,7 @@ std::string Transaction::toJSON(int parts) {
LOGFY_ADD("match", a.m_match.c_str()); LOGFY_ADD("match", a.m_match.c_str());
LOGFY_ADD("reference", a.m_reference.c_str()); LOGFY_ADD("reference", a.m_reference.c_str());
LOGFY_ADD("ruleId", std::to_string(a.m_ruleId).c_str()); LOGFY_ADD("ruleId", std::to_string(a.m_ruleId).c_str());
LOGFY_ADD("file", a.m_ruleFile.c_str()); LOGFY_ADD("file", a.m_ruleFile->c_str());
LOGFY_ADD("lineNumber", std::to_string(a.m_ruleLine).c_str()); LOGFY_ADD("lineNumber", std::to_string(a.m_ruleLine).c_str());
LOGFY_ADD("data", a.m_data.c_str()); LOGFY_ADD("data", a.m_data.c_str());
LOGFY_ADD("severity", std::to_string(a.m_severity).c_str()); LOGFY_ADD("severity", std::to_string(a.m_severity).c_str());