-
Notifications
You must be signed in to change notification settings - Fork 1.6k
customizible encoder to hide/redact sensitive information #1541
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
Comments
Hi ofen, Sorry for the late reply. I think to design a generic solution for such a problem is a large task and requires a lot of design work to make sure it works properly for all cases. Unfortunately, I don't think we have the capacity to design and implement such a solution at the moment. It might be possible for you to implement the
If you do not want to modify the message, you might be able to I'm not sure I understand what you mean by the alternatives you described. To which internal parts would you need access to implement this? |
Hi, sorry for late reply. Protobuf redaction with following marshaling performs poorly due to double iteration over nested elements. Internal part that could be used for redaction functionality, but lacks public interface to modify it's behaviour: https://github.com/protocolbuffers/protobuf-go/blob/b8fc7706010499f46982c883add4351b12e30c0b/encoding/protojson/encode.go#L259 |
I agree that the double iteration approach is more expensive than if there were hooks directly in the encoder. Do you have an idea how large the performance overhead is/would be? While double iteration can be cause performance issues, it is generally fairly fast. Are the messages you are dealing with deeply nested and have many fields? Are there other reasons that make the iteration expensive? All that said, I want to be honest and I don't think we have the capacity to design this API extension in the near future. |
@lfolger, Hello, I've came across this issue with same questions as the @ofen. My proposal is to extract the visitFunction and make it default visitFunction for MarshalOptions. So it will look like this:
If it looks good enough I can make a PR with the implementation. However if it is too open realisation or too customisable, I can figure out something else |
Would |
The About the mutating the original object, I think it is up to library user to mutate the values so general usage would look like
|
@Olex1313 this would require us to exposse the encoder because it is used in the code 228+. This is a quite large change and I don't think we can do this right now without sufficient evidence that it has a significant impact. Again, if you can share some pprof profiles or benchmarks that show the difference, it would help us to evaluate such a change. |
@lfolger, you are right, I'm writing clone-based solution right now, I will provide benchmarks when I finish to see if it is really that necessary, but for repeated fields or maps I think it would be great to have a cheap masking option |
@Olex1313 have you started the project? мне тоже нужно) |
@ofen, sorry for late answer, been quiet busy. |
Hi @Olex1313 do you mind to share the progress? Recently i'm looking for a solution of this issue. I also try to do some research and update. If you guys don't mind i can try to update, but need your help to review it. My solution is that:
please let me know if this update is not suitable or can have issue. |
@Mahes2, I can not share the benchmarks (did it for work), but as the @puellanivis said it's very complex design issue in protobuff serialization, and this doesn't go well with the purpose of Proto to JSON, because it works only in one way, but obviously you can't convert json->proto afterwards. I've shared a gist https://gist.github.com/Olex1313/88ff52b1f4cad1af15c6733b4553b4cb, it contains sample approach to clearing the message for logs/etc. For implementation in https://github.com/golang/protobuf I think it should be a third-party library, but not the part of it |
I see. but is it ok if i give contribution to add new tag and using the approach i have given above?
why it should be a 3rd party library? |
It's up to maintainers, if they are ok with such approach I would like to help w code/review
As @lfolger said upwards, designing custom deserialization api is out of context of encoder api, because it provides a simple way of ser/des of proto objects. Hiding sensible data is not the single feature that should be provided, and api should be extendable for more than that. |
I think implementing redaction logic inside protojson serialiser is bad idea, but it still good idea to have some internal parts accessible/public to let developers build their custom logic upon it. |
Unfortunately, this is—as I said in your first issue—not going to be accepted. This package needs to stick fairly strictly to the protobuf standard, and this feature is definitely something that we don’t want to walk into. (Even adding the |
Hi @puellanivis can you share me any doc or blog that has explaination about the protobuf standard? because i still don't know which standard that you are talking about. Also, is the proper JSON mapping already in progress? Finally, i thank you guys for giving the tips on how to handle the sensitive message. I did a little update with @Olex1313's suggestion and add it to my libs. I have made a PR and it's also included with the benchmark |
https://protobuf.dev/programming-guides/proto3/ is the proto3 standard. The proper JSON mapping is already complete, and done. It was done for v1 API with |
Is your feature request related to a problem? Please describe.
We need ability to hide sensitive information during pb to json encoding.
Describe the solution you'd like
Customizible encoder that will allow to work with options (see https://go.dev/blog/protobuf-apiv2).
Describe alternatives you've considered
Make most of internal parts importable to minimize copy-paste.
Additional context
None
The text was updated successfully, but these errors were encountered: