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: Remove max_program_size from regex #3093

Merged
merged 1 commit into from Nov 4, 2020

Conversation

stevesloka
Copy link
Member

The Regex max_program_size is deprecated from Envoy and the control plane should
do this validation now. Removes the max_program_size field and adds a regex compile
check to the Ingress resource builder.

Fixes #2933

Signed-off-by: Steve Sloka slokas@vmware.com

@stevesloka stevesloka added this to the 1.10.0 milestone Nov 3, 2020
GoogleRe2: &matcher.RegexMatcher_GoogleRE2{
MaxProgramSize: protobuf.UInt32(maxRegexProgramSize),
},
GoogleRe2: &matcher.RegexMatcher_GoogleRE2{},
Copy link
Member Author

Choose a reason for hiding this comment

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

This whole file could be deleted probably, these tests don't really test anything.

@codecov
Copy link

codecov bot commented Nov 3, 2020

Codecov Report

Merging #3093 into main will increase coverage by 0.03%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3093      +/-   ##
==========================================
+ Coverage   73.15%   73.19%   +0.03%     
==========================================
  Files         103      103              
  Lines        6412     6421       +9     
==========================================
+ Hits         4691     4700       +9     
  Misses       1618     1618              
  Partials      103      103              
Impacted Files Coverage Δ
internal/dag/conditions.go 95.55% <100.00%> (+0.10%) ⬆️
internal/dag/ingress_processor.go 93.45% <100.00%> (+0.60%) ⬆️
internal/envoy/v2/regex.go 100.00% <100.00%> (ø)

Copy link
Contributor

@jpeach jpeach left a comment

Choose a reason for hiding this comment

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

Looks good, with jus a few nits.


// ValidateRegex returns an error if the supplied
// regex is invalid.
func ValidateRegex(regex string) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Best to add a comment that this is specifically validating RE2 regex syntax because that I what we are programming into Envoy (though Go isn't identicall apparently?).

Comment on lines 145 to 149
p.WithError(err).
WithField("name", ing.GetName()).
WithField("namespace", ing.GetNamespace()).
WithField("regex", path).
Errorf("path regex is not valid: %s", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
p.WithError(err).
WithField("name", ing.GetName()).
WithField("namespace", ing.GetNamespace()).
WithField("regex", path).
Errorf("path regex is not valid: %s", err)
p.WithError(err).
WithField("name", ing.GetName()).
WithField("namespace", ing.GetNamespace()).
WithField("regex", path).
Error("invalid path regular expression")

since the error is already logged by WithError()

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

Comment on lines 189 to 191
err := ValidateRegex(path)
if err != nil {
return nil, err
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
err := ValidateRegex(path)
if err != nil {
return nil, err
}
if err := ValidateRegex(path); err != nil {
return nil, err
}

nit :)

@@ -1509,6 +1509,48 @@ func TestRoutePrefixRouteRegex(t *testing.T) {
TypeUrl: routeType,
Nonce: "1",
})

// add default/kuard to translator.
Copy link
Contributor

Choose a reason for hiding this comment

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

Stale comment?

@stevesloka stevesloka force-pushed the validateRegex branch 2 times, most recently from 3b53497 to fbd27f0 Compare November 4, 2020 14:16
The Regex `max_program_size` is deprecated from Envoy and the control plane should
do this validation now. Removes the max_program_size field and adds a regex compile
check to the Ingress resource builder.

Fixes projectcontour#2933

Signed-off-by: Steve Sloka <slokas@vmware.com>
@stevesloka stevesloka merged commit 967fd42 into projectcontour:main Nov 4, 2020
@stevesloka stevesloka deleted the validateRegex branch November 4, 2020 15:16
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.

RegexMatcher Deprecated, needs upgraded
2 participants