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

Đã đóng Phù hợp với người mới
#5,587 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Một pull request liên quan đã được merge.

  • #5591 của @yuminn-k — đã merge

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
76/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
ruby
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu từ parse_rfc5424, nơi issue cho biết text.index('] ', cursor) tìm ranh giới dữ liệu có cấu trúc. So sánh trình phân tích cú pháp chuỗi với trình phân tích cú pháp regexp bằng đầu vào RFC5424 được cung cấp. Theo dõi các bài kiểm thử hiện có của trình phân tích cú pháp và thêm một trường hợp hồi quy cho ] được escape theo sau bởi dấu cách. Hoàn tất khi extradata chứa toàn bộ dữ liệu có cấu trúc và message là msg.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Ruby
Star
13.6k
Fork
1.4k
Merge trung bình
1 ngày 1 giờ
Pull request đã merge (30 ngày)
61

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của fluent/fluentd

Tất cả issue của fluent/fluentd

Issue tương tự

Thêm issue về Ruby

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.