Hyperscan

Hyperscan is a high-performance multiple regex matching library, which uses hybrid automata techniques to allow simultaneous matching of large numbers of regular expressions and for the matching of regular expressions across streams of data. Hyperscan supports the pattern syntax used by PCRE.

Hyperscan is only valid in the contrib image.

Hyperscan can be used as a matcher of generic matching, or enabled as a regex engine globally.

As a matcher of generic matching

Generic matching has been implemented in a few of components and extensions in Envoy, including filter chain matcher, route matcher and RBAC matcher. Hyperscan matcher can be used in generic matcher as a custom matcher in the following structure:

1                        custom_match:
2                          name: hyperscan
3                          typed_config:
4                            "@type": type.googleapis.com/envoy.extensions.matching.input_matchers.hyperscan.v3alpha.Hyperscan
5                            regexes:
6                            - regex: allowed.*path

The behavior of regex matching in Hyperscan matchers can be configured, please refer to the API reference.

Hyperscan matcher also supports multiple pattern matching which allows matches to be reported for several patterns simultaneously. Multiple pattern matching can be turned on in the following structure:

 1                        custom_match:
 2                          name: hyperscan
 3                          typed_config:
 4                            "@type": type.googleapis.com/envoy.extensions.matching.input_matchers.hyperscan.v3alpha.Hyperscan
 5                            # The following multiple patterns match input including allowed.*path and excluding
 6                            # den(y|ied). E.g., the path /allowed/path will be matched, while the path
 7                            # /allowed/denied/path will not be matched.
 8                            regexes:
 9                            - regex: allowed.*path
10                              id: 1
11                              quiet: true
12                            - regex: den(y|ied)
13                              id: 2
14                              quiet: true
15                            - regex: 1 & !2
16                              combination: true

As a regex engine

Hyperscan regex engine acts in the similar behavior with the default regex engine Google RE2 like it turns on UTF-8 support by default. Hyperscan regex engine can be easily configured with the following configuration.

1default_regex_engine:
2  name: envoy.regex_engines.hyperscan
3  typed_config:
4    "@type": type.googleapis.com/envoy.extensions.regex_engines.hyperscan.v3alpha.Hyperscan