mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 19:24:29 +03:00
Fix rules dump
The unique pointer for file name was being used multiple times on SecMarker.
This commit is contained in:
@@ -68,7 +68,7 @@ using MatchActions = std::vector<actions::Action *>;
|
||||
class Rule {
|
||||
public:
|
||||
Rule(std::unique_ptr<std::string> fileName, int lineNumber)
|
||||
: m_fileName(std::move(fileName)),
|
||||
: m_fileName(std::make_shared<std::string>(*fileName)),
|
||||
m_lineNumber(lineNumber),
|
||||
m_phase(modsecurity::Phases::RequestHeadersPhase) {
|
||||
}
|
||||
@@ -103,7 +103,10 @@ class Rule {
|
||||
void setPhase(int phase) { m_phase = phase; }
|
||||
|
||||
virtual std::string getReference() {
|
||||
return *m_fileName + ":" + std::to_string(m_lineNumber);
|
||||
if (m_fileName) {
|
||||
return *m_fileName + ":" + std::to_string(m_lineNumber);
|
||||
}
|
||||
return "<<no file>>:" + std::to_string(m_lineNumber);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -44,6 +44,16 @@ class RuleMarker : public Rule {
|
||||
: Rule(std::move(fileName), lineNumber),
|
||||
m_name(std::make_shared<std::string>(name)) { }
|
||||
|
||||
RuleMarker(const RuleMarker& r) :
|
||||
Rule(r),
|
||||
m_name(r.m_name)
|
||||
{ }
|
||||
|
||||
RuleMarker &operator =(const RuleMarker& r) {
|
||||
Rule::operator = (r);
|
||||
m_name = r.m_name;
|
||||
return *this;
|
||||
}
|
||||
|
||||
virtual bool evaluate(Transaction *transaction,
|
||||
std::shared_ptr<RuleMessage> rm) override {
|
||||
|
@@ -46,6 +46,15 @@ class RuleUnconditional : public RuleWithActions {
|
||||
int lineNumber)
|
||||
: RuleWithActions(actions, transformations, std::move(fileName), lineNumber) { }
|
||||
|
||||
RuleUnconditional(const RuleUnconditional& r)
|
||||
: RuleWithActions(r)
|
||||
{ }
|
||||
|
||||
RuleUnconditional &operator=(const RuleUnconditional& r) {
|
||||
RuleWithActions::operator = (r);
|
||||
return *this;
|
||||
}
|
||||
|
||||
virtual bool evaluate(Transaction *transaction, std::shared_ptr<RuleMessage> ruleMessage) override;
|
||||
|
||||
private:
|
||||
|
Reference in New Issue
Block a user