Skip to content

Commit 4b03e89

Browse files
committed
Cosmetics: Defining a type for RuleId
1 parent 99350b8 commit 4b03e89

File tree

5 files changed

+10
-6
lines changed

5 files changed

+10
-6
lines changed

headers/modsecurity/modsecurity.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ namespace modsecurity {
9595
*/
9696
using ModSecString = std::string;
9797

98+
using RuleId = int64_t;
99+
98100
/**
99101
*
100102
* The Phases enumerator consists in mapping the different stages of a

headers/modsecurity/rules.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ class Rules {
4545
void dump() const;
4646

4747
int append(Rules *from,
48-
const std::vector<int64_t> &ids,
48+
const std::vector<RuleId> &ids,
4949
std::ostringstream *err);
5050

5151
bool insert(const std::shared_ptr<Rule> &rule);
5252

5353
bool insert(std::shared_ptr<Rule> rule,
54-
const std::vector<int64_t> *ids,
54+
const std::vector<RuleId> *ids,
5555
std::ostringstream *err);
5656

5757
size_t size() const;

src/rule_with_actions.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ class RuleWithActions : public Rule {
408408
return dst;
409409
}
410410

411-
inline int64_t getId() const { return m_ruleId; }
411+
inline RuleId getId() const { return m_ruleId; }
412412
void setId(int id) {
413413
m_ruleId = id;
414414
}
@@ -443,7 +443,7 @@ class RuleWithActions : public Rule {
443443
}
444444

445445
private:
446-
int64_t m_ruleId;
446+
RuleId m_ruleId;
447447

448448
std::shared_ptr<RuleWithActions> m_chainedRuleChild;
449449
RuleWithActions *m_chainedRuleParent;

src/rules.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
namespace modsecurity {
2121

2222

23-
int Rules::append(Rules *from, const std::vector<int64_t> &ids, std::ostringstream *err) {
23+
int Rules::append(Rules *from, const std::vector<RuleId> &ids, std::ostringstream *err) {
2424
size_t j = 0;
2525
for (; j < from->size(); j++) {
2626
RuleWithActions *rule = dynamic_cast<RuleWithActions*>(from->at(j).get());
@@ -42,7 +42,7 @@ bool Rules::insert(const std::shared_ptr<Rule> &rule) {
4242
}
4343

4444

45-
bool Rules::insert(std::shared_ptr<Rule> rule, const std::vector<int64_t> *ids, std::ostringstream *err) {
45+
bool Rules::insert(std::shared_ptr<Rule> rule, const std::vector<RuleId> *ids, std::ostringstream *err) {
4646
RuleWithActions*r = dynamic_cast<RuleWithActions*>(rule.get());
4747
if (r && ids != nullptr
4848
&& std::binary_search(ids->begin(), ids->end(), r->getId())) {

test/cppcheck_suppressions.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ duplicateBranch:src/request_body_processor/multipart.cc:93
5656
danglingTempReference:src/modsecurity.cc:206
5757
knownConditionTrueFalse:src/operators/validate_url_encoding.cc:77
5858
knownConditionTrueFalse:src/operators/verify_svnr.cc:88
59+
noConstructor:src/actions/rule_id.h:33
60+
functionStatic:src/actions/rule_id.h:35
5961

6062
noExplicitConstructor:seclang-parser.hh
6163
constParameter:seclang-parser.hh

0 commit comments

Comments
 (0)