Skip to content

Commit 3fb71f3

Browse files
author
Felipe Zimmerle
committed
Coding style fixes
1 parent 023e7ac commit 3fb71f3

40 files changed

+589
-660
lines changed

examples/reading_logs_via_rule_message/reading_logs_via_rule_message.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
*
1414
*/
1515

16+
#include <unistd.h>
17+
1618
#include <string>
1719
#include <memory>
1820

19-
#include <unistd.h>
2021

2122
#define NUM_THREADS 100
2223

@@ -151,8 +152,9 @@ class ReadingLogsViaRuleMessage {
151152
dms.rules = rules;
152153

153154
for (i = 0; i < NUM_THREADS; i++) {
154-
pthread_create(&threads[i], NULL, process_request, (void *)&dms);
155-
//process_request((void *)&dms);
155+
pthread_create(&threads[i], NULL, process_request,
156+
reinterpret_cast<void *>(&dms));
157+
// process_request((void *)&dms);
156158
}
157159

158160
usleep(10000);

examples/reading_logs_via_rule_message/simple_request.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,13 @@
2323

2424

2525
int main(int argc, char **argv) {
26-
*argv++;
27-
if (*argv == NULL) {
28-
*argv--;
26+
if (argc < 2) {
2927
std::cout << "Use " << *argv << " test-case-file.conf";
3028
std::cout << std::endl << std::endl;
3129
return -1;
3230
}
3331

32+
*(argv++);
3433
std::string rules(*argv);
3534
ReadingLogsViaRuleMessage rlvrm(request_header, request_uri, request_body,
3635
response_headers, response_body, ip, rules);

examples/simple_example_using_c/basic_rules.conf

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,11 @@ SecRule REQUEST_HEADERS:Content-Type "application/json" \
3535
# to the size of data, with files excluded. You want to keep that value as
3636
# low as practical.
3737
#
38-
SecRequestBodyLimit 13107200
39-
SecRequestBodyNoFilesLimit 131072
4038

4139
# Store up to 128 KB of request body data in memory. When the multipart
4240
# parser reachers this limit, it will start using your hard disk for
4341
# storage. That is slow, but unavoidable.
4442
#
45-
SecRequestBodyInMemoryLimit 131072
4643

4744
# What do do if the request body size is above our configured limit.
4845
# Keep in mind that this setting will automatically be set to ProcessPartial

examples/using_bodies_in_chunks/simple_request.cc

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,20 @@
1313
*
1414
*/
1515

16+
#include <unistd.h>
1617
#include <stdio.h>
1718
#include <string.h>
18-
#include <string>
19-
#include <memory>
2019

21-
#include <unistd.h>
2220

2321
#include <modsecurity/modsecurity.h>
2422
#include <modsecurity/rules.h>
2523
#include <modsecurity/rule_message.h>
2624

2725

26+
#include <string>
27+
#include <memory>
28+
29+
2830

2931
char request_uri[] = "/test.pl?param1=test&para2=test2";
3032

@@ -85,8 +87,7 @@ static void logCb(void *data, const void *ruleMessagev) {
8587
}
8688
}
8789

88-
int process_intervention(modsecurity::Transaction *transaction)
89-
{
90+
int process_intervention(modsecurity::Transaction *transaction) {
9091
modsecurity::ModSecurityIntervention intervention;
9192
intervention.status = 200;
9293
intervention.url = NULL;
@@ -105,17 +106,15 @@ int process_intervention(modsecurity::Transaction *transaction)
105106
free(intervention.log);
106107
intervention.log = NULL;
107108

108-
if (intervention.url != NULL)
109-
{
109+
if (intervention.url != NULL) {
110110
std::cout << "Intervention, redirect to: " << intervention.url;
111111
std::cout << " with status code: " << intervention.status << std::endl;
112112
free(intervention.url);
113113
intervention.url = NULL;
114114
return intervention.status;
115115
}
116116

117-
if (intervention.status != 200)
118-
{
117+
if (intervention.status != 200) {
119118
std::cout << "Intervention, returning code: " << intervention.status;
120119
std::cout << std::endl;
121120
return intervention.status;
@@ -129,13 +128,12 @@ int main(int argc, char **argv) {
129128
modsecurity::Rules *rules;
130129
modsecurity::ModSecurityIntervention it;
131130

132-
*argv++;
133-
if (*argv == NULL) {
134-
*argv--;
131+
if (argc < 2) {
135132
std::cout << "Use " << *argv << " test-case-file.conf";
136133
std::cout << std::endl << std::endl;
137134
return -1;
138135
}
136+
*(argv++);
139137

140138
std::string rules_arg(*argv);
141139

headers/modsecurity/audit_log.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ class AuditLog {
206206
int m_directoryPermission;
207207
int m_defaultDirectoryPermission = 0750;
208208

209-
private:
209+
private:
210210
AuditLogStatus m_status;
211211

212212
AuditLogType m_type;

headers/modsecurity/collection/variable.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <iostream>
2020
#include <memory>
2121
#include <list>
22+
#include <utility>
2223
#endif
2324

2425
#include "modsecurity/variable_origin.h"
@@ -51,7 +52,7 @@ class Variable {
5152
m_key(""),
5253
m_value("") { }
5354

54-
Variable(const Variable *o) :
55+
explicit Variable(const Variable *o) :
5556
m_key(""),
5657
m_value("") {
5758
m_key.assign(o->m_key);

headers/modsecurity/rule.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ class Rule {
5252
explicit Rule(std::string marker);
5353
~Rule();
5454

55-
virtual bool evaluate(Transaction *transaction, std::shared_ptr<RuleMessage> rm);
55+
virtual bool evaluate(Transaction *transaction,
56+
std::shared_ptr<RuleMessage> rm);
5657
bool evaluateActions(Transaction *transaction);
5758
std::vector<std::unique_ptr<collection::Variable>>
5859
getFinalVars(Transaction *trasn);
@@ -108,7 +109,7 @@ class Rule {
108109
operators::Operator *m_op;
109110
int m_phase;
110111
std::string m_rev;
111-
long m_ruleId;
112+
int64_t m_ruleId;
112113
bool m_secMarker;
113114
std::vector<Variables::Variable *> *m_variables;
114115
std::string m_ver;

headers/modsecurity/rule_message.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ class RuleMessage {
7676
return RuleMessage::log(this, props, responseCode);
7777
}
7878
std::string errorLog() {
79-
return RuleMessage::log(this, ClientLogMessageInfo | ErrorLogTailLogMessageInfo);
79+
return RuleMessage::log(this,
80+
ClientLogMessageInfo | ErrorLogTailLogMessageInfo);
8081
}
8182

8283
static std::string log(const RuleMessage *rm, int props, int code);

headers/modsecurity/rules_exceptions.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,26 +48,29 @@ class RulesExceptions {
4848
bool addRange(int a, int b);
4949
bool addNumber(int a);
5050
bool contains(int a);
51-
bool merge(RulesExceptions& from);
51+
bool merge(RulesExceptions *from);
5252

5353
bool loadRemoveRuleByMsg(const std::string &msg, std::string *error);
5454
bool loadRemoveRuleByTag(const std::string &msg, std::string *error);
5555

5656
bool loadUpdateTargetByMsg(const std::string &msg,
57-
std::unique_ptr<std::vector<std::unique_ptr<Variables::Variable> > > var,
57+
std::unique_ptr<std::vector<std::unique_ptr<Variables::Variable> > > v,
5858
std::string *error);
5959

6060
bool loadUpdateTargetByTag(const std::string &tag,
61-
std::unique_ptr<std::vector<std::unique_ptr<Variables::Variable> > > var,
61+
std::unique_ptr<std::vector<std::unique_ptr<Variables::Variable> > > v,
6262
std::string *error);
6363

6464
bool loadUpdateTargetById(double id,
65-
std::unique_ptr<std::vector<std::unique_ptr<Variables::Variable> > > var,
65+
std::unique_ptr<std::vector<std::unique_ptr<Variables::Variable> > > v,
6666
std::string *error);
6767

68-
std::unordered_multimap<std::shared_ptr<std::string>, std::unique_ptr<Variables::Variable>> m_variable_update_target_by_tag;
69-
std::unordered_multimap<std::shared_ptr<std::string>, std::unique_ptr<Variables::Variable>> m_variable_update_target_by_msg;
70-
std::unordered_multimap<double, std::unique_ptr<Variables::Variable>> m_variable_update_target_by_id;
68+
std::unordered_multimap<std::shared_ptr<std::string>,
69+
std::unique_ptr<Variables::Variable>> m_variable_update_target_by_tag;
70+
std::unordered_multimap<std::shared_ptr<std::string>,
71+
std::unique_ptr<Variables::Variable>> m_variable_update_target_by_msg;
72+
std::unordered_multimap<double,
73+
std::unique_ptr<Variables::Variable>> m_variable_update_target_by_id;
7174
std::list<std::string> m_remove_rule_by_msg;
7275
std::list<std::string> m_remove_rule_by_tag;
7376

headers/modsecurity/rules_properties.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ class RulesProperties {
355355
to->m_httpblKey.m_set = from->m_httpblKey.m_set;
356356
}
357357

358-
to->m_exceptions.merge(from->m_exceptions);
358+
to->m_exceptions.merge(&from->m_exceptions);
359359

360360
to->m_components.insert(to->m_components.end(),
361361
from->m_components.begin(), from->m_components.end());

0 commit comments

Comments
 (0)