@@ -51,25 +51,13 @@ namespace modsecurity {
5151namespace audit_log {
5252
5353
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 ;
6755
6856
6957AuditLog::~AuditLog () {
7058 if (m_writer) {
7159 delete m_writer;
72- m_writer = NULL ;
60+ m_writer = nullptr ;
7361 }
7462}
7563
@@ -108,35 +96,42 @@ bool AuditLog::setStatus(AuditLogStatus status) {
10896}
10997
11098
111- bool AuditLog::setRelevantStatus (const std::basic_string< char >& status) {
99+ bool AuditLog::setRelevantStatus (std::string_view status) {
112100 this ->m_relevant = std::string (status);
113101 return true ;
114102}
115103
116104
117- bool AuditLog::setStorageDir (const std::basic_string< char >& path) {
105+ bool AuditLog::setStorageDir (std::string_view path) {
118106 this ->m_storage_dir = path;
119107 return true ;
120108}
121109
122110
123- bool AuditLog::setFilePath1 (const std::basic_string< char >& path) {
111+ bool AuditLog::setFilePath1 (std::string_view path) {
124112 this ->m_path1 = path;
125113 return true ;
126114}
127115
128116
129- bool AuditLog::setFilePath2 (const std::basic_string< char >& path) {
117+ bool AuditLog::setFilePath2 (std::string_view path) {
130118 this ->m_path2 = path;
131119 return true ;
132120}
133121
122+
123+ bool AuditLog::setPrefix (std::string_view prefix) {
124+ this ->m_prefix = prefix;
125+ return true ;
126+ }
127+
128+
134129bool AuditLog::setFormat (AuditLogFormat fmt) {
135130 this ->m_format = fmt;
136131 return true ;
137132}
138133
139- int AuditLog::addParts (int parts, const std::string& new_parts) {
134+ int AuditLog::addParts (int parts, std::string_view new_parts) {
140135 PARTS_CONSTAINS (' A' , AAuditLogPart)
141136 PARTS_CONSTAINS (' B' , BAuditLogPart)
142137 PARTS_CONSTAINS (' C' , CAuditLogPart)
@@ -154,7 +149,7 @@ int AuditLog::addParts(int parts, const std::string& new_parts) {
154149}
155150
156151
157- int AuditLog::removeParts (int parts, const std::string& new_parts) {
152+ int AuditLog::removeParts (int parts, std::string_view new_parts) {
158153 PARTS_CONSTAINS_REM (' A' , AAuditLogPart)
159154 PARTS_CONSTAINS_REM (' B' , BAuditLogPart)
160155 PARTS_CONSTAINS_REM (' C' , CAuditLogPart)
@@ -172,7 +167,7 @@ int AuditLog::removeParts(int parts, const std::string& new_parts) {
172167}
173168
174169
175- bool AuditLog::setParts (const std::basic_string< char >& new_parts) {
170+ bool AuditLog::setParts (std::string_view new_parts) {
176171 int parts = 0 ;
177172
178173 PARTS_CONSTAINS (' A' , AAuditLogPart)
@@ -208,15 +203,14 @@ bool AuditLog::setType(AuditLogType audit_type) {
208203}
209204
210205
211-
212206bool AuditLog::init (std::string *error) {
213207 audit_log::writer::Writer *tmp_writer;
214208
215209 if ((m_status == OffAuditLogStatus || m_status == NotSetLogStatus)
216210 && !m_ctlAuditEngineActive) {
217211 if (m_writer) {
218212 delete m_writer;
219- m_writer = NULL ;
213+ m_writer = nullptr ;
220214 }
221215 return true ;
222216 }
@@ -234,7 +228,7 @@ bool AuditLog::init(std::string *error) {
234228 tmp_writer = new audit_log::writer::Serial (this );
235229 }
236230
237- if (tmp_writer == NULL ) {
231+ if (tmp_writer == nullptr ) {
238232 error->assign (" Writer memory alloc failed!" );
239233 return false ;
240234 }
@@ -312,7 +306,7 @@ bool AuditLog::saveIfRelevant(Transaction *transaction, int parts) {
312306 }
313307 ms_dbg_a (transaction, 5 , " Saving this request as part " \
314308 " of the audit logs." );
315- if (m_writer == NULL ) {
309+ if (m_writer == nullptr ) {
316310 ms_dbg_a (transaction, 1 , " Internal error, audit log writer is null" );
317311 } else {
318312 std::string error;
@@ -337,6 +331,7 @@ bool AuditLog::merge(AuditLog *from, std::string *error) {
337331 AL_MERGE_STRING_CONF (from->m_path2 , m_path2);
338332 AL_MERGE_STRING_CONF (from->m_storage_dir , m_storage_dir);
339333 AL_MERGE_STRING_CONF (from->m_relevant , m_relevant);
334+ AL_MERGE_STRING_CONF (from->m_prefix , m_prefix);
340335
341336 if (from->m_filePermission != -1 ) {
342337 m_filePermission = from->m_filePermission ;
0 commit comments