Skip to content

Commit

Permalink
decomposedfs: prevent direct access to trash items
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
  • Loading branch information
butonic committed Jun 15, 2023
1 parent 91643f9 commit c3eeab9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/hide-trash-items.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: prevent direct access to trash items

decomposedfs now prevents direct access to trash items

https://github.com/cs3org/reva/pull/3977
14 changes: 9 additions & 5 deletions pkg/storage/utils/decomposedfs/node/permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,7 @@ func (p *Permissions) AssemblePermissions(ctx context.Context, n *Node) (ap prov
n.ID = kp[0]
}

// check if the current user is the owner
if utils.UserIDEqual(u.Id, n.Owner()) {
return OwnerPermissions(), nil
}
// determine root

rn := n.SpaceRoot

cn := n
Expand Down Expand Up @@ -154,6 +149,10 @@ func (p *Permissions) AssemblePermissions(ctx context.Context, n *Node) (ap prov
// We do not have a parent, so we assume the next valid parent is the spaceRoot (which must always exist)
cn = n.SpaceRoot
}
if !cn.Exists {
return NoPermissions(), errtypes.NotFound(n.ID)
}

}

// for the root node
Expand All @@ -167,6 +166,11 @@ func (p *Permissions) AssemblePermissions(ctx context.Context, n *Node) (ap prov
appctx.GetLogger(ctx).Error().Err(err).Interface("node", cn.ID).Msg("error reading root node permissions")
}

// check if the current user is the owner
if utils.UserIDEqual(u.Id, n.Owner()) {
return OwnerPermissions(), nil
}

appctx.GetLogger(ctx).Debug().Interface("permissions", ap).Interface("node", n.ID).Interface("user", u).Msg("returning agregated permissions")
return ap, nil
}
Expand Down

0 comments on commit c3eeab9

Please sign in to comment.