Skip to content

Commit 0470168

Browse files
martinhsvzimmerle
authored andcommitted
Fix: audit log data omitted when nolog,auditlog
1 parent 6624a18 commit 0470168

File tree

4 files changed

+57
-0
lines changed

4 files changed

+57
-0
lines changed

CHANGES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
v3.0.4 - YYYY-MMM-DD (to be released)
22
-------------------------------------
33

4+
- Fix: audit log data omitted when nolog,auditlog
5+
[@martinhsv]
46
- Fix: ModSecurity 3.x inspectFile operator does not pass
57
FILES_TMPNAMES parameter to lua engine
68
[Issue #2204, #2205 - @kadirerdogan]

src/actions/audit_log.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include "modsecurity/transaction.h"
2323
#include "modsecurity/rule_message.h"
24+
#include "modsecurity/rules.h"
2425

2526
namespace modsecurity {
2627
namespace actions {
@@ -29,6 +30,9 @@ namespace actions {
2930
bool AuditLog::evaluate(Rule *rule, Transaction *transaction,
3031
std::shared_ptr<RuleMessage> rm) {
3132
rm->m_noAuditLog = false;
33+
ms_dbg_a(transaction, 9, "Saving transaction to logs");
34+
rm->m_saveMessage = true;
35+
3236
return true;
3337
}
3438

src/actions/no_audit_log.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ namespace actions {
2929
bool NoAuditLog::evaluate(Rule *rule, Transaction *transaction,
3030
std::shared_ptr<RuleMessage> rm) {
3131
rm->m_noAuditLog = true;
32+
rm->m_saveMessage = false;
33+
3234
return true;
3335
}
3436

test/test-cases/regression/auditlog.json

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,5 +171,54 @@
171171
"SecAuditLogType Parallel",
172172
"SecAuditLogRelevantStatus \"^(?:5|4(?!04))\""
173173
]
174+
},
175+
{
176+
"enabled": 1,
177+
"version_min": 300000,
178+
"version_max": 0,
179+
"title": "auditlog : messages verification - nolog,auditlog",
180+
"client": {
181+
"ip": "200.249.12.31",
182+
"port": 2313
183+
},
184+
"server": {
185+
"ip": "200.249.12.31",
186+
"port": 80
187+
},
188+
"request": {
189+
"headers": {
190+
"Host": "www.modsecurity.org",
191+
"User-Agent": "Mozilla\/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.5) Gecko\/20091102 Firefox\/3.5.5 (.NET CLR 3.5.30729)",
192+
"Accept": "text\/html,application\/xhtml+xml,application\/xml;q=0.9,*\/*;q=0.8",
193+
"Accept-Language": "en-us,en;q=0.5",
194+
"Accept-Encoding": "gzip,deflate",
195+
"Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
196+
"Keep-Alive": "300",
197+
"Connection": "keep-alive",
198+
"Pragma": "no-cache",
199+
"Cache-Control": "no-cache"
200+
},
201+
"uri": "\/test.pl?param1=test&param2=test2",
202+
"method": "GET",
203+
"http_version": 1.1,
204+
"body": ""
205+
},
206+
"expected": {
207+
"audit_log": "id \"1556",
208+
"error_log": "",
209+
"http_code": 403
210+
},
211+
"rules": [
212+
"SecRuleEngine On",
213+
"SecDefaultAction \"phase:1,nolog,auditlog,deny,status:403\"",
214+
"SecRule ARGS \"@contains test\" \"id:1556,phase:1,block,nolog,auditlog\"",
215+
"SecAuditEngine RelevantOnly",
216+
"SecAuditLogParts ABCFHZ",
217+
"SecAuditLog /tmp/test/modsec_audit_auditlog_1.log",
218+
"SecAuditLogDirMode 0766",
219+
"SecAuditLogFileMode 0666",
220+
"SecAuditLogType Serial",
221+
"SecAuditLogRelevantStatus \"^(?:5|4(?!04))\""
222+
]
174223
}
175224
]

0 commit comments

Comments
 (0)