[#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,23 +76,28 @@ func (v *FormatValidator) Validate(obj *Object) error {
|
|||
return errNilCID
|
||||
}
|
||||
|
||||
for ; obj != nil; obj = obj.GetParent() {
|
||||
if err := v.checkAttributes(obj); err != nil {
|
||||
return fmt.Errorf("invalid attributes: %w", err)
|
||||
}
|
||||
if err := v.checkOwner(obj); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := v.validateSignatureKey(obj); err != nil {
|
||||
return fmt.Errorf("(%T) could not validate signature key: %w", v, err)
|
||||
}
|
||||
if err := v.checkAttributes(obj); err != nil {
|
||||
return fmt.Errorf("invalid attributes: %w", err)
|
||||
}
|
||||
|
||||
// TODO: combine small checks
|
||||
if err := v.checkExpiration(obj); err != nil {
|
||||
return fmt.Errorf("object did not pass expiration check: %w", err)
|
||||
}
|
||||
if err := v.validateSignatureKey(obj); err != nil {
|
||||
return fmt.Errorf("(%T) could not validate signature key: %w", v, err)
|
||||
}
|
||||
|
||||
if err := object.CheckHeaderVerificationFields(obj.SDK()); err != nil {
|
||||
return fmt.Errorf("(%T) could not validate header fields: %w", v, err)
|
||||
}
|
||||
if err := v.checkExpiration(obj); err != nil {
|
||||
return fmt.Errorf("object did not pass expiration check: %w", err)
|
||||
}
|
||||
|
||||
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