Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[server] Restrict copy between same app type

Neeraj Guptaff2df412c3da
diff --git a/server/pkg/controller/collections/file_action.go b/server/pkg/controller/collections/file_action.go
index 6c51421ca1..127ccc2cc7 100644
--- a/server/pkg/controller/collections/file_action.go
+++ b/server/pkg/controller/collections/file_action.go
@@ -2,6 +2,7 @@ package collections
import (
"fmt"
+
"github.com/ente-io/museum/ente"
"github.com/ente-io/museum/pkg/controller/access"
"github.com/ente-io/museum/pkg/utils/auth"
@@ -285,20 +286,25 @@ func (c *CollectionController) isRemoveAllowed(ctx *gin.Context,
func (c *CollectionController) IsCopyAllowed(ctx *gin.Context, actorUserID int64, req ente.CopyFileSyncRequest) error {
// verify that srcCollectionID is accessible by actorUserID
- if _, err := c.AccessCtrl.GetCollection(ctx, &access.GetCollectionParams{
+ srcCollection, err := c.AccessCtrl.GetCollection(ctx, &access.GetCollectionParams{
CollectionID: req.SrcCollectionID,
ActorUserID: actorUserID,
- }); err != nil {
+ })
+ if err != nil {
return stacktrace.Propagate(err, "failed to verify srcCollection access")
}
// verify that dstCollectionID is owned by actorUserID
- if _, err := c.AccessCtrl.GetCollection(ctx, &access.GetCollectionParams{
+ dstCollection, err := c.AccessCtrl.GetCollection(ctx, &access.GetCollectionParams{
CollectionID: req.DstCollection,
ActorUserID: actorUserID,
VerifyOwner: true,
- }); err != nil {
+ })
+ if err != nil {
return stacktrace.Propagate(err, "failed to ownership of the dstCollection access")
}
+ if srcCollection.Collection.App != dstCollection.Collection.App {
+ return stacktrace.Propagate(ente.ErrInvalidApp, fmt.Sprintf("copy across app not supported %s to %s", srcCollection.Collection.App, dstCollection.Collection.App))
+ }
// verify that all FileIDs exists in the srcCollection
fileIDs := make([]int64, len(req.CollectionFileItems))
for idx, file := range req.CollectionFileItems {