Skip to content

parser_syslog: accept a space after RFC3164 priority#5449

Open
AkashKumar7902 wants to merge 1 commit into
fluent:masterfrom
AkashKumar7902:agent/accept-rfc3164-pri-space
Open

parser_syslog: accept a space after RFC3164 priority#5449
AkashKumar7902 wants to merge 1 commit into
fluent:masterfrom
AkashKumar7902:agent/accept-rfc3164-pri-space

Conversation

@AkashKumar7902

Copy link
Copy Markdown

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_syslog or 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 rfc3164 and the RFC3164 path of auto, 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_format beginning 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 errors
  • bundle exec ruby -Itest test/plugin/test_in_syslog.rb — 41 tests, 280 assertions, 0 failures, 0 errors
  • bundle exec rake test — 4,397 tests, 16,155 assertions, 0 failures, 0 errors, 3 pendings, 36 omissions
  • gem exec rubocop — 460 files inspected, 0 offenses
  • Balanced microbenchmark with 8 samples per revision and case — all 8 prespecified fixed regression gates passed. The narrowest throughput ratio was 0.955; this was used only as a regression gate, and no performance improvement is claimed.
  • Installed-gem UDP validation — 16/16 scenarios passed. Both baseline and candidate gems were built and installed into isolated environments, real fluentd --no-supervisor processes 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.

Signed-off-by: Akash Kumar <meakash7902@gmail.com>
@AkashKumar7902
AkashKumar7902 marked this pull request as ready for review July 19, 2026 23:57

@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.

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)
  end

On 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.

@Watson1978 Watson1978 added the enhancement Feature request or improve operations label Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Feature request or improve operations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

in_syslog: consider space between PRI and HEADER valid for RFC3164

2 participants