mirror of
https://github.com/nspcc-dev/neofs-api-go.git
synced 2026-03-01 04:28:56 +00:00
Stable marshaller produces different wire for nil structure #75
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @alexvanin on GitHub (Apr 25, 2022).
Originally assigned to: @fyrchik on GitHub.
Here is the example where stable marshaler produces different wire data compare to default
proto.Marshaler.This can lead to unexpected signature check failures, because client side calls
StableMarshal()to generate signature, and server side callsproto.Unmarshal() + StableMarshal(). They produce different wire output which leads to signature check failure.We mostly avoid
nilstructures, but clarification of expected behavior will be appreciated.@alexvanin commented on GitHub (Apr 25, 2022):
A bit of clarification.
(1) Client side sets
nilstructure to repeated list of attributes, usesStableMarshal()and generates message based on[]byte{0x1a, 0x0}value.(2) Then client sends structure to the server over
gRPCwhich usesproto.Marshalwith[]byte{0x1a, 0x2, 0x52, 0x0}wire.(3) Server receives
[]byte{0x1a, 0x2, 0x52, 0x0}and unmarshals it to a list with empty attribute value(4) Server calls
StableMarshal()and generates message based on[]byte{0x1a, 0x2, 0x52, 0x0}value(5) Signature check fails.
Can be fixed by https://github.com/nspcc-dev/neofs-api-go/issues/384 probably, but this is a long-term issue.
@alexvanin commented on GitHub (Apr 26, 2022):
This is not the case for
object.Attributeafter https://github.com/nspcc-dev/neofs-api-go/pull/377 but we still have some pointer slices here and there.@fyrchik commented on GitHub (Apr 26, 2022):
I believe, we have slices of pointers only in
grpcsub-packages or in conversion functions.If we are talking about the spec only, what about disallowing to have
nilin slices completely? List of attributes, ID's etc. should always be filled.@alexvanin commented on GitHub (Apr 26, 2022):
Seems good enough. So we can say that properties of stable marshaling are:
nilmessages as non-existing inrepeatedfields.If everyone agree with that, the issue can be closed.
@cthulhu-rider commented on GitHub (May 16, 2022):
👍