[#1383] object: Add restrictions for Patch method
Some checks failed
Pre-commit hooks / Pre-commit (pull_request) Successful in 2m54s
Vulncheck / Vulncheck (pull_request) Successful in 2m51s
Build / Build Components (pull_request) Successful in 4m14s
DCO action / DCO (pull_request) Successful in 40s
Tests and linters / Run gofumpt (pull_request) Successful in 45s
Tests and linters / gopls check (pull_request) Successful in 2m17s
Tests and linters / Staticcheck (pull_request) Successful in 2m20s
Tests and linters / Lint (pull_request) Failing after 2m38s
Tests and linters / Tests (pull_request) Successful in 3m33s
Tests and linters / Tests with -race (pull_request) Successful in 4m19s

* `Patch` can't be applied for non-regular type object (tombstones,
  locks etc.)
* Complex object parts can't be patched. So, if an object has EC/Split
  header, it won't be patched.

Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
Airat Arifullin 2024-09-18 12:13:15 +03:00
parent d4bec24c9f
commit 3e78a1de57

View file

@ -63,6 +63,14 @@ func (s *Streamer) init(ctx context.Context, req *objectV2.PatchRequest) error {
return err return err
} }
if hdrWithSig.GetHeader().GetObjectType() != objectV2.TypeRegular {
return errors.New("non-regular object can't be patched")
}
if hdrWithSig.GetHeader().GetEC() != nil || hdrWithSig.GetHeader().GetSplit() != nil {
return errors.New("complex object parts can't be patched")
}
commonPrm, err := util.CommonPrmFromV2(req) commonPrm, err := util.CommonPrmFromV2(req)
if err != nil { if err != nil {
return err return err