Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal/envoy: switch to safe regex for path match #1913

Merged
merged 3 commits into from
Nov 22, 2019

Conversation

davecheney
Copy link
Contributor

@davecheney davecheney commented Nov 18, 2019

Updates #1351
Fixes #1513

Switch path regex matching to safe regex. Refactor matcher.RegexMatcher
code to its own file and helper so it can be reused across
internal/envoy and internal/contour.

Also of note, internal/contour longestRouteFirst comparator has intimate
knowledge of RouteMatch_SafeRegex which is probably not ideal.

Signed-off-by: Dave Cheney dave@cheney.net

Updates projectcontour#1351

Switch path regex matching to safe regex. Refactor matcher.RegexMatcher
code to its own file and helper so it can be reused across
internal/envoy and internal/contour.

Also of note, internal/contour longestRouteFirst comparator has intimate
knowledge of RouteMatch_SafeRegex which is probably not ideal.

Signed-off-by: Dave Cheney <dave@cheney.net>
@davecheney davecheney added this to the 1.1.0 milestone Nov 18, 2019
@davecheney davecheney requested a review from jpeach November 18, 2019 04:56
@stevesloka
Copy link
Member

Also fixes: #1513

Copy link
Member

@stevesloka stevesloka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@stevesloka stevesloka merged commit 5c9497a into projectcontour:master Nov 22, 2019
davecheney added a commit to davecheney/contour that referenced this pull request Nov 24, 2019
Updates projectcontour#1351

Prior to projectcontour#1882 the envoy package offered two ways to construct a
Prefix/Regex match -- the first was a direct call to
RoutePrefix/RouteRegex which took a string parameter, the second was
via RouteMatch which took a dag.Route object. projectcontour#1882 refactored
RouteMatch on top of RoutePrefix/RouteRegex which consolidated on one
method of constructing a regex match, projectcontour#1913 later took advatage of this
to update all uses of regex to safe regex.

However there still existed two ways to construct a matcher, one via a
direct call to RoutePrefix/RouteRegex the other via RouteMatch. It turns
out that all the test code used the former, and all the production code
used the latter, implying that RoutePrefix/RouteRegex were test helpers.

This PR removes RouteRegex/RoutePrefix and replaces their calls in test
code with helpers that construct the respective *dag.Route object and
passes that to RouteMatch.

Signed-off-by: Dave Cheney <dave@cheney.net>
davecheney added a commit that referenced this pull request Nov 25, 2019
Updates #1351

Prior to #1882 the envoy package offered two ways to construct a
Prefix/Regex match -- the first was a direct call to
RoutePrefix/RouteRegex which took a string parameter, the second was
via RouteMatch which took a dag.Route object. #1882 refactored
RouteMatch on top of RoutePrefix/RouteRegex which consolidated on one
method of constructing a regex match, #1913 later took advatage of this
to update all uses of regex to safe regex.

However there still existed two ways to construct a matcher, one via a
direct call to RoutePrefix/RouteRegex the other via RouteMatch. It turns
out that all the test code used the former, and all the production code
used the latter, implying that RoutePrefix/RouteRegex were test helpers.

This PR removes RouteRegex/RoutePrefix and replaces their calls in test
code with helpers that construct the respective *dag.Route object and
passes that to RouteMatch.

Signed-off-by: Dave Cheney <dave@cheney.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

internal/envoy: Switch to Safe_Regex
2 participants