parser_syslog: the regexp engine for RFC 5424 can match the header later in the message and corrupt the record
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
从 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 分钟
- 30 天内合并 PR
- 66
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 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 今天认领。 未关闭bug
难度 3/5 1-2 天 新手友好度 74/100
维护者通常 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 天内回复