From 0f503bc859ecf139b784a77dc3ba74f742d1f238 Mon Sep 17 00:00:00 2001 From: jkoberg Date: Thu, 8 Aug 2024 11:24:27 +0200 Subject: [PATCH] feat(reva): bump reva Signed-off-by: jkoberg --- changelog/unreleased/bump-reva.md | 1 + go.mod | 2 +- go.sum | 4 +- .../http/services/owncloud/ocdav/copy.go | 9 +++- .../handlers/apps/sharing/shares/public.go | 15 ++++--- .../handlers/apps/sharing/shares/shares.go | 6 +-- .../ocs/handlers/apps/sharing/shares/user.go | 45 ++++++++++++------- .../tusd/v2/pkg/handler/unrouted_handler.go | 19 ++++++++ vendor/modules.txt | 2 +- 9 files changed, 75 insertions(+), 28 deletions(-) diff --git a/changelog/unreleased/bump-reva.md b/changelog/unreleased/bump-reva.md index ffb06ca615..d83dee9af2 100644 --- a/changelog/unreleased/bump-reva.md +++ b/changelog/unreleased/bump-reva.md @@ -1,4 +1,5 @@ Enhancement: Bump reva +https://github.com/owncloud/ocis/pull/9763 https://github.com/owncloud/ocis/pull/9714 https://github.com/owncloud/ocis/pull/9715 diff --git a/go.mod b/go.mod index d29495ee3d..b9fdd197af 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/cenkalti/backoff v2.2.1+incompatible github.com/coreos/go-oidc/v3 v3.11.0 github.com/cs3org/go-cs3apis v0.0.0-20240724121416-062c4e3046cb - github.com/cs3org/reva/v2 v2.22.1-0.20240806075425-8bcdd93dfa20 + github.com/cs3org/reva/v2 v2.22.1-0.20240809114512-56b26ddd82cc github.com/dhowden/tag v0.0.0-20230630033851-978a0926ee25 github.com/dutchcoders/go-clamd v0.0.0-20170520113014-b970184f4d9e github.com/egirna/icap-client v0.1.1 diff --git a/go.sum b/go.sum index 3d36d288f0..ba52f14e52 100644 --- a/go.sum +++ b/go.sum @@ -262,8 +262,8 @@ github.com/crewjam/saml v0.4.14 h1:g9FBNx62osKusnFzs3QTN5L9CVA/Egfgm+stJShzw/c= github.com/crewjam/saml v0.4.14/go.mod h1:UVSZCf18jJkk6GpWNVqcyQJMD5HsRugBPf4I1nl2mME= github.com/cs3org/go-cs3apis v0.0.0-20240724121416-062c4e3046cb h1:KmYZDReplv/yfwc1LNYpDcVhVujC3Pasv6WjXx1haSU= github.com/cs3org/go-cs3apis v0.0.0-20240724121416-062c4e3046cb/go.mod h1:yyP8PRo0EZou3nSH7H4qjlzQwaydPeIRNgX50npQHpE= -github.com/cs3org/reva/v2 v2.22.1-0.20240806075425-8bcdd93dfa20 h1:GVxOUoabZQ5kgeS3oBOHZZn+sY0Sb5VOyhjsEFttJ4g= -github.com/cs3org/reva/v2 v2.22.1-0.20240806075425-8bcdd93dfa20/go.mod h1:l/llk1KaiB/XiJYfk+gznzkXZqVv+TbxJKgDbpti444= +github.com/cs3org/reva/v2 v2.22.1-0.20240809114512-56b26ddd82cc h1:ctPVsRj/QeWhYpNDAkUFXsBgtcR/PPsehdk8AIMLHok= +github.com/cs3org/reva/v2 v2.22.1-0.20240809114512-56b26ddd82cc/go.mod h1:p7CHBXcg6sSqB+0JMNDfC1S7TSh9FghXkw1kTV3KcJI= github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4= github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/copy.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/copy.go index cccc3c2f08..73e3129093 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/copy.go +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/copy.go @@ -697,7 +697,14 @@ func (s *svc) prepareCopy(ctx context.Context, w http.ResponseWriter, r *http.Re // we must not allow to override mountpoints - so we check if we have access to the parent. If not this is a mountpoint if destInShareJail { - dir, file := filepath.Split(dstRef.GetPath()) + res, err := client.GetPath(ctx, &provider.GetPathRequest{ResourceId: dstStatRes.GetInfo().GetId()}) + if err != nil || res.GetStatus().GetCode() != rpc.Code_CODE_OK { + log.Error().Err(err).Msg("error sending grpc get path request") + w.WriteHeader(http.StatusInternalServerError) + return nil + } + + dir, file := filepath.Split(filepath.Clean(res.GetPath())) if dir == "/" || dir == "" || file == "" { log.Error().Msg("must not overwrite mount points") w.WriteHeader(http.StatusBadRequest) diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/public.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/public.go index 25da16b6dc..35e8637d90 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/public.go +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/public.go @@ -295,12 +295,17 @@ func (h *Handler) isPublicShare(r *http.Request, oid string) (*link.PublicShare, }, }, }) - if err != nil { - logger.Err(err) - return nil, false + switch { + case err != nil: + log.Err(err).Send() + case psRes.Status.Code == rpc.Code_CODE_OK: + return psRes.GetShare(), psRes.GetShare() != nil + case psRes.Status.Code == rpc.Code_CODE_INTERNAL: + log.Error().Str("message", psRes.GetStatus().GetMessage()).Str("code", psRes.GetStatus().GetCode().String()).Msg("isPublicShare received internal error") + default: + log.Debug().Str("message", psRes.GetStatus().GetMessage()).Str("code", psRes.GetStatus().GetCode().String()).Msg("isPublicShare received unexpected status") } - - return psRes.GetShare(), psRes.GetShare() != nil + return nil, false } func (h *Handler) updatePublicShare(w http.ResponseWriter, r *http.Request, share *link.PublicShare) { diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go index 02d92344f1..1136ded122 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go @@ -634,7 +634,7 @@ func (h *Handler) GetShare(w http.ResponseWriter, r *http.Request) { } } - if share == nil { + if h.listOCMShares && share == nil { // check if we have a federated share req := &ocm.GetOCMShareRequest{ Ref: &ocm.ShareReference{ @@ -662,7 +662,7 @@ func (h *Handler) GetShare(w http.ResponseWriter, r *http.Request) { } } - if share == nil { + if h.listOCMShares && share == nil { // check if we have an incoming federated share req := &ocm.GetReceivedOCMShareRequest{ Ref: &ocm.ShareReference{ @@ -912,7 +912,7 @@ func (h *Handler) RemoveShare(w http.ResponseWriter, r *http.Request) { h.removeUserShare(w, r, share) return } - if h.isFederatedShare(r, shareID) { + if h.listOCMShares && h.isFederatedShare(r, shareID) { h.removeFederatedShare(w, r, shareID) return } diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/user.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/user.go index 65247a9443..52281b91c8 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/user.go +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/user.go @@ -132,10 +132,10 @@ func (h *Handler) createUserShare(w http.ResponseWriter, r *http.Request, statIn } func (h *Handler) isUserShare(r *http.Request, oid string) (*collaboration.Share, bool) { - logger := appctx.GetLogger(r.Context()) + log := appctx.GetLogger(r.Context()) client, err := pool.GetGatewayServiceClient(h.gatewayAddr) if err != nil { - logger.Err(err) + log.Err(err).Send() } getShareRes, err := client.GetShare(r.Context(), &collaboration.GetShareRequest{ @@ -147,12 +147,17 @@ func (h *Handler) isUserShare(r *http.Request, oid string) (*collaboration.Share }, }, }) - if err != nil { - logger.Err(err) - return nil, false + switch { + case err != nil: + log.Err(err).Send() + case getShareRes.Status.Code == rpc.Code_CODE_OK: + return getShareRes.GetShare(), true + case getShareRes.Status.Code == rpc.Code_CODE_INTERNAL: + log.Error().Str("message", getShareRes.GetStatus().GetMessage()).Str("code", getShareRes.GetStatus().GetCode().String()).Msg("isUserShare received internal error") + default: + log.Debug().Str("message", getShareRes.GetStatus().GetMessage()).Str("code", getShareRes.GetStatus().GetCode().String()).Msg("isUserShare received unexpected status") } - - return getShareRes.GetShare(), getShareRes.GetShare() != nil + return nil, false } func (h *Handler) isFederatedShare(r *http.Request, shareID string) bool { @@ -172,12 +177,17 @@ func (h *Handler) isFederatedShare(r *http.Request, shareID string) bool { }, }, }) - if err != nil { + switch { + case err != nil: log.Err(err).Send() - return false + case getShareRes.Status.Code == rpc.Code_CODE_OK: + return true + case getShareRes.Status.Code == rpc.Code_CODE_INTERNAL: + log.Error().Str("message", getShareRes.GetStatus().GetMessage()).Str("code", getShareRes.GetStatus().GetCode().String()).Msg("isFederatedShare received internal error") + default: + log.Debug().Str("message", getShareRes.GetStatus().GetMessage()).Str("code", getShareRes.GetStatus().GetCode().String()).Msg("isFederatedShare received unexpected status") } - - return getShareRes.GetShare() != nil + return false } func (h *Handler) removeFederatedShare(w http.ResponseWriter, r *http.Request, shareID string) { @@ -247,12 +257,17 @@ func (h *Handler) isFederatedReceivedShare(r *http.Request, shareID string) bool }, }, }) - if err != nil { + switch { + case err != nil: log.Err(err).Send() - return false + case getShareRes.Status.Code == rpc.Code_CODE_OK: + return true + case getShareRes.Status.Code == rpc.Code_CODE_INTERNAL: + log.Error().Str("message", getShareRes.GetStatus().GetMessage()).Str("code", getShareRes.GetStatus().GetCode().String()).Msg("isFederatedReceivedShare received internal error") + default: + log.Debug().Str("message", getShareRes.GetStatus().GetMessage()).Str("code", getShareRes.GetStatus().GetCode().String()).Msg("isFederatedReceivedShare received unexpected status") } - - return getShareRes.GetShare() != nil + return false } func (h *Handler) removeUserShare(w http.ResponseWriter, r *http.Request, share *collaboration.Share) { diff --git a/vendor/github.com/tus/tusd/v2/pkg/handler/unrouted_handler.go b/vendor/github.com/tus/tusd/v2/pkg/handler/unrouted_handler.go index 73be46437e..b91161bb75 100644 --- a/vendor/github.com/tus/tusd/v2/pkg/handler/unrouted_handler.go +++ b/vendor/github.com/tus/tusd/v2/pkg/handler/unrouted_handler.go @@ -691,12 +691,14 @@ func (handler *UnroutedHandler) HeadFile(w http.ResponseWriter, r *http.Request) // PatchFile adds a chunk to an upload. This operation is only allowed // if enough space in the upload is left. func (handler *UnroutedHandler) PatchFile(w http.ResponseWriter, r *http.Request) { + fmt.Println("PATCH FILE") c := handler.getContext(w, r) isTusV1 := !handler.usesIETFDraft(r) // Check for presence of application/offset+octet-stream if isTusV1 && r.Header.Get("Content-Type") != "application/offset+octet-stream" { + fmt.Println("WRONG CONTENT TYPE") handler.sendError(c, ErrInvalidContentType) return } @@ -704,12 +706,14 @@ func (handler *UnroutedHandler) PatchFile(w http.ResponseWriter, r *http.Request // Check for presence of a valid Upload-Offset Header offset, err := strconv.ParseInt(r.Header.Get("Upload-Offset"), 10, 64) if err != nil || offset < 0 { + fmt.Println("WRONG OFFSET") handler.sendError(c, ErrInvalidOffset) return } id, err := extractIDFromPath(r.URL.Path) if err != nil { + fmt.Println("WRONG ID") handler.sendError(c, err) return } @@ -718,6 +722,7 @@ func (handler *UnroutedHandler) PatchFile(w http.ResponseWriter, r *http.Request if handler.composer.UsesLocker { lock, err := handler.lockUpload(c, id) if err != nil { + fmt.Println("WRONG LOCK") handler.sendError(c, err) return } @@ -727,23 +732,27 @@ func (handler *UnroutedHandler) PatchFile(w http.ResponseWriter, r *http.Request upload, err := handler.composer.Core.GetUpload(c, id) if err != nil { + fmt.Println("WRONG UPLOAD") handler.sendError(c, err) return } info, err := upload.GetInfo(c) if err != nil { + fmt.Println("WRONG INFO") handler.sendError(c, err) return } // Modifying a final upload is not allowed if info.IsFinal { + fmt.Println("WRONG FINAL") handler.sendError(c, ErrModifyFinal) return } if offset != info.Offset { + fmt.Println("WRONG INFO OFFSET") handler.sendError(c, ErrMismatchOffset) return } @@ -760,27 +769,32 @@ func (handler *UnroutedHandler) PatchFile(w http.ResponseWriter, r *http.Request // Do not proxy the call to the data store if the upload is already completed if !info.SizeIsDeferred && info.Offset == info.Size { resp.Header["Upload-Offset"] = strconv.FormatInt(offset, 10) + fmt.Println("UPLOAD ALREADY COMPLETED") handler.sendResp(c, resp) return } if r.Header.Get("Upload-Length") != "" { if !handler.composer.UsesLengthDeferrer { + fmt.Println("UPLOAD LENGTH DEFERRER") handler.sendError(c, ErrNotImplemented) return } if !info.SizeIsDeferred { + fmt.Println("UPLOAD LENGTH NOT DEFERED") handler.sendError(c, ErrInvalidUploadLength) return } uploadLength, err := strconv.ParseInt(r.Header.Get("Upload-Length"), 10, 64) if err != nil || uploadLength < 0 || uploadLength < info.Offset || (handler.config.MaxSize > 0 && uploadLength > handler.config.MaxSize) { + fmt.Println("UPLOAD LENGTH INVALID") handler.sendError(c, ErrInvalidUploadLength) return } lengthDeclarableUpload := handler.composer.LengthDeferrer.AsLengthDeclarableUpload(upload) if err := lengthDeclarableUpload.DeclareLength(c, uploadLength); err != nil { + fmt.Println("UPLOAD LENGTH DECLARED") handler.sendError(c, err) return } @@ -791,6 +805,7 @@ func (handler *UnroutedHandler) PatchFile(w http.ResponseWriter, r *http.Request resp, err = handler.writeChunk(c, resp, upload, info) if err != nil { + fmt.Println("CANT WRITE CHUNK") handler.sendError(c, err) return } @@ -799,6 +814,7 @@ func (handler *UnroutedHandler) PatchFile(w http.ResponseWriter, r *http.Request if willCompleteUpload && info.SizeIsDeferred { info, err = upload.GetInfo(c) if err != nil { + fmt.Println("CANT GET INFO") handler.sendError(c, err) return } @@ -807,6 +823,7 @@ func (handler *UnroutedHandler) PatchFile(w http.ResponseWriter, r *http.Request lengthDeclarableUpload := handler.composer.LengthDeferrer.AsLengthDeclarableUpload(upload) if err := lengthDeclarableUpload.DeclareLength(c, uploadLength); err != nil { + fmt.Println("CANT UPLOAD LENGTH") handler.sendError(c, err) return } @@ -816,12 +833,14 @@ func (handler *UnroutedHandler) PatchFile(w http.ResponseWriter, r *http.Request resp, err = handler.finishUploadIfComplete(c, resp, upload, info) if err != nil { + fmt.Println("CANT COMPLETE") handler.sendError(c, err) return } } handler.sendResp(c, resp) + fmt.Println("PATCH COMPLETE") } // writeChunk reads the body from the requests r and appends it to the upload diff --git a/vendor/modules.txt b/vendor/modules.txt index 83ffd5193d..c2cb30d3ad 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -367,7 +367,7 @@ github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1 github.com/cs3org/go-cs3apis/cs3/storage/registry/v1beta1 github.com/cs3org/go-cs3apis/cs3/tx/v1beta1 github.com/cs3org/go-cs3apis/cs3/types/v1beta1 -# github.com/cs3org/reva/v2 v2.22.1-0.20240806075425-8bcdd93dfa20 +# github.com/cs3org/reva/v2 v2.22.1-0.20240809114512-56b26ddd82cc ## explicit; go 1.21 github.com/cs3org/reva/v2/cmd/revad/internal/grace github.com/cs3org/reva/v2/cmd/revad/runtime