Skip to main content

Module grpc

Module grpc 

Source
Expand description

Minimal gRPC framing + protobuf wire-format extractor (the 9th custom parser in this crate, fuzzed — see ARCHITECTURE §13). Two layers, one linear pass, never panics:

  1. gRPC framing: a body is a sequence of length-prefixed messages [compressed-flag:1][length:4 big-endian][message:length]. We de-frame, count messages/bytes, and flag any compressed frame (the per-message flag bit) — a compressed payload is opaque here, the policy (on_compressed) lives in the module.

  2. protobuf wire-format (NO schema): each field is tag = (field<<3)|wire_type (varint) followed by its value. We walk the fields and, for length-delimited (wire-type 2) fields, apply the heuristic: valid UTF-8 → a leaf string (a content-inspection candidate, fed to the §6 derived channel); otherwise → recurse as a nested sub-message (depth-capped). Varint/fixed fields are skipped.

Honesty (best-effort). The wire format is schema-less and therefore ambiguous by construction: a length-delimited field may be a string, opaque bytes, or an embedded message, and they are indistinguishable without the .proto. So content extraction is best-effort (the same status as GraphQL max_complexity). The guaranteed deliverable is the structural signal — message size, field count, nesting depth, compressed/malformed flags — which the grpc module turns into a Reject. NB: a sub-message whose raw bytes are valid UTF-8 is kept as ONE leaf string; the nested field content is still a substring of it, so a content rule still matches — only the per-field structure is lost, not the payload text.

Structs§

GrpcExtract
Structural metrics + extracted content of a gRPC body.
GrpcLimits
Caps that bound the parser’s own work (anti-DoS during parsing) and surface the structural signal. max_depth/max_fields doubling as the parser bound and the module’s cap is deliberate: parsing past a cap that already forces a Reject is wasted work. max_leaves bounds the extracted content surface.

Functions§

grpc_extract
De-frame body and extract its GrpcExtract. Linear, bounded by limits, no panic.