Skip to content

Commit 2ca328e

Browse files
author
Lucas Bremgartner
committed
Merge remote-tracking branch 'upstream/master' into feature-modularize
Conflicts: logstash-modsecurity.conf
2 parents c21a6d2 + b166e9b commit 2ca328e

16 files changed

Lines changed: 67 additions & 93 deletions

1010_input_file_example.conf

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
input {
2-
32
file {
43
# IMPORTANT! set this correctly to the charset
54
# that your server writes these log files in
6-
charset => "US-ASCII"
75
path => "/path/to/your/modsec/audit/logs/*.log"
86
type => "mod_security"
97

@@ -13,10 +11,10 @@ input {
1311
# which is the end of each modsec logical event in the logfile
1412
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1513
codec => multiline {
14+
charset => "US-ASCII"
1615
pattern => "^--[a-fA-F0-9]{8}-Z--$"
1716
negate => true
1817
what => previous
1918
}
2019
}
21-
2220
}

2020_filter_section_b_parse_request_line.conf

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,12 @@ filter {
77
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
88

99
# if a legit line... normal http request
10-
if [rawSectionB] =~ /.*?\s\S+\s.+\n{1}/ {
11-
12-
grok {
13-
match => {
14-
"rawSectionB" => "%{DATA:httpMethod}\s(?<requestedUri>\S+)\s(?<incomingProtocol>.+?)\n{1}"
15-
}
16-
patterns_dir => "./patterns/logstash_modsecurity_patterns"
17-
}
18-
19-
# not a legit line.. invalid http request, grab first line and dump in the httpMethod
20-
} else {
21-
10+
if [rawSectionB] =~ /.+/ {
2211
grok {
2312
match => {
24-
"rawSectionB" => "(?<httpMethod>^(.*)$)"
13+
"rawSectionB" => [ "(?m)^%{DATA:httpMethod}\s(?<requestedUri>\S+)\s(?<incomingProtocol>[^\n]+)(?:\n(?<raw_requestHeaders>.+)?)?$",
14+
"(?<httpMethod>^(.*)$)" ]
2515
}
26-
patterns_dir => "./patterns/logstash_modsecurity_patterns"
2716
}
2817
}
2918
}
File renamed without changes.

2021_filter_section_b_parse_headers.conf

Lines changed: 0 additions & 18 deletions
This file was deleted.

2029_filter_section_b_example_header_Cookie.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ filter {
1212
match => {
1313
"raw_requestHeaders" => "(?<myCookie>myCookie[^; \s]+)"
1414
}
15-
patterns_dir => "./patterns/logstash_modsecurity_patterns"
1615
}
1716
}
1817
}

2029_filter_section_b_example_header_X-Forwarded-For.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ filter {
1616
match => {
1717
"raw_requestHeaders" => "X-Forwarded-For: %{IPORHOST:XForwardedFor}"
1818
}
19-
patterns_dir => "./patterns/logstash_modsecurity_patterns"
2019
}
2120
}
2221
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
filter {
2+
if [type] == "mod_security" {
3+
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4+
# Example of splitting all Cookies from the requestHeader Cookie
5+
# and promoting it to a first class field
6+
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7+
8+
if [requestHeaders][Cookie] =~ /.+/ {
9+
kv {
10+
source => "[requestHeaders][Cookie]"
11+
field_split => "; "
12+
value_split => "="
13+
target => "requestCookies"
14+
}
15+
}
16+
}
17+
}
18+
}

2030_filter_section_c_parse.conf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ filter {
1010
grok {
1111
match => {
1212
"rawSectionC" => "(?<requestBody>.+)"
13-
}
14-
patterns_dir => "./patterns/logstash_modsecurity_patterns"
13+
}
1514
}
1615
}
1716
}

2060_filter_section_f_parse_request_line.conf

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,12 @@ filter {
55
# Parse out server protocol/HTTP status from Section F (response related, line 1)
66
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
77

8-
# response section (NO headers)
9-
if [rawSectionF] =~ /(.+?)\s(.+?)$/ {
10-
grok {
11-
singles => true
12-
match => {
13-
"rawSectionF" => "(?<serverProtocol>.+?)\s(?<responseStatus>.+?)$"
14-
}
15-
patterns_dir => "./patterns/logstash_modsecurity_patterns"
16-
}
8+
if [rawSectionF] =~ /.+/ {
179

18-
# response section (WITH headers)
19-
} else if [rawSectionF] =~ /(.+?)\s(.+?)\n{1}/ {
2010
grok {
21-
singles => true
2211
match => {
23-
"rawSectionF" => "(?<serverProtocol>.+?)\s(?<responseStatus>.+?)\n{1}"
12+
"rawSectionF" => "(?m)^(?<serverProtocol>.+?)\s(?<responseStatus>[^\n]+)(\n(?<raw_responseHeaders>.+)?)?$"
2413
}
25-
patterns_dir => "./patterns/logstash_modsecurity_patterns"
2614
}
2715
}
2816
}

2061_filter_section_f_parse_headers.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ filter {
1212
match => {
1313
"rawSectionF" => ".+?\n(?m)(?<raw_responseHeaders>.+)"
1414
}
15-
patterns_dir => "./patterns/logstash_modsecurity_patterns"
1615
}
1716
}
1817
}

0 commit comments

Comments
 (0)