Skip to content

Commit d3512e5

Browse files
committed
Makes RuleWithActions const in run time operations
1 parent 2408006 commit d3512e5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+118
-118
lines changed

headers/modsecurity/rule.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class Rule {
6363
return *this;
6464
}
6565

66-
virtual bool evaluate(Transaction *transaction) = 0;
66+
virtual bool evaluate(Transaction *transaction) const = 0;
6767

6868
std::shared_ptr<std::string> getFileName() const {
6969
return m_fileName;
@@ -76,11 +76,11 @@ class Rule {
7676
int getPhase() const { return m_phase; }
7777
void setPhase(int phase) { m_phase = phase; }
7878

79-
virtual std::string getReference() {
79+
virtual std::string getReference() const {
8080
return *m_fileName + ":" + std::to_string(m_lineNumber);
8181
}
8282

83-
virtual void dump(std::stringstream &out) {
83+
virtual void dump(std::stringstream &out) const {
8484
out << getOriginInTextFormat() << std::endl;
8585
}
8686

headers/modsecurity/rule_message.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ class RuleMessage {
113113
static std::string _details(const RuleMessage *rm);
114114
static std::string _errorLogTail(const RuleMessage *rm);
115115

116-
RuleWithActions *getRule() const;
117-
void setRule(RuleWithActions *rule);
116+
const RuleWithActions *getRule() const;
117+
void setRule(const RuleWithActions *rule);
118118
bool isSettle() const;
119119
int getRuleId() const;
120120
int getPhase() const;
@@ -144,7 +144,7 @@ class RuleMessage {
144144

145145
private:
146146
Transaction *m_transaction;
147-
RuleWithActions *m_rule;
147+
const RuleWithActions *m_rule;
148148
};
149149

150150

headers/modsecurity/transaction.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ class TransactionRuleMessageManagement {
328328
RuleMessage *messageGetLast();
329329
void messageNew();
330330

331-
void logMatchLastRuleOnTheChain(RuleWithActions *rule);
331+
void logMatchLastRuleOnTheChain(const RuleWithActions *rule);
332332

333333
std::list<RuleMessage *> messageGetAll();
334334

src/engine/lua.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ class LuaScriptBlob {
3434
public:
3535
LuaScriptBlob() :
3636
m_data(NULL),
37-
m_len(0) { }
37+
m_len(0)
38+
{ }
3839

3940
~LuaScriptBlob() {
4041
if (m_data) {

src/operators/begins_with.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace operators {
2525

2626

2727
bool BeginsWith::evaluate(Transaction *transaction,
28-
RuleWithActions *rule,
28+
const RuleWithActions *rule,
2929
const bpstd::string_view &str,
3030
RuleMessage *ruleMessage) {
3131
std::string p(m_string->evaluate(transaction));

src/operators/begins_with.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class BeginsWith : public Operator {
3333
: Operator("BeginsWith", std::move(param)) { }
3434

3535
bool evaluate(Transaction *transaction,
36-
RuleWithActions *rule,
36+
const RuleWithActions *rule,
3737
const bpstd::string_view &input,
3838
RuleMessage *ruleMessage) override;
3939
};

src/operators/contains.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace modsecurity {
2222
namespace operators {
2323

2424
bool Contains::evaluate(Transaction *transaction,
25-
RuleWithActions *rule,
25+
const RuleWithActions *rule,
2626
const bpstd::string_view &input,
2727
RuleMessage *ruleMessage) {
2828
std::string p(m_string->evaluate(transaction));

src/operators/contains.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Contains : public Operator {
3636
: Operator("Contains", std::move(param)) { };
3737

3838
bool evaluate(Transaction *transaction,
39-
RuleWithActions *rule,
39+
const RuleWithActions *rule,
4040
const bpstd::string_view &input,
4141
RuleMessage *ruleMessage) override;
4242
};

src/operators/contains_word.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ bool ContainsWord::acceptableChar(const bpstd::string_view &a, size_t pos) {
3737
}
3838

3939
bool ContainsWord::evaluate(Transaction *transaction,
40-
RuleWithActions *rule,
40+
const RuleWithActions *rule,
4141
const bpstd::string_view &inputView,
4242
RuleMessage *ruleMessage) {
4343
std::string paramTarget(m_string->evaluate(transaction));

src/operators/contains_word.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class ContainsWord : public Operator {
3333
: Operator("ContainsWord", std::move(param)) { }
3434

3535
bool evaluate(Transaction *transaction,
36-
RuleWithActions *rule,
36+
const RuleWithActions *rule,
3737
const bpstd::string_view &input,
3838
RuleMessage *ruleMessage) override;
3939

0 commit comments

Comments
 (0)