-
Notifications
You must be signed in to change notification settings - Fork 1
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3 +/- ##
==========================================
+ Coverage 84.61% 85.48% +0.86%
==========================================
Files 5 9 +4
Lines 247 427 +180
==========================================
+ Hits 209 365 +156
- Misses 34 58 +24
Partials 4 4
|
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.
Just some small nits
internal/server/authz.go
Outdated
// If there are no trigger rules, allow the request with no check executions. | ||
// TriggerRules are used to determine which request should be checked by the filter and which don't. | ||
if !mustTriggerCheck(e.cfg.TriggerRules, req) { | ||
e.log.Debug(fmt.Sprintf("no matching trigger rule, so allowing request to proceed without any authservice functionality %s://%s%s", |
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.
Let's get the log.Context(ctx)
to make sure we include any context logs here (such as the x-requesd-id or others that we could populate)
internal/server/authz.go
Outdated
return strings.HasSuffix(path, m.Suffix) | ||
case *configv1.StringMatch_Regex: | ||
b, _ := regexp.MatchString(m.Regex, path) | ||
// TODO: handle error |
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.
Let's just log the error and return false?
{"suffix-match", stringSuffix("test"), "123-test", true}, | ||
{"suffix-no-match", stringSuffix("test"), "no-match", false}, | ||
{"regex-match", stringRegex(".*st"), "test", true}, | ||
{"regex-no-match", stringRegex(".*st"), "no-match", false}, |
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 for the regexp error as well.
internal/server/authz.go
Outdated
@@ -72,6 +73,17 @@ func (e *ExtAuthZFilter) Register(server *grpc.Server) { | |||
|
|||
// Check is the implementation of the Envoy AuthorizationServer interface. | |||
func (e *ExtAuthZFilter) Check(ctx context.Context, req *envoy.CheckRequest) (response *envoy.CheckResponse, err error) { | |||
// If there are no trigger rules, allow the request with no check executions. | |||
// TriggerRules are used to determine which request should be checked by the filter and which don't. | |||
trLog := e.log.Context(ctx) |
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.
In line 90 we're already getting the log from the context. let's just create the log
variable here and reuse it later?
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.
totally, didn't notice that.
No description provided.