@@ -51,25 +51,13 @@ namespace modsecurity {
51
51
namespace audit_log {
52
52
53
53
54
- AuditLog::AuditLog ()
55
- : m_path1(" " ),
56
- m_path2 (" " ),
57
- m_storage_dir(" " ),
58
- m_format(NotSetAuditLogFormat),
59
- m_parts(-1 ),
60
- m_filePermission(-1 ),
61
- m_directoryPermission(-1 ),
62
- m_status(NotSetLogStatus),
63
- m_type(NotSetAuditLogType),
64
- m_relevant(" " ),
65
- m_writer(NULL ),
66
- m_ctlAuditEngineActive(false ) { }
54
+ AuditLog::AuditLog () = default ;
67
55
68
56
69
57
AuditLog::~AuditLog () {
70
58
if (m_writer) {
71
59
delete m_writer;
72
- m_writer = NULL ;
60
+ m_writer = nullptr ;
73
61
}
74
62
}
75
63
@@ -108,35 +96,42 @@ bool AuditLog::setStatus(AuditLogStatus status) {
108
96
}
109
97
110
98
111
- bool AuditLog::setRelevantStatus (const std::basic_string< char >& status) {
99
+ bool AuditLog::setRelevantStatus (std::string_view status) {
112
100
this ->m_relevant = std::string (status);
113
101
return true ;
114
102
}
115
103
116
104
117
- bool AuditLog::setStorageDir (const std::basic_string< char >& path) {
105
+ bool AuditLog::setStorageDir (std::string_view path) {
118
106
this ->m_storage_dir = path;
119
107
return true ;
120
108
}
121
109
122
110
123
- bool AuditLog::setFilePath1 (const std::basic_string< char >& path) {
111
+ bool AuditLog::setFilePath1 (std::string_view path) {
124
112
this ->m_path1 = path;
125
113
return true ;
126
114
}
127
115
128
116
129
- bool AuditLog::setFilePath2 (const std::basic_string< char >& path) {
117
+ bool AuditLog::setFilePath2 (std::string_view path) {
130
118
this ->m_path2 = path;
131
119
return true ;
132
120
}
133
121
122
+
123
+ bool AuditLog::setPrefix (std::string_view prefix) {
124
+ this ->m_prefix = prefix;
125
+ return true ;
126
+ }
127
+
128
+
134
129
bool AuditLog::setFormat (AuditLogFormat fmt) {
135
130
this ->m_format = fmt;
136
131
return true ;
137
132
}
138
133
139
- int AuditLog::addParts (int parts, const std::string& new_parts) {
134
+ int AuditLog::addParts (int parts, std::string_view new_parts) {
140
135
PARTS_CONSTAINS (' A' , AAuditLogPart)
141
136
PARTS_CONSTAINS (' B' , BAuditLogPart)
142
137
PARTS_CONSTAINS (' C' , CAuditLogPart)
@@ -154,7 +149,7 @@ int AuditLog::addParts(int parts, const std::string& new_parts) {
154
149
}
155
150
156
151
157
- int AuditLog::removeParts (int parts, const std::string& new_parts) {
152
+ int AuditLog::removeParts (int parts, std::string_view new_parts) {
158
153
PARTS_CONSTAINS_REM (' A' , AAuditLogPart)
159
154
PARTS_CONSTAINS_REM (' B' , BAuditLogPart)
160
155
PARTS_CONSTAINS_REM (' C' , CAuditLogPart)
@@ -172,7 +167,7 @@ int AuditLog::removeParts(int parts, const std::string& new_parts) {
172
167
}
173
168
174
169
175
- bool AuditLog::setParts (const std::basic_string< char >& new_parts) {
170
+ bool AuditLog::setParts (std::string_view new_parts) {
176
171
int parts = 0 ;
177
172
178
173
PARTS_CONSTAINS (' A' , AAuditLogPart)
@@ -208,15 +203,14 @@ bool AuditLog::setType(AuditLogType audit_type) {
208
203
}
209
204
210
205
211
-
212
206
bool AuditLog::init (std::string *error) {
213
207
audit_log::writer::Writer *tmp_writer;
214
208
215
209
if ((m_status == OffAuditLogStatus || m_status == NotSetLogStatus)
216
210
&& !m_ctlAuditEngineActive) {
217
211
if (m_writer) {
218
212
delete m_writer;
219
- m_writer = NULL ;
213
+ m_writer = nullptr ;
220
214
}
221
215
return true ;
222
216
}
@@ -234,7 +228,7 @@ bool AuditLog::init(std::string *error) {
234
228
tmp_writer = new audit_log::writer::Serial (this );
235
229
}
236
230
237
- if (tmp_writer == NULL ) {
231
+ if (tmp_writer == nullptr ) {
238
232
error->assign (" Writer memory alloc failed!" );
239
233
return false ;
240
234
}
@@ -312,7 +306,7 @@ bool AuditLog::saveIfRelevant(Transaction *transaction, int parts) {
312
306
}
313
307
ms_dbg_a (transaction, 5 , " Saving this request as part " \
314
308
" of the audit logs." );
315
- if (m_writer == NULL ) {
309
+ if (m_writer == nullptr ) {
316
310
ms_dbg_a (transaction, 1 , " Internal error, audit log writer is null" );
317
311
} else {
318
312
std::string error;
@@ -337,6 +331,7 @@ bool AuditLog::merge(AuditLog *from, std::string *error) {
337
331
AL_MERGE_STRING_CONF (from->m_path2 , m_path2);
338
332
AL_MERGE_STRING_CONF (from->m_storage_dir , m_storage_dir);
339
333
AL_MERGE_STRING_CONF (from->m_relevant , m_relevant);
334
+ AL_MERGE_STRING_CONF (from->m_prefix , m_prefix);
340
335
341
336
if (from->m_filePermission != -1 ) {
342
337
m_filePermission = from->m_filePermission ;
0 commit comments