-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Labels
Description
Title: Introduce New header match type to avoid Regex - Contains
Description:
For matching values in the header that might be somewhere in the middle of the header, the present option is to use Regex in the form .*Search-Pattern.*. This can cause catastrophic backtracking as described here:
#7728
As a solution, in our build used in eBay Traffic engineering, we have introduced another header match type called contains which is based on absl::StrContains(). It works well for us.
The API is exactly the same as suffix match for headers:
| | |
| | | // If specified, header match will be performed based on whether the header value contains
| | | // the value specified in this option.
| | | // Note: empty contains match is not allowed, please use present_match instead.
| | | //
| | | // Examples:
| | | //
| | | // * The contains *abc* matches the value *xyzabcdpqrs*, but not for *xyzbcdpqrs*.
| | | string contains_match = 11 [(validate.rules).string.min_bytes = 1];
Please let me know if this is required/acceptable upstream, I can cherry-pick and raise a PR. Here is a snippet from our change to further illustrate:
case HeaderMatchType::Contains:
match = absl::StrContains(header->value().getStringView(), header_data.value_);
break;
Reactions are currently unavailable