parser_syslog: the regexp engine for RFC 5424 can match the header later in the message and corrupt the record
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
lib/fluent/plugin/parser_syslog.rbから始め、issueでリンクされているparse_plainからRegexp#match(text, idx)への呼び出しを確認し、RFC 5424ヘッダーフィールドがどのように解析されるかを追ってください。RFC 5424のparserテストと、regexpエンジンおよびstringエンジンを確認してください。フィールドがidxで一致しない場合に、regexpエンジンが不一致を報告し、先行するテキストを破棄したりレコードを破損したりしなければ完了です。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
With message_format rfc5424 and the default parser_engine regexp, the parser matches the header fields after the timestamp with re.match(text, idx). Regexp#match with a position does not anchor the match at that position. When the text at idx does not match, the regexp can match later in the text. The record then gets values from the wrong place, and the text before the match is dropped. No warning is logged.
https://github.com/fluent/fluentd/blob/e7d3c3e4/lib/fluent/plugin/parser_syslog.rb#L269
To Reproduce
Run the script below with bundle exec ruby -Ilib repro.rb in this repository.
Results on master (e7d3c3e4):
<14>1 2026-04-25T16:43:29Z hôst app 123 ID - msg: the regexp engine returns"host" => "st". The string engine returns"host" => "hôst".<14>1 2026-04-25T16:43:29Z first line\nhost app 123 ID - second line: the regexp engine returns"host" => "host"and"message" => "second line".first lineis dropped.
require 'fluent/test'
require 'fluent/test/driver/parser'
require 'fluent/plugin/parser_syslog'
Fluent::Test.setup
%w[regexp string].each do |engine|
d = Fluent::Test::Driver::Parser.new(Fluent::Plugin::SyslogParser).configure(%[
message_format rfc5424
with_priority true
parser_engine #{engine}
])
[
'<14>1 2026-04-25T16:43:29Z hôst app 123 ID - msg',
"<14>1 2026-04-25T16:43:29Z first line\nhost app 123 ID - second line",
].each do |text|
d.instance.parse(text) { |_time, record| puts "#{engine}: #{record.inspect}" }
end
end
Expected behavior
The regexp engine does not skip text. If the header fields do not match at that position, the message is reported as not matched. Anchoring the match at idx (for example with \G) would do this.
Your Environment
- Fluentd version: master (e7d3c3e4). v1.20.1 and v1.19.4 have the same code (not run).
- Package version: -
- Operating system: Linux
- Kernel version: -
Your Configuration
<parse>
@type syslog
message_format rfc5424
with_priority true
</parse>
Your Error Log
No error or warning is logged.
Additional context
parse_rfc3164_regex also uses the same parse_plain. I did not check whether RFC 3164 messages are affected.
- 主要言語
- Ruby
- スター
- 13.6k
- フォーク
- 1.4k
- 平均マージ
- 17時間 28分
- マージ済み PR(30日)
- 66
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
fluent/fluentd のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
parser_syslog: message_format auto parses RFC 3164 messages with an RFC 3339 timestamp as RFC 5424オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 64/100
メンテナーはふだん 1 日以内に返信
-
out_forward: unacknowledged chunks are resent forever with heartbeat_type none, ignoring retry limits and secondary対応中かも @SahinurDEV が 1 日前に担当しました。 オープンbug
難易度 3/5 1〜2日 初心者へのやさしさ 74/100
fluent/fluentd#5619 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
A label looked up at runtime during a graceful reload can keep dropping the events of a tag対応中かも @sarankumar1325 が今日担当しました。 オープンbug
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
Websockify heartbeat for vnc_container対応中かも @robinkar が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
Mend: dependency security vulnerability
難易度 2/5 1〜3時間 初心者へのやさしさ 63/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
metanorma/metanorma-cli#494 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
davidteren/mutineer#434 ·
メンテナーはふだん 2 日以内に返信