From 766eea4c8c17ff7163f335aeac175528592ae558 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Tue, 3 Nov 2020 12:08:24 +0300 Subject: [PATCH] [#85] services/container: Check container format in Put Call CheckFormat function in container.Put handler for conducting initial checks of the structure that are not performed by the smart contract. Signed-off-by: Leonard Lyubich --- pkg/services/container/morph/executor.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/services/container/morph/executor.go b/pkg/services/container/morph/executor.go index 24b523173..47ea3092e 100644 --- a/pkg/services/container/morph/executor.go +++ b/pkg/services/container/morph/executor.go @@ -8,9 +8,11 @@ import ( "github.com/nspcc-dev/neofs-api-go/pkg/owner" "github.com/nspcc-dev/neofs-api-go/v2/container" "github.com/nspcc-dev/neofs-api-go/v2/refs" + containerCore "github.com/nspcc-dev/neofs-node/pkg/core/container" containerMorph "github.com/nspcc-dev/neofs-node/pkg/morph/client/container" "github.com/nspcc-dev/neofs-node/pkg/morph/client/container/wrapper" containerSvc "github.com/nspcc-dev/neofs-node/pkg/services/container" + "github.com/pkg/errors" ) type morphExecutor struct { @@ -33,6 +35,10 @@ func (s *morphExecutor) Put(ctx context.Context, body *container.PutRequestBody) cnr := containerSDK.NewContainerFromV2(body.GetContainer()) sig := body.GetSignature() + if err := containerCore.CheckFormat(cnr); err != nil { + return nil, errors.Wrapf(err, "incorrect container format") + } + cid, err := s.wrapper.Put(cnr, sig.GetKey(), sig.GetSign()) if err != nil { return nil, err