Repository navigation
in_syslog: Treat a PRI above 191 as invalid - #5635
Conversation
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, so it now uses <134>. Fixes fluent#5632 Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>
Watson1978
left a comment
There was a problem hiding this comment.
Thanks for the fix. The range check looks correct to me.
I compared master and this branch with both parser engines, with_priority true and false, message_format rfc3164, rfc5424 and auto, @type none, and severity_key/facility_key. The only change was for messages that master emitted with an empty facility in the tag. They are now rejected, as #5632 expects. They go to syslog.unmatched with emit_unmatched_lines true and are dropped otherwise. Messages with a PRI in 0..191 behave the same as on master.
I left two comments on the tests.
Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>
|
Thanks. Pushed c070e5a with both suggestions:
|
Watson1978
left a comment
There was a problem hiding this comment.
Thanks for the update. Both changes look good to me.
I ran test/plugin/test_in_syslog.rb on c070e5a: 56 tests, 0 failures. The new test still fails with the lib from master. It also fails if PRI_RANGE is 0..199. I also limited SYSLOG_REGEXP to 3 digits. Then the space-after-PRI test failed with both parser engines.
Which issue(s) this PR fixes:
Fixes #5632
What this PR does / why we need it:
message_handlerbuilt the tag fromFACILITY_MAP[pri >> 3]without checking the range. A PRI above 191 has no facility, so the tag got an empty part.<200>gavesyslog..emerg. Withwith_priority false,SYSLOG_REGEXPaccepts any number of digits, so<1234>gavesyslog..crit.PRI must now be in
0..191, the range RFC 5424 defines. Otherwise in_syslog logsinvalid syslog priorityand returns. Withemit_unmatched_lines trueit emits the line assyslog.unmatched, the same way it handles other invalid messages.test_space_after_input_owned_priority_preserves_input_priority_syntaxused<1234>as a valid PRI. It now uses<0134>and still checks that the space after PRI makes no difference.Tests:
test_priority_out_of_range_is_unmatched(default parse andwith_priority false) sends<192>,<1234>and<191>. It expects twosyslog.unmatchedevents and thensyslog.local7.debug. On master,with_priority falseemitssyslog..emergandsyslog..crit, and the default parse emitssyslog..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.with_priority false: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.