parser_syslog: string parser ends RFC5424 structured data at an escaped "]"

クローズ 初心者向け
#5,587 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

関連するプルリクエストがすでにマージされています。

  • #5591 @yuminn-k による — マージ済み

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
76/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
ruby
領域
backend

調査の方向性

parse_rfc5424から始めてください。issueによると、text.index('] ', cursor)が構造化データの境界を見つけます。提供されたRFC5424入力を使って、文字列パーサーと正規表現パーサーを比較してください。既存のパーサーテストを追い、エスケープされた]の後に空白が続くケースの回帰テストを追加してください。extradataに構造化データ全体が含まれ、messageがmsgになれば完了です。

索引モデルが issue の本文から書いたものです。

説明

bug
Describe the bug

With parser_engine string, parser_syslog ends STRUCTURED-DATA at the first ] in the message. It does not check whether the ] is escaped. When a PARAM-VALUE contains \] followed by a space, the rest of the structured data goes into message.

RFC 5424 section 6.3.3 requires ] in a PARAM-VALUE to be escaped as \], so this is a valid message.

Input:

<14>1 2026-04-25T16:43:29.123Z host app 123 ID [x@1 a="b\] c"] msg
extradata message
parser_engine string [x@1 a="b] c"] msg
parser_engine regexp [x@1 a="b\] c"] msg
To Reproduce
  1. Create /tmp/syslog.log with this line:

    <14>1 2026-04-25T16:43:29.123Z host app 123 ID [x@1 a="b\] c"] msg
    
  2. Run Fluentd with the configuration below.

Expected behavior

extradata contains the whole structured data and message is msg, as with parser_engine regexp.

Actual output:

test: {"host":"host","ident":"app","pid":"123","msgid":"ID","pri":14,"extradata":"[x@1 a=\"b]","message":"c\"] msg"}
Your Environment
- Fluentd version: 1.20.1 (master at f55db4b1)
- Package version: N/A (from source)
- Operating system: CachyOS
- Kernel version: 7.3.1-1-cachyos
- Ruby: 4.0.9
Your Configuration
<source>
  @type tail
  path /tmp/syslog.log
  pos_file /tmp/syslog.log.pos
  read_from_head true
  tag test
  <parse>
    @type syslog
    message_format rfc5424
    with_priority true
    parser_engine string
  </parse>
</source>

<match test>
  @type stdout
</match>
Your Error Log
No error is logged. The record is emitted with wrong fields.
Additional context

parse_rfc5424 finds the end of the structured data with text.index('] ', cursor). This exists since v1.11.0.

主要言語
Ruby
スター
13.6k
フォーク
1.4k
平均マージ
1日 1時間
マージ済み PR(30日)
61

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

fluent/fluentd のほかの issue

fluent/fluentd の issue をすべて見る

似ている issue

Ruby の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。