shreemaan-abhishek commented on code in PR #2813:
URL:
https://github.com/apache/apisix-ingress-controller/pull/2813#discussion_r3654921206
##########
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:
@nic-6443 you were right about the update path, thanks. I confirmed
`Provider.Update` returns on the translation error before `UpdateConfig`, so
the previously-programmed unprotected route survived in the ADC cache and data
plane. Translator-only tests could not see it.
I have moved enforcement to the Ingress admission webhook (`ValidateCreate`
+ `ValidateUpdate`), so `enable-csrf: true` with no key is now rejected at
apply time for updates as well as creates, and the already-served case is
covered. The translation-failure change is reverted. Added a webhook test that
exercises an update from a route with no csrf annotations to the invalid
enable-csrf-without-key state.
--
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]