Skip to content

Backport(v1.19): in_syslog: Treat a PRI above 191 as invalid (#5635) - #5654

Merged
kenhys merged 1 commit into
v1.19from
backport-pr5635
Nov 19, 2026
Merged

kenhys merged 1 commit into
v1.19from
backport-pr5635

Conversation

@Watson1978

Copy link
Copy Markdown
Contributor

Which issue(s) this PR fixes:
Backport #5635
Fixes #5632

What this PR does / why we need it:

message_handler built the tag from FACILITY_MAP[pri >> 3] without checking the range. A PRI above 191 has no facility, so the tag got an empty part. <200> gave syslog..emerg. With with_priority false, SYSLOG_REGEXP accepts any number of digits, so <1234> gave syslog..crit.

PRI must now be in 0..191, the range RFC 5424 defines. Otherwise in_syslog logs invalid syslog priority and returns. With emit_unmatched_lines true it emits the line as syslog.unmatched, the same way it handles other invalid messages.

test_space_after_input_owned_priority_preserves_input_priority_syntax used <1234> as a valid PRI. It now uses <0134> and still checks that the space after PRI makes no difference.

Tests:

  • New test_priority_out_of_range_is_unmatched (default parse and with_priority false) sends <192>, <1234> and <191>. It expects two syslog.unmatched events and then syslog.local7.debug. On master, with_priority false emits syslog..emerg and syslog..crit, and the default parse emits syslog..emerg.
  • bundle exec ruby -Ilib -Itest test/plugin/test_in_syslog.rb: 56 tests, 0 failures. test/plugin/test_parser_syslog.rb: 204 tests, 0 failures.
  • The steps from the issue with with_priority false:
master:
syslog..emerg: {"host":"host","ident":"app","message":"msg"}
syslog..crit: {"host":"host","ident":"app","message":"msg"}
syslog.local7.debug: {"host":"host","ident":"app","message":"msg"}

branch:
[warn]: invalid syslog priority data="<200>Apr 25 16:43:29 host app: msg"
[warn]: invalid syslog priority data="<1234>Apr 25 16:43:29 host app: msg"
syslog.local7.debug: {"host":"host","ident":"app","message":"msg"}

Docs Changes:
None.

Release Note:
in_syslog: Treat a PRI above 191 as invalid instead of emitting the message with an empty facility in the tag.

in_syslog built the tag from FACILITY_MAP[pri >> 3] without checking
the range. For a PRI above 191 the facility was nil, so <200> was
emitted with the tag syslog..emerg. With with_priority false, the PRI
comes from SYSLOG_REGEXP with any number of digits, so <1234> gave
syslog..crit.

RFC 5424 limits PRI to 0..191. Warn and drop such a message, or emit
it as unmatched with emit_unmatched_lines, like other invalid messages.

The space test used <1234> as a valid PRI. It now uses <0134>, so it
still covers a PRI written with 4 digits. The new test checks <192>,
the first value above the range.

Fixes #5632

Backport note: test/plugin/test_in_syslog.rb conflicted because v1.19
does not have the tests around the space after PRI from #5449. The
change of <1234> to <0134> in one of those tests is dropped, and only
the new test for a PRI out of range is added.

Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>
Co-authored-by: Shizuo Fujita <fujita@clear-code.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Shizuo Fujita <fujita@clear-code.com>
@Watson1978 Watson1978 added this to the v1.19.5 milestone Nov 18, 2026
@Watson1978
Watson1978 requested a review from kenhys November 18, 2026 01:45
@kenhys
kenhys merged commit a2608e3 into v1.19 Nov 19, 2026
22 checks passed
@kenhys
kenhys deleted the backport-pr5635 branch November 19, 2026 08:31
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.

3 participants