parser_syslog: accept a space after RFC3164 priority#5449
Open
AkashKumar7902 wants to merge 1 commit into
Open
parser_syslog: accept a space after RFC3164 priority#5449AkashKumar7902 wants to merge 1 commit into
AkashKumar7902 wants to merge 1 commit into
Conversation
Signed-off-by: Akash Kumar <meakash7902@gmail.com>
AkashKumar7902
marked this pull request as ready for review
July 19, 2026 23:57
Watson1978
requested changes
Jul 21, 2026
Contributor
There was a problem hiding this comment.
The following test should pass. It works on the master branch, but on this PR the behavior changes and it fails.
data(
'boundary space' => '<14> Apr 25 16:43:29.5',
)
def test_truncated_subsecond_rfc3164_is_rejected_without_raising(text)
@parser.configure(
'parser_engine' => 'string',
'message_format' => 'rfc3164',
'with_priority' => true,
'time_format' => '%b %d %H:%M:%S.%N',
)
result = :not_yielded
assert_nothing_raised do
@parser.instance.parse(text) do |time, record|
result = [time, record]
end
end
assert_equal([nil, nil], result)
endOn master, the input <14> Apr 25 16:43:29.5 (a truncated message with a boundary space, no host/message) is gracefully rejected as [nil, nil].
On this PR it raises NoMethodError(<undefined method '-' for nil>) instead.
Please add above test case in this PR.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue(s) this PR fixes:
Fixes #4158
What this PR does / why we need it:
Some syslog senders emit RFC3164 records with an ASCII space between the priority and header. Depending on whether
in_syslogor the parser owns priority extraction, the RFC3164 parser sees that space either immediately after>or as the first character of its input, and currently attempts to parse it as the start of the timestamp.This change accepts the RFC3164 boundary space in
rfc3164and the RFC3164 path ofauto, across both parser engines and both priority-ownership models. Canonical records without the space continue to parse unchanged, malformed priorities remain invalid, and RFC5424 parsing is unchanged.For the default RFC3164 time format, regression coverage verifies that two boundary spaces and tabs remain invalid. An explicit RFC3164
time_formatbeginning with a space treats that leading space as timestamp syntax, so this change does not impose or claim a one-space maximum for that configuration.This also corrects the string parser's dynamic timestamp slice cursor and the field-count accounting needed by RFC3164 time formats that begin with a space.
Docs Changes:
None. This broadens input compatibility without adding or changing configuration.
Release Note:
parser_syslog: accept one optional ASCII space between RFC3164 priority and header.
Testing:
bundle exec ruby -Itest test/plugin/test_parser_syslog.rb— 128 tests, 509 assertions, 0 failures, 0 errorsbundle exec ruby -Itest test/plugin/test_in_syslog.rb— 41 tests, 280 assertions, 0 failures, 0 errorsbundle exec rake test— 4,397 tests, 16,155 assertions, 0 failures, 0 errors, 3 pendings, 36 omissionsgem exec rubocop— 460 files inspected, 0 offensesfluentd --no-supervisorprocesses were started, and packets were sent by external UDP clients. The matrix included four baseline negative controls and twelve candidate scenarios across both parser engines, both priority-ownership models,rfc3164/auto, canonical and spaced packets, default-format whitespace rejection checks, RFC5424 compatibility, and explicit leading-space time formats.