-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
xds: Make regex matchers match on full string, not just partial match #4875
Conversation
@@ -91,7 +92,8 @@ func (hrm *HeaderRegexMatcher) Match(md metadata.MD) bool { | |||
if !ok { | |||
return false | |||
} | |||
return hrm.re.MatchString(v) | |||
rem := hrm.re.FindString(v) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make a function (in grpcutil
) to
- call longest()
- FindString and compare length
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't calling longest() more than once inefficient...it is cleaner though. It makes regex bool longest = true, then is a no op afterward. Added though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's cleaner to make longest() an implementation detail of the compare() function.
And did you forget to push?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it took me longer than expected ngl :P.
1e546e9
to
ae86d3f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Can you also verify this fixes the failure in xds interop tests?
want: false, | ||
}, | ||
{ | ||
name: "match because fully match", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a test case for Longest.
Use the regex from the example: https://pkg.go.dev/regexp#Regexp.Longest
Or https://play.golang.org/p/Z682jeK2IH6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Pinged Eric about interop because of vet problem on master.
Try rebasing? The vet failure was fixed by #4877. |
59ef17a
to
33461b6
Compare
This PR fixes issue #4852. Previously, regex matchers returned true even if the string had a portion that matched with the regex. The proto documentation mentions that the full value needs to match the regex, not just a portion, and this PR switches the matchers to implement that.
Fixes #4852.
RELEASE NOTES: None