AlinsRan commented on code in PR #2813:
URL: 
https://github.com/apache/apisix-ingress-controller/pull/2813#discussion_r3662268257


##########
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.

Review Comment:
   Let's still return an error here when the key is missing.
   
   Not to fail the route — `plugins.Parse` logs handler errors and skips only 
that plugin, so the rest of the Ingress is untouched. The webhook stays the 
enforcement point; this just means the cases it cannot cover (webhook disabled, 
or an Ingress created before the upgrade that never gets re-admitted) leave a 
log line instead of nothing at all.
   
   webhook + log is enough here. No status condition, no event.



##########
internal/webhook/v1/ingress_webhook.go:
##########
@@ -82,6 +83,10 @@ func (v *IngressCustomValidator) ValidateCreate(ctx 
context.Context, obj runtime
                return nil, fmt.Errorf("%s", 
sslvalidator.FormatConflicts(conflicts))
        }
 
+       if err := validateAnnotations(ingress); err != nil {

Review Comment:
   Move this above `DetectConflicts`. It is a pure in-memory check, no reason 
to run it after several List calls and Secret reads.



-- 
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