Skip to content

Backport(v1.19): Optimize RFC5424 structured data parsing (#5437)#5444

Open
github-actions[bot] wants to merge 1 commit into
v1.19from
backport-to-v1.19/pr5437
Open

Backport(v1.19): Optimize RFC5424 structured data parsing (#5437)#5444
github-actions[bot] wants to merge 1 commit into
v1.19from
backport-to-v1.19/pr5437

Conversation

@github-actions

Copy link
Copy Markdown

Which issue(s) this PR fixes:
Fixes #5367

What this PR does / why we need it:

The RFC5424 structured-data pattern repeated an element that already contains a lazy wildcard. On Ruby 3.2 and older, invalid input with adjacent structured-data elements could trigger exponential backtracking.

This removes the redundant outer repetition. The lazy match still spans adjacent structured-data elements, while a focused timeout regression protects the invalid-suffix case.

Validation included an exhaustive comparison of 97,656 generated suffixes on Ruby 2.6 and Ruby 4.0; match results and all named captures were unchanged.

Docs Changes:

None.

Release Note:

parser_syslog: avoid excessive backtracking when parsing malformed RFC5424 structured data.

Testing:

  • bundle exec ruby -Itest test/plugin/test_parser_syslog.rb — 77 tests, 332 assertions, 0 failures, 0 errors
  • bundle exec rake test — 4,336 tests, 15,819 assertions, 0 failures, 0 errors, 3 existing pendings, 36 existing omissions
  • rubocop — 459 files inspected, no offenses
  • ruby -c for both changed files and git diff --check

**Which issue(s) this PR fixes**:
Fixes #5367

**What this PR does / why we need it**:

The RFC5424 structured-data pattern repeated an element that already
contains a lazy wildcard. On Ruby 3.2 and older, invalid input with
adjacent structured-data elements could trigger exponential
backtracking.

This removes the redundant outer repetition. The lazy match still spans
adjacent structured-data elements, while a focused timeout regression
protects the invalid-suffix case.

Validation included an exhaustive comparison of 97,656 generated
suffixes on Ruby 2.6 and Ruby 4.0; match results and all named captures
were unchanged.

**Docs Changes**:

None.

**Release Note**:

parser_syslog: avoid excessive backtracking when parsing malformed
RFC5424 structured data.

**Testing**:

- `bundle exec ruby -Itest test/plugin/test_parser_syslog.rb` — 77
tests, 332 assertions, 0 failures, 0 errors
- `bundle exec rake test` — 4,336 tests, 15,819 assertions, 0 failures,
0 errors, 3 existing pendings, 36 existing omissions
- `rubocop` — 459 files inspected, no offenses
- `ruby -c` for both changed files and `git diff --check`

Signed-off-by: Joey@macstudio <4296411@qq.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@Watson1978 Watson1978 added this to the v1.19.4 milestone Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants