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

Show server root directory in move dialog #2234

Merged
merged 5 commits into from Mar 9, 2017
Merged

Conversation

takluyver
Copy link
Member

Attempt at addressing #2204

screenshot from 2017-02-27 16-37-58

  • I used a table to get them on the same line, but it doesn't fit them to the space neatly. I'm sure there's a better way to lay this out, but I don't know what it is. People who know more CSS than me, feel free to edit the branch directly.
  • I think we're using API paths for the editable part, which is going to look weird for Windows users - the fixed part will have backslashes, and the editable part forward slashes.
  • Is exposing the path of the server root directory like this at all a concern? I can't see any reason why it would be, but I don't think anything currently exposes it.
  • What would this do with non-filesystem-based contents managers?

@Carreau
Copy link
Member

Carreau commented Feb 27, 2017

What about show the same than in the dashboard with the folder icon ?
screen shot 2017-02-27 at 10 05 18

@takluyver
Copy link
Member Author

I may be wrong, but I don't think that icon is widely recognised as 'notebook server root directory'.

If we can figure out the points above, I think we should do this for 5.0, and keep thinking about it for the future. I get the impression that our system of only allowing access to the starting folder and subfolders is not well understood. Maybe we should abandon it entirely - though I'm reluctant to do that, as even if it's a poor security measure by itself, it may make it harder to exploit flaws in other security measures - or maybe we should think about ways to make it clearer what's going on.

@takluyver takluyver mentioned this pull request Feb 28, 2017
12 tasks
@ellisonbg
Copy link
Contributor

Nice! A few comments:

  • You can get the layout you want using a flexbox hbox ( sorry I can't help code it, swamped with teaching...)
  • It is fine to expose the root of the notebook server, just not the full system path, which we do in general hide from the user. I like Matthias's idea of showing the root of the notebook server in the same manner as the file browser itself. I know it isn't standard, but at least consistent.
  • Even for non file system content managers, they will still have the notion of paths, so I think they would show the same type of thing as the file browser does.
  • I am fine using forward slashes even on windows.

@takluyver
Copy link
Member Author

It is fine to expose the root of the notebook server, just not the full system path

I don't understand the distinction here. Is it OK for the body tag's data attributes to show that the server is running in /home/takluyver? If so, I'm not sure what you mean about the 'full system path'.

@minrk
Copy link
Member

minrk commented Mar 1, 2017

@takluyver I think the issue is about the API path, not filesystem path. So rather than /home/takluyver/foo/ [input] it would show /foo/ [input] if the notebook server is running in /home/takluyver and the dialog is at the /tree/foo/ URL.

@minrk
Copy link
Member

minrk commented Mar 1, 2017

...which is the notebookPath data already on the page, I believe.

@takluyver
Copy link
Member Author

Right, it already puts the API path of the directory in the input box where you can edit it. The issue (#2204) is that it's not very clear that you need a path where / is the root of the notebook server. This is my attempt to make that clearer.

@ellisonbg
Copy link
Contributor

ellisonbg commented Mar 1, 2017 via email

@Carreau
Copy link
Member

Carreau commented Mar 1, 2017

Arguably the user is already logged in, so it does not matter much, and mot of the time have access to this info via the kernel.

Re-arguably against myself, the kernel may not be on the same machine, and the user might have a phone user home.

Maybe is root is home show ~/ ?

@blink1073
Copy link
Member

blink1073 commented Mar 1, 2017

On Github, the "root path" is the root of the repo and the path is shown without a leading slash, why not adopt that for this path as well?

@ellisonbg
Copy link
Contributor

ellisonbg commented Mar 1, 2017 via email

@takluyver
Copy link
Member Author

  1. I'm not clear why the root directory of the server should be secret.
  • So long as our other security measures are working, only the authenticated user can see this anyway; we're not broadcasting it to the internet.
  • We avoid serving files from outside the server root directory to make it marginally trickier for someone who can bypass those security mechanisms to read e.g. ssh keys. This has always been somewhat doubtful as a security mechanism, and I don't think that it's worth 'protecting' the information of which directory the server is serving like this.
  • It's no less protected than the list of files in that directory, which seems more likely to contain sensitive information than the path.
  • +1 to compressing the user's home directory to ~ as @Carreau suggested - does that make it more tolerable?
  1. We already show the path from the server root directory in the move dialog. We're discussing this because we're concerned that it's not obvious to users how these paths work. I think showing the server root in the dialog too makes it significantly clearer; I don't think the absence of a leading slash makes much difference.

@minrk
Copy link
Member

minrk commented Mar 5, 2017

We should make sure to do something sensible for the cases where there is no server_root directory, e.g. when using pgcontents or GDrive. The prefix should probably come from the ContentsManager, not the Application. For example:

  1. use ContentsManager.root_display (or a better name)
  2. base ContentsManager.root_display = '/'
  3. FileContentsManager.root_display = self.root_dir by default
  4. allow hiding by overriding .root_display in config

I like showing the file path in the dialog, and +1 to collapsing $HOME to ~.

@minrk
Copy link
Member

minrk commented Mar 5, 2017

Another (simpler) option to the above is to use .root_dir always, and not allow FileContentsManagers to override display, only ensure that the base ContentsManager has .root_dir = '/'.

@ellisonbg
Copy link
Contributor

ellisonbg commented Mar 5, 2017 via email

@takluyver
Copy link
Member Author

I'm away this week, and have very limited time to work on anything, so please feel free to move this forwards without me.

@gnestor
Copy link
Contributor

gnestor commented Mar 8, 2017

From what I've gathered from this discussion, we have 2 options:

  • The folder icon root:
    image
  • os.path.basename(os.path.normpath(self.settings['server_root_dir'])) which will get the server root path from ContentsManager like @minrk proposed and will trim the rest of the absolute path:
    image

I also updated the styles to use flexbox vs. table like @ellisonbg proposed.

@gnestor
Copy link
Contributor

gnestor commented Mar 8, 2017

Another (simpler) option to the above is to use .root_dir always, and not allow FileContentsManagers to override display, only ensure that the base ContentsManager has .root_dir = '/'.

@minrk Let me know if there's a more elegant way to do this.

@minrk
Copy link
Member

minrk commented Mar 8, 2017

@gnestor we'll need ContentsManager.root_dir defined (probably just '/') on the base class so that non-file CMs don't fail with AttributeErrors.

@gnestor
Copy link
Contributor

gnestor commented Mar 8, 2017

Ok, would that just require adding something like this to https://github.com/jupyter/notebook/blob/master/notebook/services/contents/manager.py#L35:

root_dir = Unicode(config=True)

    @default('root_dir')
    def _default_root_dir(self):
        return '/'

@minrk
Copy link
Member

minrk commented Mar 8, 2017

@gnestor yes, but it can be simpler. You only need @default for dynamically-generated defaults. Simple defaults can be declared in the constructor:

root_dir = Unicode('/', config=True)

@@ -49,6 +50,7 @@ def get(self, path=''):
notebook_path=path,
breadcrumbs=breadcrumbs,
terminals_available=self.settings['terminals_available'],
server_root=os.path.basename(os.path.normpath(self.settings['server_root_dir'])),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gnestor I think the idea was for it to still be an absolute path, but collapse home to ~. So instead of basename, call:

root_dir = self.contents_manager.root_dir
home = os.path.expanduser('~')
if root_dir.startswith(home + os.path.sep):
    # collapse $HOME to ~
    root_dir = '~' + root_dir[len(home):]

This can be done once when defining the server_root_dir above in notebookapp.py, rather than here every time. Here, we can use server_root=self.settings['server_root'], assuming it already has the right form.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so should it look like this?

image

@gnestor
Copy link
Contributor

gnestor commented Mar 9, 2017

@minrk Ready for final review

@minrk minrk changed the title [WIP] Show server root directory in move dialog Show server root directory in move dialog Mar 9, 2017
@minrk minrk merged commit 420715e into jupyter:master Mar 9, 2017
@minrk
Copy link
Member

minrk commented Mar 9, 2017

Thanks!

gnestor added a commit that referenced this pull request Mar 9, 2017
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants