Validate container owner namespace when putting container #819

Merged
fyrchik merged 1 commit from dstepanov-yadro/frostfs-node:feat/ir_validate_namespace into master 2024-09-04 19:51:04 +00:00
  • Dropped old FrostFSID contract client and event handlers (unused)

  • Created new FrostfsID contract client

  • Added container owner namespace validation in container put handler

Closes #755

* Dropped old FrostFSID contract client and event handlers (unused) * Created new FrostfsID contract client * Added container owner namespace validation in `container put` handler Closes #755
dstepanov-yadro requested review from storage-core-committers 2023-11-20 14:41:38 +00:00
dstepanov-yadro requested review from storage-core-developers 2023-11-20 14:41:38 +00:00
dstepanov-yadro force-pushed feat/ir_validate_namespace from 51a2c0a67c to eeb695e1a1 2023-11-20 15:10:37 +00:00 Compare
aarifullin approved these changes 2023-11-21 11:22:10 +00:00
dstepanov-yadro force-pushed feat/ir_validate_namespace from eeb695e1a1 to a302dd6ea9 2023-11-27 07:05:57 +00:00 Compare
aarifullin reviewed 2023-11-27 08:09:09 +00:00
@ -0,0 +17,4 @@
func (c *Client) GetSubject(addr util.Uint160) (*frostfsidclient.Subject, error) {
prm := client.TestInvokePrm{}
prm.SetMethod("getSubject")
Member

prm.SetMethod("getSubject") -> prm.SetMethod(methodGetSubject) ? :)

`prm.SetMethod("getSubject")` -> `prm.SetMethod(methodGetSubject)` ? :)
Author
Member

fixed

fixed
aarifullin marked this conversation as resolved
aarifullin reviewed 2023-11-27 08:15:23 +00:00
@ -0,0 +87,4 @@
func parseMap(item stackitem.Item) (map[string]string, error) {
if item.Equals(stackitem.Null{}) {
return nil, nil
Member

Would not be better to return empty map?

return map[string]string{}, nil

Invoking side may try to get a key from the map if it detects the error is nil

Would not be better to return empty map? ```go return map[string]string{}, nil ``` Invoking side may try to get a key from the map if it detects the error is `nil`
Author
Member

There is the same logic already for arrays:

case stackitem.AnyT:

There is the same logic already for arrays: https://git.frostfs.info/TrueCloudLab/frostfs-node/src/commit/5521737f0b4cf5bb1ae22bfcfb3e7539617e8fd0/pkg/morph/client/util.go#L75
aarifullin marked this conversation as resolved
aarifullin reviewed 2023-11-27 08:18:51 +00:00
@ -0,0 +63,4 @@
}
}
if !structArr[2].Equals(stackitem.Null{}) {
Member

structArr[2] has been already parsed above. Probably, you mean structArr[3]?

`structArr[2]` has been already parsed above. Probably, you mean `structArr[3]`?
Author
Member

fixed

fixed
aarifullin marked this conversation as resolved
dstepanov-yadro force-pushed feat/ir_validate_namespace from a302dd6ea9 to dfc4b6688c 2023-11-27 14:33:30 +00:00 Compare
fyrchik requested changes 2023-11-27 17:17:42 +00:00
@ -263,3 +261,3 @@
MorphClient: cnrClient.Morph(),
FrostFSIDClient: frostfsIDClient,
NetworkState: s.netmapClient,
FrostFSIDClient: frostfsIDClient,
Owner

Why this change?

Why this change?
Author
Member

Fixed. I first completely deleted the old client, then made a new one.

Fixed. I first completely deleted the old client, then made a new one.
fyrchik marked this conversation as resolved
@ -178,0 +182,4 @@
return nil
}
addr, err := util.Uint160DecodeBytesBE(cnr.Owner().WalletBytes()[:util.Uint160Size])
Owner

It should be [1:1+util.Uint160Size], see

copy(x.w[1:], scriptHash.BytesBE())

It should be `[1:1+util.Uint160Size]`, see https://git.frostfs.info/TrueCloudLab/frostfs-sdk-go/src/commit/56debcfa569e69c16e4a7be57d24f95ce2e46ffc/user/id.go#L71
Author
Member

fixed

fixed
fyrchik marked this conversation as resolved
@ -178,0 +193,4 @@
}
if subject.Namespace != namespace {
return fmt.Errorf("container owner doesn't match namespace")
Owner

Maybe container and owner namespaces do not match?

Maybe `container and owner namespaces do not match`?
Author
Member

fixed

fixed
fyrchik marked this conversation as resolved
@ -6,4 +0,0 @@
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
)
type commonBindArgs struct {
Owner

It is frostfs contract (no id), why is it removed here?

It is `frostfs` contract (no `id`), why is it removed here?
Author
Member

There is no usages found.

There is no usages found.
fyrchik marked this conversation as resolved
@ -0,0 +78,4 @@
return &subj, nil
}
func makeValidRes(item stackitem.Item) (*result.Invoke, error) {
Owner

I am not sure wrapping item in result for the sake of parsing is a good approach.
pkg/morph/client/util.go has some helpers, which could be of use here.

I am not sure wrapping item in `result` for the sake of parsing is a good approach. `pkg/morph/client/util.go` has some helpers, which could be of use here.
Author
Member

I think it is ok, because wrapping allows to use native neo-go's methods.

I think it is ok, because wrapping allows to use native neo-go's methods.
fyrchik marked this conversation as resolved
dstepanov-yadro force-pushed feat/ir_validate_namespace from dfc4b6688c to 88aee2d724 2023-11-28 06:51:19 +00:00 Compare
dstepanov-yadro requested review from fyrchik 2023-11-28 06:54:35 +00:00
acid-ant approved these changes 2023-11-29 14:37:26 +00:00
aarifullin approved these changes 2023-11-29 14:41:07 +00:00
dstepanov-yadro force-pushed feat/ir_validate_namespace from 88aee2d724 to 9b49908404 2023-11-30 14:02:44 +00:00 Compare
Owner

Ready to merge, please fix the conflicts.

Ready to merge, please fix the conflicts.
fyrchik approved these changes 2023-12-11 13:16:15 +00:00
dstepanov-yadro force-pushed feat/ir_validate_namespace from 9b49908404 to 7cfbad99a5 2023-12-11 13:20:10 +00:00 Compare
dstepanov-yadro force-pushed feat/ir_validate_namespace from 7cfbad99a5 to a3ef7b58b4 2023-12-12 09:36:58 +00:00 Compare
fyrchik merged commit a3ef7b58b4 into master 2023-12-12 09:37:56 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: TrueCloudLab/frostfs-node#819
No description provided.