Skip to content

parser_syslog, in_syslog: fix handling of a priority on a later line - #5598

Merged
Watson1978 merged 1 commit into
fluent:masterfrom
lbarrosby:parser-syslog-anchor-start
Nov 6, 2026
Merged

Watson1978 merged 1 commit into
fluent:masterfrom
lbarrosby:parser-syslog-anchor-start

Conversation

@lbarrosby

@lbarrosby lbarrosby commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Which issue(s) this PR fixes:
Fixes #5593

What this PR does / why we need it:

RFC5424_PRI_REGEXP, RFC3164_PRI_REGEXP and REGEXP_DETECT_RFC5424 in parser_syslog, and SYSLOG_REGEXP in in_syslog, started with ^. Since ^ matches at the start of any line, a message whose first line is not a syslog header was parsed from a later line that looks like one, and the text before it was dropped without a warning. With message_format auto, a message starting with an RFC3164 header could be detected as RFC5424 because of its second line.

This PR anchors the four regexps with \A, so the header is only looked for at the start of the message. Such messages are now rejected (and emitted as unmatched_line by in_syslog with emit_unmatched_lines true), which is what parser_engine string already does. As noted in the issue, a message that starts with an empty line is also rejected now, the same as with the string parser.

Tests:

  • test_priority_on_a_later_line_is_rejected: the RFC5424, RFC3164 and auto inputs from the issue, for both engines. On master the 3 regexp rows fail.
  • test_auto_detects_rfc3164_when_a_later_line_looks_like_rfc5424: on master the regexp row parses the second line as RFC5424 and the string row raises TimeParseError.
  • test_priority_on_a_later_line_is_unmatched_when_input_parses_priority in test_in_syslog.rb: <parse> @type none with first line\n<14>second line. On master it emits {"message":"second line"}.

test/plugin/test_parser_syslog.rb and test/plugin/test_in_syslog.rb pass locally (Ruby 4.0, macOS).

Docs Changes:

N/A

Release Note:

parser_syslog, in_syslog: fix handling of a priority on a later line

A priority on a later line was used as the priority of the message, and the text before it was dropped. Such messages are now treated as unmatched.

… message

The regexps that look for the PRI started with `^`, which matches at the
start of any line. When the first line of a message was not a syslog
header, the parser started from a later line that looked like one and
silently dropped the text before it. `message_format auto` could also
detect an RFC3164 message as RFC5424 from its second line.

Anchor them with `\A` so a message without a header at its start is
rejected, as `parser_engine string` already does.

Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>
@Watson1978 Watson1978 added this to the v1.21.0 milestone Nov 6, 2026
@Watson1978 Watson1978 added the backport to v1.19 We will backport this fix to the LTS branch label Nov 6, 2026

@Watson1978 Watson1978 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@Watson1978 Watson1978 changed the title parser_syslog, in_syslog: match the priority only at the start of the message parser_syslog, in_syslog: fix handling of a priority on a later line Nov 6, 2026
@Watson1978
Watson1978 merged commit 1d6b112 into fluent:master Nov 6, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport to v1.19 We will backport this fix to the LTS branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

parser_syslog, in_syslog: text before a PRI on a later line is silently dropped

2 participants