github.com/Finschia/finschia-sdk@v0.48.1/codec/unknownproto/doc.go (about) 1 /* 2 unknownproto implements functionality to "type check" protobuf serialized byte sequences 3 against an expected proto.Message to report: 4 5 a) Unknown fields in the stream -- this is indicative of mismatched services, perhaps a malicious actor 6 7 b) Mismatched wire types for a field -- this is indicative of mismatched services 8 9 Its API signature is similar to proto.Unmarshal([]byte, proto.Message) in the strict case 10 11 if err := RejectUnknownFieldsStrict(protoBlob, protoMessage, false); err != nil { 12 // Handle the error. 13 } 14 15 and ideally should be added before invoking proto.Unmarshal, if you'd like to enforce the features mentioned above. 16 17 By default, for security we report every single field that's unknown, whether a non-critical field or not. To customize 18 this behavior, please set the boolean parameter allowUnknownNonCriticals to true to RejectUnknownFields: 19 20 if err := RejectUnknownFields(protoBlob, protoMessage, true); err != nil { 21 // Handle the error. 22 } 23 */ 24 package unknownproto