Skip to content

Instantly share code, notes, and snippets.

@vadzappa
Created April 9, 2020 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vadzappa/af32632675449c68be9c50ed4b497a6c to your computer and use it in GitHub Desktop.
Save vadzappa/af32632675449c68be9c50ed4b497a6c to your computer and use it in GitHub Desktop.
func sanitize(args ...interface{}) []interface{} {
res := make([]interface{}, 0, len(args))
for _, v := range args {
switch a := v.(type) {
case protoreflect.ProtoMessage:
res = append(res, sanitizeProtoMessage(a))
default:
res = append(res, a)
}
}
return res
}
@bpike0612
Copy link

Hi Vadim, I've been reviewing your Medium article pertaining to this code snippet. do you happen to have the corresponding example project stored in GitHub? I'm having trouble implementing your write-up just going off the snippets provided.

Medium: https://medium.com/pipedrive-engineering/data-logging-with-golang-how-to-store-customer-details-securely-14d49f2cf992

Thanks,
Brett

@vadzappa
Copy link
Author

Hi Brett!

Unfortunately I don't have any public repository which will utilize this, but I would gladly help you finding what might not work well in your scenario. One of the first questions would be which version of go and protobufs you're using? This technique is supported with version of protobufs from March 2nd 2020

@bpike0612
Copy link

Thanks for getting back to me!

Here is a copy of the implementation I put together based on your article: https://github.com/bpike0612/sensitive-data/tree/master

go version: 1.13
protobuf version: protobuf-compiler (3.6.1.3-2ubuntu5)

What I'm finding is in: protocol/company.proto the import "options.proto"; is not recognizing "options.proto" and in logger/sanitize.go on line 12 never recognizes the message as type "protoreflect.ProtoMessage:" so the log output is never redacted.

@vadzappa
Copy link
Author

Posted solution as an issue, since can't push PR for the repository :)

bpike0612/sensitive-data#1

Basically issue is with different protobuf generator. Once I've regenerated files using protoc generator, everything worked as expected

Hopefully this helps

@bpike0612
Copy link

Responded and the help is much appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment