Skip to content

Add protoscope language, assembler, disassembler#734

Open
sudorandom wants to merge 1 commit into
bufbuild:mainfrom
sudorandom:protoscope
Open

Add protoscope language, assembler, disassembler#734
sudorandom wants to merge 1 commit into
bufbuild:mainfrom
sudorandom:protoscope

Conversation

@sudorandom

Copy link
Copy Markdown

Description

Adds protoscope, a human-readable text format for raw Protobuf binary wire payloads, to protocompile. It enables writing, parsing, compiling (assembly), and decompiling (disassembly) without requiring a schema. It supports multi-frame documents (separated by ---) and transport framing (gRPC, ConnectRPC, and Varint delimited).

Key Changes

  • Parser & AST (internal/protoscope/parser, internal/protoscope/ast): Parses tokens into an AST of fields, blocks (groups/length-delimited), values, and options.
  • Assembler (internal/protoscope/assembler): Compiles AST nodes into raw Protobuf wire format.
  • Disassembler (internal/protoscope/disassembler): Decompiles binary Protobuf payloads back to protoscope text format using heuristics.
  • Public API (protoscope): Exposes public endpoints (Assemble, Disassemble, Diagnostics, Hover, and Possibilities) for integrations (e.g. Buf LSP). Handles frame splitting/joining, flags parsing, and context-aware hover info.
  • Fuzz tests and a few related fixes as a result of the fuzz testing. Changes in experimental/internal/lexer/number.go is an example of changes made to avoid a DoS vector that was revealed with this testing.

Adds `protoscope`, a human-readable text format for raw Protobuf binary wire payloads, to `protocompile`. It enables writing, parsing, compiling (assembly), and decompiling (disassembly) without requiring a schema. It supports multi-frame documents (separated by `---`) and transport framing (gRPC, ConnectRPC, and Varint delimited).

- **Parser & AST (`internal/protoscope/parser`, `internal/protoscope/ast`)**: Parses tokens into an AST of fields, blocks (groups/length-delimited), values, and options.
- **Assembler (`internal/protoscope/assembler`)**: Compiles AST nodes into raw Protobuf wire format.
- **Disassembler (`internal/protoscope/disassembler`)**: Decompiles binary Protobuf payloads back to protoscope text format using heuristics.
- **Public API (`protoscope`)**: Exposes public endpoints (`Assemble`, `Disassemble`, `Diagnostics`, `Hover`, and `Possibilities`) for integrations (e.g. Buf LSP). Handles frame splitting/joining, flags parsing, and context-aware hover info.
- `Fuzz tests` and a few related fixes as a result of the fuzz testing. Changes in `experimental/internal/lexer/number.go` is an example of changes made to avoid a DoS vector that was revealed with this testing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant