forked from TrueCloudLab/frostfs-node
[#919] pkg/object: Do not accept objects with empty owner
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
7cb3d0cb4a
commit
b148b85af4
2 changed files with 31 additions and 14 deletions
|
@ -14,6 +14,7 @@ Storage Node envs.
|
|||
command (#810)
|
||||
- SN and IR notary deposits are made dynamically depending on the Notary and
|
||||
GAS balances now (#873)
|
||||
- Do not accept objects with empty owner (#841)
|
||||
|
||||
## [0.25.1] - 2021-09-29
|
||||
|
||||
|
|
|
@ -76,7 +76,10 @@ func (v *FormatValidator) Validate(obj *Object) error {
|
|||
return errNilCID
|
||||
}
|
||||
|
||||
for ; obj != nil; obj = obj.GetParent() {
|
||||
if err := v.checkOwner(obj); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := v.checkAttributes(obj); err != nil {
|
||||
return fmt.Errorf("invalid attributes: %w", err)
|
||||
}
|
||||
|
@ -85,7 +88,6 @@ func (v *FormatValidator) Validate(obj *Object) error {
|
|||
return fmt.Errorf("(%T) could not validate signature key: %w", v, err)
|
||||
}
|
||||
|
||||
// TODO: combine small checks
|
||||
if err := v.checkExpiration(obj); err != nil {
|
||||
return fmt.Errorf("object did not pass expiration check: %w", err)
|
||||
}
|
||||
|
@ -93,6 +95,9 @@ func (v *FormatValidator) Validate(obj *Object) error {
|
|||
if err := object.CheckHeaderVerificationFields(obj.SDK()); err != nil {
|
||||
return fmt.Errorf("(%T) could not validate header fields: %w", v, err)
|
||||
}
|
||||
|
||||
if obj = obj.GetParent(); obj != nil {
|
||||
return v.Validate(obj)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -258,6 +263,17 @@ func (v *FormatValidator) checkAttributes(obj *Object) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
var errIncorrectOwner = errors.New("incorrect object owner")
|
||||
|
||||
func (v *FormatValidator) checkOwner(obj *Object) error {
|
||||
// TODO: use appropriate functionality after neofs-api-go#352
|
||||
if len(obj.OwnerID().ToV2().GetValue()) != owner.NEO3WalletSize {
|
||||
return errIncorrectOwner
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// WithNetState returns options to set network state interface.
|
||||
//
|
||||
// FIXME: network state is a required parameter.
|
||||
|
|
Loading…
Reference in a new issue