Documentation
¶
Overview ¶
Package grpcwire reads gRPC request messages without their schema: it splits a body into gRPC messages and finds the text in each protobuf message, for rules to inspect.
Protobuf's wire format doesn't say which length-delimited fields are strings, bytes or nested messages. A field whose bytes are a whole protobuf message is read as one (its fields get their own names); a field whose bytes are UTF-8 is text, whatever its characters. Some bytes are both, and give both. A group is read as a nested message. Binary bytes give their runs of readable text. Numbers outside a length-delimited field and anything that fails to parse give nothing.
Index ¶
Constants ¶
const FrameHeader = 5
FrameHeader is a gRPC message's prefix: a compressed flag (0 or 1) and the message length, 4 bytes big-endian.
Variables ¶
var DefaultLimits = Limits{Depth: 16, Fields: 1024}
DefaultLimits are those the pipeline uses.
Functions ¶
Types ¶
type Field ¶
Field is text found in a message: Name is the path of field numbers from the message, dot-separated ("2.1": field 1 of the message in field 2).
func Strings ¶
Strings returns the text fields of a protobuf message, appended to out, and reports whether the message parsed whole and stayed within lim. A message that doesn't parse gives what was found before the error. A panic while reading (it runs on an adapter's goroutine, which nothing else recovers) is a message not read whole, as one that doesn't parse.
type Limits ¶
type Limits struct {
// Depth is how deep nested messages are read.
Depth int
// Fields is how many text fields are returned.
Fields int
}
Limits bound the work on one body.