Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dump protocol-buffers data/response

Is it possible to dump(view) data written in PB format without any knowledge about types used to write that data?

I've found https://stackoverflow.com/a/10253515/883738 that

Briefly, on the wire, protobufs are encoded as 3-tuples of , where the key is the field number assigned to the field in the .proto schema. The type is one of . It contains just enough information to decode the value of the 3-tuple, namely it tells you how long the value is.

What is my final goal is to write extension for Fiddler2 to see what's being sent/received in PB format.

like image 890
Alex Sorokoletov Avatar asked Sep 08 '12 16:09

Alex Sorokoletov


1 Answers

There is a wireshark tool for this, iirc.

The problem here is that the protobuf format is ambiguous if you don't know the schema:

  • a fixed-32 could be a float or a signed or unsigned integer (32 bit)
  • a fixed-64 could be a double or a signed or unsigned integer (64 bit)
  • a varint could be a signed or unsigned integer, a zig-zag integer, or a boolean
  • a string could be a utf-8 string, a packed array of primitives, a sub-message, or raw bytes

In fact, the only unambiguous tokens are start/end group, and they are semi-deprecated!

So: it is sort of doable, but you might need to present multiple interpretations of the same data

You can also only list field numbers: there are no member-names in the binary format

like image 90
Marc Gravell Avatar answered Sep 21 '22 11:09

Marc Gravell