Skip to content

Commit cc83a1b

Browse files
authored
Merge pull request #2673 from martinhsv/v3/master
Fix multiMatch msg, etc, population in audit log
2 parents cb80837 + 3ee6e10 commit cc83a1b

File tree

3 files changed

+112
-0
lines changed

3 files changed

+112
-0
lines changed

CHANGES

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

4+
- Fix multiMatch msg, etc, population in audit log
5+
[Issue #2573 - @Sachin-M-Desai, @martinhsv]
46
- Fix some name handling for ARGS_*NAMES: regex SecRuleUpdateTargetById, etc.
57
[Issue #2627, #2648 - @lontchianicet, @victorserbu2709, @martinhsv]
68
- Adjust confusing variable name in setRequestBody method

src/rule_with_actions.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,18 @@ void RuleWithActions::executeActionsIndependentOfChainedRuleResult(Transaction *
215215
}
216216
}
217217

218+
if (m_containsMultiMatchAction && !m_isChained) {
219+
if (m_severity) {
220+
m_severity->evaluate(this, trans, ruleMessage);
221+
}
222+
if (m_logData) {
223+
m_logData->evaluate(this, trans, ruleMessage);
224+
}
225+
if (m_msg) {
226+
m_msg->evaluate(this, trans, ruleMessage);
227+
}
228+
}
229+
218230
}
219231

220232

test/test-cases/regression/auditlog.json

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,5 +220,103 @@
220220
"SecAuditLogType Serial",
221221
"SecAuditLogRelevantStatus \"^(?:5|4(?!04))\""
222222
]
223+
},
224+
{
225+
"enabled": 1,
226+
"version_min": 300000,
227+
"version_max": 0,
228+
"title": "auditlog : multiMatch data, match after last transform",
229+
"client": {
230+
"ip": "200.249.12.31",
231+
"port": 2313
232+
},
233+
"server": {
234+
"ip": "200.249.12.31",
235+
"port": 80
236+
},
237+
"request": {
238+
"headers": {
239+
"Host": "www.modsecurity.org",
240+
"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)",
241+
"Accept": "text\/html,application\/xhtml+xml,application\/xml;q=0.9,*\/*;q=0.8",
242+
"Accept-Language": "en-us,en;q=0.5",
243+
"Accept-Encoding": "gzip,deflate",
244+
"Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
245+
"Keep-Alive": "300",
246+
"Connection": "keep-alive",
247+
"Pragma": "no-cache",
248+
"Cache-Control": "no-cache"
249+
},
250+
"uri": "\/test.pl?param1=test&param2=tEst2",
251+
"method": "GET",
252+
"http_version": 1.1,
253+
"body": ""
254+
},
255+
"expected": {
256+
"audit_log": "\\[msg \"testmsg\"\\]",
257+
"error_log": "",
258+
"http_code": 403
259+
},
260+
"rules": [
261+
"SecRuleEngine On",
262+
"SecDefaultAction \"phase:1,nolog,auditlog,deny,status:403\"",
263+
"SecRule ARGS \"@contains test2\" \"id:1557,phase:1,multiMatch,block,log,t:none,t:urlDecode,t:lowercase,msg:'testmsg'\"",
264+
"SecAuditEngine RelevantOnly",
265+
"SecAuditLogParts ABCFHZ",
266+
"SecAuditLog /tmp/test/modsec_audit_multimatch_1.log",
267+
"SecAuditLogDirMode 0766",
268+
"SecAuditLogFileMode 0666",
269+
"SecAuditLogType Serial",
270+
"SecAuditLogRelevantStatus \"^(?:5|4(?!04))\""
271+
]
272+
},
273+
{
274+
"enabled": 1,
275+
"version_min": 300000,
276+
"version_max": 0,
277+
"title": "auditlog : multiMatch data, match only after intermediate transform",
278+
"client": {
279+
"ip": "200.249.12.31",
280+
"port": 2313
281+
},
282+
"server": {
283+
"ip": "200.249.12.31",
284+
"port": 80
285+
},
286+
"request": {
287+
"headers": {
288+
"Host": "www.modsecurity.org",
289+
"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)",
290+
"Accept": "text\/html,application\/xhtml+xml,application\/xml;q=0.9,*\/*;q=0.8",
291+
"Accept-Language": "en-us,en;q=0.5",
292+
"Accept-Encoding": "gzip,deflate",
293+
"Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
294+
"Keep-Alive": "300",
295+
"Connection": "keep-alive",
296+
"Pragma": "no-cache",
297+
"Cache-Control": "no-cache"
298+
},
299+
"uri": "\/test.pl?param1=test&param2=%20tEst2",
300+
"method": "GET",
301+
"http_version": 1.1,
302+
"body": ""
303+
},
304+
"expected": {
305+
"audit_log": "\\[msg \"tstmsg\"\\]",
306+
"error_log": "",
307+
"http_code": 403
308+
},
309+
"rules": [
310+
"SecRuleEngine On",
311+
"SecDefaultAction \"phase:1,nolog,auditlog,deny,status:403\"",
312+
"SecRule ARGS \"@streq tEst2\" \"id:1558,phase:1,multiMatch,block,log,t:none,t:trim,t:lowercase,msg:'tstmsg'\"",
313+
"SecAuditEngine RelevantOnly",
314+
"SecAuditLogParts ABCFHZ",
315+
"SecAuditLog /tmp/test/modsec_audit_multimatch_2.log",
316+
"SecAuditLogDirMode 0766",
317+
"SecAuditLogFileMode 0666",
318+
"SecAuditLogType Serial",
319+
"SecAuditLogRelevantStatus \"^(?:5|4(?!04))\""
320+
]
223321
}
224322
]

0 commit comments

Comments
 (0)