-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mapstr: M.Format and M.MarshalLogObject and mutate nested fields #232
Comments
This seems important or severe because it has the potential to "corrupt" data being sent to Elasticsearch, particularly when debug is enabled. I did a very narrow, non-exhaustive search in Beats, and there are cases where this could occur such as
My immediate concern is to ensure data cannot be mutated as a side-effect of logging. Secondarily, I think separation of concerns should be reconsidered for |
For redaction, I would suggest that one of the shim layers in logp makes a conditional call based on whether the value implements a (bikeshed) |
Redaction makes sense to me in the logger, see elastic/elastic-agent#5675 for a place where we'd immediately use this. I think the key would be making it impossible to forget to redact, without mandatory redaction imposing significant performance overhead. |
Currently, when
M.Format
orMarshalLogObject
are called, they result in the mutation of the receiver. This leads to the unexpected mutation of values when printing or loggingmapstr.M
.This is demonstrated by running the following program.
output:
https://go.dev/play/p/rviU45kYeOk
The underlying cause of this is that
mapstr.M.Clone
, while claiming to deep copy the receiver, does not when it comes to slices or array; only shallow copies are made when any value that is not assignable to amapstr.M
is encountered.The text was updated successfully, but these errors were encountered: