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

Cerrado Apto para principiantes
#5,587 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Ya se ha fusionado un pull request relacionado.

  • #5591 de @yuminn-k — fusionado

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
76/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
ruby
Área
backend

Línea de trabajo

Empieza en parse_rfc5424, donde el issue indica que text.index('] ', cursor) encuentra el límite de los datos estructurados. Compara el parser de cadenas con el parser de expresiones regulares usando la entrada RFC5424 proporcionada. Sigue los tests existentes del parser y añade un caso de regresión para un ] escapado seguido de un espacio. El trabajo está hecho cuando extradata contiene todos los datos estructurados y message es msg.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Ruby
Estrellas
13.6k
Forks
1.4k
Merge medio
1 d 1 h
PR fusionados (30 d)
61

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de fluent/fluentd

Todos los issues de fluent/fluentd

Issues similares

Más issues de Ruby

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.