-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introduce safe regex matcher based on re2 engine (#7878)
The libstdc++ std::regex implementation is not safe in all cases for user provided input. This change deprecates the used of std::regex in all user facing paths and introduces a new safe regex matcher with an explicitly configurable engine, right now limited to Google's re2 regex engine. This is not a drop in replacement for std::regex as all language features are not supported. As such we will go through a deprecation period for the old regex engine. Fixes envoyproxy/envoy#7728 Signed-off-by: Matt Klein <mklein@lyft.com> Mirrored from https://github.com/envoyproxy/envoy @ eff020170c6267e6c8dc235473f7fc85c5b1e07d
- Loading branch information
data-plane-api(CircleCI)
committed
Aug 23, 2019
1 parent
3337c67
commit 9b2125a
Showing
6 changed files
with
146 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
syntax = "proto3"; | ||
|
||
package envoy.type.matcher; | ||
|
||
option java_outer_classname = "StringProto"; | ||
option java_multiple_files = true; | ||
option java_package = "io.envoyproxy.envoy.type.matcher"; | ||
option go_package = "matcher"; | ||
|
||
import "google/protobuf/wrappers.proto"; | ||
import "validate/validate.proto"; | ||
|
||
// [#protodoc-title: RegexMatcher] | ||
|
||
// A regex matcher designed for safety when used with untrusted input. | ||
message RegexMatcher { | ||
// Google's `RE2 <https://github.com/google/re2>`_ regex engine. The regex string must adhere to | ||
// the documented `syntax <https://github.com/google/re2/wiki/Syntax>`_. The engine is designed | ||
// to complete execution in linear time as well as limit the amount of memory used. | ||
message GoogleRE2 { | ||
// This field controls the RE2 "program size" which is a rough estimate of how complex a | ||
// compiled regex is to evaluate. A regex that has a program size greater than the configured | ||
// value will fail to compile. In this case, the configured max program size can be increased | ||
// or the regex can be simplified. If not specified, the default is 100. | ||
google.protobuf.UInt32Value max_program_size = 1; | ||
} | ||
|
||
oneof engine_type { | ||
option (validate.required) = true; | ||
|
||
// Google's RE2 regex engine. | ||
GoogleRE2 google_re2 = 1 [(validate.rules).message.required = true]; | ||
} | ||
|
||
// The regex match string. The string must be supported by the configured engine. | ||
string regex = 2 [(validate.rules).string.min_bytes = 1]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters