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:
   Error is right, but `plugins.Parse` (plugins.go:62-65) does `log.Error; 
continue` and returns nil, so it never reaches `translateAnnotations`' 
`errors.Join`. Route still programmed without csrf — only a log line, no 
status/event. Failing loud needs `plugins.Parse` to propagate the error. See 
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]

Reply via email to