[#57] core/object: Fix validation of linking object

Linking object carries only identifier of the parent object. Fix Validate
method of FormatValidator to not validate parent object of the linking
object.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-09-29 19:40:25 +03:00 committed by Alex Vanin
parent be322835af
commit 68178b8d74

View file

@ -35,14 +35,19 @@ func (v *FormatValidator) Validate(obj *Object) error {
return errNilCID return errNilCID
} }
for ; obj.GetID() != nil; obj = NewFromSDK(obj.GetParent()) { if err := v.validateSignatureKey(obj); err != nil {
if err := v.validateSignatureKey(obj); err != nil { return errors.Wrapf(err, "(%T) could not validate signature key", v)
return errors.Wrapf(err, "(%T) could not validate signature key", v) }
}
if err := object.CheckHeaderVerificationFields(obj.SDK()); err != nil { if err := object.CheckHeaderVerificationFields(obj.SDK()); err != nil {
return errors.Wrapf(err, "(%T) could not validate header fields", v) return errors.Wrapf(err, "(%T) could not validate header fields", v)
} }
par := NewFromSDK(obj.GetParent())
// validate parent object header
if par.GetID() != nil && len(obj.GetChildren()) == 0 {
return v.Validate(par)
} }
return nil return nil