nic-6443 commented on code in PR #2808:
URL:
https://github.com/apache/apisix-ingress-controller/pull/2808#discussion_r3637313922
##########
api/adc/types.go:
##########
@@ -61,6 +61,23 @@ type Resources struct {
SSLs []*SSL `json:"ssls,omitempty"
yaml:"ssls,omitempty"`
}
+// MarshalLog implements logr.Marshaler so logging Resources emits only counts,
+// never the secret-bearing bodies (SSL private keys, consumer credentials).
+// It affects logging only, not the JSON sent to the data plane.
+func (r *Resources) MarshalLog() any {
Review Comment:
Mechanism checks out — I built the production logger (zapr + zap console
encoder) into a buffer and confirmed `MarshalLog` is honoured at all three
sites, the token comes out `[REDACTED]`, and the wire payload is untouched.
Also confirmed the remaining `"config", config` / `"configs", configs` sites in
`client.go` are already safe: `Config.MarshalJSON` gets picked up by zap's
reflect encoder, so the AdminKey doesn't survive there either.
One sharp edge on this receiver: it's on `*Resources`, so `Resources` by
value doesn't satisfy `logr.Marshaler` and silently falls back to reflection.
Logging a value dumps everything:
```
log.V(1).Info("resources", "resources", *someResources)
// {"resources":
{"consumers":[{"plugins":{"key-auth":{"key":"SUPER-SECRET"}}...
```
No current call site does that (`Task.Resources` is a pointer and
`ADCServerRequest.MarshalLog` calls it explicitly), so nothing to fix here —
but a value receiver would make it hold under refactoring, since the pointer
method set includes it either way. Up to you.
Separately, and out of scope for this PR: `translator/httproute.go` still
logs the fully-decoded plugin map from a PluginConfig extensionRef at V(1), and
`translator/gateway.go` does the same for GatewayProxy plugins plus the raw
plugin_metadata blob on unmarshal error. Same "inline plugin credentials" class
you're closing here. Worth a follow-up?
--
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]