Werk #5671: Use RE2 regular expression engine for Livestatus queries.

Component Livestatus
Title Use RE2 regular expression engine for Livestatus queries.
Date Feb 15, 2018
Checkmk Edition Checkmk Raw (CRE)
Checkmk Version 1.5.0i3
Level Prominent Change
Class New Feature
Compatibility Compatible - no manual interaction needed

Livestatus offers various places where a regular expression can be used, e.g. in its "Filter:" header for GET queries. The previous implementation had various problems, which have all been fixed by switching to a new regular expression engine RE2:

  • Unicode was not handled correctly: RE2 fully understands UTF-8, so this has been fixed.
  • Unbounded memory usage during matching: This could lead to stack overflows and CMC/Nagios crashes when trying to match some classes of regular expressions on long inputs. RE2 guarantees that this won't happen, it either complains that a regular expression is too complicated (which is hard to provoke) or runs in constant memory afterwards.
  • Exponential runtime: Some classes of regular expressions could lead to exponential runtime, blocking Livestatus threads and using CPU time for some millenia or more. RE2's runtime is linear in the size of the regular expression and the input, so this has been fixed, too.

As an additional bonus, most of the time RE2 is quite a bit faster than the previous implementation.

RE2's regular expression syntax is basically a superset of the previous POSIX extended regular expression syntax, so you won't have to change your patterns.

Note that one esoteric detail is different, though, namely the semantics of submatching. If you relied on this, you probably already had some problems, because almost every POSIX regex implementation out there was buggy in some way.

To the list of all Werks