AlinsRan commented on code in PR #2813:
URL:
https://github.com/apache/apisix-ingress-controller/pull/2813#discussion_r3643527293
##########
internal/adc/translator/annotations/plugins/csrf.go:
##########
@@ -39,7 +41,10 @@ func (c *csrf) Handle(e annotations.Extractor) (any, error) {
key := e.GetStringAnnotation(annotations.AnnotationsCsrfKey)
if key == "" {
- return nil, nil
+ // csrf requested but the key is missing: fail loud instead of
+ // silently dropping the plugin and programming the route
unprotected.
+ return nil, fmt.Errorf("annotation %q is enabled but %q is
missing or empty",
+ annotations.AnnotationsEnableCsrf,
annotations.AnnotationsCsrfKey)
Review Comment:
This error is correct, but it dies in `plugins.Parse` (plugins.go:62-65:
`log.Error(...); continue`), which then returns a nil error. So it never
reaches `translateAnnotations`' `errors.Join`, and the route is still
programmed without csrf — no Ingress status, no event, only a controller log
line. To actually fail loud, `plugins.Parse` needs to return the error rather
than swallow it. See the top-level comment.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]