Skip to content

Commit a963729

Browse files
committed
node/object: Check signature and ID separately
Previously, we checked signature itself, then ID, then signature agains the session token. Signed-off-by: Leonard Lyubich <[email protected]>
1 parent 9c95884 commit a963729

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

pkg/core/object/fmt.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,15 @@ func (v *FormatValidator) Validate(obj *object.Object, unprepared bool) error {
161161
if !obj.VerifySignature() {
162162
return errors.New("could not validate header fields: invalid signature")
163163
}
164-
if err := obj.VerifyID(); err != nil {
165-
return fmt.Errorf("could not validate header fields: invalid identifier: %w", err)
166-
}
167164

168165
if err := validateSignatureKey(obj); err != nil {
169166
return fmt.Errorf("could not validate signature key: %w", err)
170167
}
171168

169+
if err := obj.VerifyID(); err != nil {
170+
return fmt.Errorf("invalid identifier: %w", err)
171+
}
172+
172173
if err := v.checkExpiration(*obj); err != nil {
173174
return fmt.Errorf("object did not pass expiration check: %w", err)
174175
}

pkg/core/object/fmt_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func TestFormatValidator_Validate(t *testing.T) {
9797
require.ErrorIs(t, v.Validate(&obj, false), errNilID)
9898
})
9999
t.Run("wrong", func(t *testing.T) {
100-
require.EqualError(t, v.Validate(&wrongIDECDSASHA512, false), "could not validate header fields: invalid identifier: incorrect object identifier")
100+
require.EqualError(t, v.Validate(&wrongIDECDSASHA512, false), "invalid identifier: incorrect object identifier")
101101
})
102102
})
103103

0 commit comments

Comments
 (0)