Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

decomposedfs: actually check GetPath permission #2909

Merged
merged 1 commit into from
May 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: the decomposedfs now checks the GetPath permission

After fixing the meta endpoint and introducing the fieldmask the GetPath call is made directly to the storageprovider. The decomposedfs now checks if the current user actually has the permission to get the path. Before the two previous PRs this was covered by the list storage spaces call which used a stat request and the stat permission.

https://github.com/cs3org/reva/pull/2909
6 changes: 1 addition & 5 deletions internal/grpc/services/storageprovider/storageprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,12 +440,8 @@ func (s *service) GetPath(ctx context.Context, req *provider.GetPathRequest) (*p
// TODO(labkode): check that the storage ID is the same as the storage provider id.
fn, err := s.storage.GetPathByID(ctx, req.ResourceId)
if err != nil {
appctx.GetLogger(ctx).Error().
Err(err).
Interface("resource_id", req.ResourceId).
Msg("error getting path by id")
return &provider.GetPathResponse{
Status: status.NewInternal(ctx, "error getting path by id"),
Status: status.NewStatusFromErrType(ctx, "get path", err),
}, nil
}
res := &provider.GetPathResponse{
Expand Down
9 changes: 9 additions & 0 deletions pkg/storage/utils/decomposedfs/decomposedfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,15 @@ func (fs *Decomposedfs) GetPathByID(ctx context.Context, id *provider.ResourceId
if err != nil {
return "", err
}
ok, err := fs.p.HasPermission(ctx, node, func(rp *provider.ResourcePermissions) bool {
return rp.GetPath
})
switch {
case err != nil:
return "", errtypes.InternalError(err.Error())
case !ok:
return "", errtypes.PermissionDenied(filepath.Join(node.ParentID, node.Name))
}

return fs.lu.Path(ctx, node)
}
Expand Down