-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
[WIP] Add INodeByPath to Directory #54441
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
base: master
Are you sure you want to change the base?
Conversation
cad0ea3 to
87d9b88
Compare
| use OCP\Share\IManager; | ||
|
|
||
| abstract class Node implements \Sabre\DAV\INode { | ||
| abstract class Node extends \Sabre\DAV\Node implements \Sabre\DAV\INode { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment: unfortunately this is needed, as there is a check in Tree that checks for Node and not INode 😢 without this, the whole thing would not work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not ideal. I this an overview in sabre code? Can you point to the code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problematic check is here:
https://github.com/sabre-io/dav/blob/58be83aae10a244372f113b63624c48034378094/lib/DAV/Tree.php#L87
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but it's open source, so easy to change :) sabre-io/dav#1595
| use OCP\Share\IManager; | ||
|
|
||
| abstract class Node implements \Sabre\DAV\INode { | ||
| abstract class Node extends \Sabre\DAV\Node implements \Sabre\DAV\INode { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not ideal. I this an overview in sabre code? Can you point to the code?
f67982e to
c54b5c9
Compare
Signed-off-by: Salvatore Martire <[email protected]>
Signed-off-by: Salvatore Martire <[email protected]>
Signed-off-by: Salvatore Martire <[email protected]>
Signed-off-by: Salvatore Martire <[email protected]>
Signed-off-by: Salvatore Martire <[email protected]>
Signed-off-by: Salvatore Martire <[email protected]>
Signed-off-by: Salvatore Martire <[email protected]>
c54b5c9 to
cf952ce
Compare
|
Possible performance regression detected Show Output |
1 similar comment
|
Possible performance regression detected Show Output |
|
Performance regression warning is unrelated. The output of the check contains text which makes the |
|
Possible performance regression detected Show Output |
|
Possible performance regression detected Show Output |
| // In case reading a directory was allowed but it turns out the node was a not a directory, reject it now. | ||
| if (!$this->info->isReadable()) { | ||
| throw new NotFound(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is $this->info used here and not $info?
Also I do not understand the comment, is it related to this if?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@come-nc $this->info refers to the node on which getNodeForPath gets called.
Regarding the comment: it is a leftover of the checks for the files drop checks in getChild which I had dropped for this function. But of course dropping the checks was not OK, since now I can skip ACLs from the files_accesscontrol app. I tested this after discovering the files_accesscontrol app and I am able to do things I shouldn't be able to.
I will add a comment to describe the problem and see if anyone has ideas on what else can break and if there are other solutions other than abandoning the PR.
| return $this->node; | ||
| } | ||
|
|
||
| public function getNodeForPath($path) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| public function getNodeForPath($path) { | |
| public function getNodeForPath($path): INode { |
or whatever is the correct node ;)
|
I converted the PR back to a draft because I ran into an issue with access control rules. Problem statementApps that rely on path navigation to perform checks that block an action could be broken with this PR. ExampleThe In the current implementation, the app relies on the fact that How to reproduce
Uploading should fail but succeeds instead Possible solution?Alter files_accesscontrolFor the case in the example, a fix could be to change Can someone come up with ideas on how to address this or other things that may break, so that if we try a new solution I can test it still works? |
a1a6278 to
cf952ce
Compare
This is probably the best option imo. Another alternative would be to have a dav plugin in files_accesscontrol to do extra checking without effecting any of the other rules or non-dav code paths. |
Summary
Sabre has an interface
INodeByPaththat allows nodes to fetch a specific node by its path. This was not implemented in ourDirectoryclass, leading to any file query to fetch all parent nodes until the file node was reached. This PR makesDirectoryimplement that interface, extends makes the NCNodeclass extend theNodeclass from Sabre (required step).Before:

After:

Checklist