Skip to content

Commit e119c79

Browse files
[libbeat] Fix parsing of RFC 3164 process IDs in syslog processor (#38982) (#39124)
- The pattern for parsing process IDs was too relaxed and would match everything between the first opening and the last closing square bracket in a message. If the message included multiple closing square brackets, the process ID would be set to not only the process ID, but also whatever leads up to the last closing square bracket. - The pattern has now been locked down to only digits. - Added test case. (cherry picked from commit 8e9a276) Co-authored-by: Taylor Swanson <90622908+taylor-swanson@users.noreply.github.com>
1 parent 619e51f commit e119c79

File tree

4 files changed

+20
-56
lines changed

4 files changed

+20
-56
lines changed

CHANGELOG.next.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]
9191
- Change cache processor documentation from `write_period` to `write_interval`. {pull}38561[38561]
9292
- Fix cache processor expiries heap cleanup on partial file writes. {pull}38561[38561]
9393
- Fix cache processor expiries infinite growth when large a large TTL is used and recurring keys are cached. {pull}38561[38561]
94+
- Fix parsing of RFC 3164 process IDs in syslog processor. {issue}38947[38947] {pull}38982[38982]
9495

9596
*Auditbeat*
9697
- Set field types to correctly match ECS in sessionmd processor {issue}38955[38955] {pull}38994[38994]

libbeat/reader/syslog/parser/rfc3164.rl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
hostname = graph+ >tok %set_hostname;
1717

1818
tag = (print -- [ :\[])+ >tok %set_tag;
19-
content_value = print+ >tok %set_content;
19+
content_value = digit+ >tok %set_content;
2020
content = '[' content_value ']';
2121
msg = (tag content? ':' sp)? any+ >tok %set_msg;
2222
}%%

libbeat/reader/syslog/rfc3164_gen.go

Lines changed: 5 additions & 55 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libbeat/reader/syslog/rfc3164_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,19 @@ func TestParseRFC3164(t *testing.T) {
8888
msg: "message",
8989
},
9090
},
91+
"ok-procid-with-square-brackets-msg": {
92+
in: "<114>Apr 12 13:30:01 aaaaaa001.adm.domain aaaaaa001[25259]: my.some.domain 10.11.12.13 - USERNAME [12/Apr/2024:13:29:59.993 +0200] /skodas \"GET /skodas/group/pod-documentation/aaa HTTP/1.1\" 301 301 290bytes 1 10327",
93+
want: message{
94+
timestamp: mustParseTime(time.Stamp, "Apr 12 13:30:01", time.Local),
95+
priority: 114,
96+
facility: 14,
97+
severity: 2,
98+
hostname: "aaaaaa001.adm.domain",
99+
process: "aaaaaa001",
100+
pid: "25259",
101+
msg: "my.some.domain 10.11.12.13 - USERNAME [12/Apr/2024:13:29:59.993 +0200] /skodas \"GET /skodas/group/pod-documentation/aaa HTTP/1.1\" 301 301 290bytes 1 10327",
102+
},
103+
},
91104
"err-pri-not-a-number": {
92105
in: "<abc>Oct 11 22:14:15 test-host this is the message",
93106
want: message{

0 commit comments

Comments
 (0)