mirror of
https://github.com/protocolbuffers/protobuf-go.git
synced 2025-02-21 09:40:03 +00:00
This adds a experimental function to the internal/impl package which validates a wire-format message against a message type. The validator reports whether the message can be successfully unmarshaled, and whether the result is initialized (all required fields are set). In some cases, the validator returns ambiguous results when full validation would be expensive. The validator is unused outside of tests. In the future, it may be used to permit lazy unmarshaling of some data. It is being added now for testing; in particular, the wire fuzzer now checks the validator output for consistency with the unmarshaler. The validator adds a small amount of unused per-MessageType state. If this becomes a concern, we could conditionalize it with a build tag. Change-Id: I4216ef81d6a9ed975302eed189b02d08608858b4 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/212302 Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Fuzzing
Fuzzing support using go-fuzz.
Basic operation:
$ go install github.com/dvyukov/go-fuzz/go-fuzz github.com/dvyukov/go-fuzz/go-fuzz-build
$ cd internal/fuzz/{fuzzer}
$ GOFUZZ111MODULE=on go-fuzz-build .
$ go-fuzz
OSS-Fuzz
Fuzzers are automatically run by OSS-Fuzz.
The OSS-Fuzz configuration currently builds fuzzers in every directory under internal/fuzz. Only add fuzzers (not support packages) in this directory.
Fuzzing results are available at the OSS-Fuzz console,
under golang-protobuf
.