1

I have some arbitrary Google Protocol Buffers message as a byte string that I have no descriptor for. How can I iterate throughout it's fields and check their values? It's fine if they would be represented as just some general bytes arrays without names.

I digged all over the google, stackoverflow and original reference for Protocol Buffers with no use. Reflection module for Python does not help as well and can't actually reflect insides of arbitrary message.

Again: I have no any descriptor for my message at all, still need to list it's fields, so this does not answer.

username
  • 337
  • 3
  • 11
  • I don't know much, but I think protobuf is compressed in ways that make it impossible to access the message's names without the original message schema. – byxor Jul 05 '19 at 04:27
  • @PeterGibson like I said, I've digged stackoverflow with that post as well and it does not answer since I have no any descriptor for my message at all, still need to list it's fields. Please read carefully. – username Jul 05 '19 at 04:39
  • Iterating over fields without schema is possible - I do it here https://protogen.marcgravell.com/decode - but I don't know if there's a Python API for it. Also, the protocol is ambiguous: the same bytes can mean different things and you would have to infer the meaning. For example, a "string" could be a utf8 string, a packed array of primitives, a sub-message, or a "bytes" raw chunk. Also, there are no field names: just numbers. – Marc Gravell Jul 06 '19 at 07:05
  • @MarcGravell thanks for link! Numbers would be totally fine. As well as ambigous data type. By now I just did some raw template of "scanner" message with about 10 fields of bytes with consequent ids and read my messages with it. I would like to have some general solution for this though. – username Jul 06 '19 at 08:31
  • @gerrBen you're looking for a reader/parser API. Maybe "CodedInputStream" if I remember Google's naming conventions. – Marc Gravell Jul 06 '19 at 23:15

0 Answers0