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

Notebook: hardcoded file assumptions #107438

Closed
bpasero opened this issue Sep 25, 2020 · 8 comments
Closed

Notebook: hardcoded file assumptions #107438

bpasero opened this issue Sep 25, 2020 · 8 comments
Assignees
Labels
debt Code quality issues notebook sandbox Running VSCode in a node-free environment
Milestone

Comments

@bpasero
Copy link
Member

bpasero commented Sep 25, 2020

The context is: #107437 and the deprecation of getPathFromAmdModule

I notice that src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.ts makes assumptions about using file protocol:

const rootPath = URI.file(path.dirname(getPathFromAmdModule(require, '')));

and a deprecated getPathFromAmdModule use:

const pathsPath = getPathFromAmdModule(require, 'vs/loader.js');

The new methods are FileAccess.asFileUri and FileAccess.asBrowserUri. It would be great if notebooks could adopt this accordingly.

@bpasero bpasero added debt Code quality issues notebook labels Sep 25, 2020
@bpasero bpasero added the sandbox Running VSCode in a node-free environment label Sep 25, 2020
@bpasero
Copy link
Member Author

bpasero commented Sep 27, 2020

Just to clarify: currently on master these methods are not implemented fully, they basically just return the same URI. But once the vscode-file branch is merged, the asBrowserUri will return a vscode-file scheme while asFileUri ensures a file scheme.

@rebornix
Copy link
Member

rebornix commented Oct 2, 2020

I use isWeb to decide whether to use asBrowserUri or asFileUri but correct me if I was wrong.

@rebornix rebornix added this to the October 2020 milestone Oct 2, 2020
@bpasero bpasero reopened this Oct 3, 2020
@bpasero
Copy link
Member Author

bpasero commented Oct 3, 2020

Ok, let's reopen this issue to make sure we do the right fix, you bring up a good question and looking at your changes I am not entirely sure they are correct.

Trying to recap:

  • asBrowserUri: this will be https in web and vscode-file in native once the vscode-file branch is merged to master (until then, the scheme will be file for native). This method should be used whenever you have Chrome load something (e.g. via DOM)
  • asFileUri: as you probably already figured out only makes sense to be used in native context and never in web because this always returns a file:// URI. However, this can ONLY be used in contexts where node.js is used to access a file. As you can see here, we will start to block any access to file protocols that happen via a browser (e.g. renderer, webview, any DOM access)

I suggest that you give your changes a try from the vscode-file branch that will block any access to file protocol. That branch can just be run out of sources.

Since I am not an expert in the webview code there, maybe could also connect with @mjbvz to ensure the right thing is done.

@rebornix
Copy link
Member

rebornix commented Oct 5, 2020

I checked vscode-file branch and it's working fine, I guess the main reason is we will convert all Uris to webview Uris like

vscode-webview-resource://b9b8afaf-8eaf-4a3a-935d-dd5557181017/file///Users/penlv/code/vscode/out/vs/loader.js

note that it's vscode-webview-resource://${GUID}/file/${path}, which means that webview component in main thread @mjbvz wrote will handle the file loading.

@rebornix rebornix modified the milestones: October 2020, On Deck Oct 26, 2020
@bpasero
Copy link
Member Author

bpasero commented Jan 7, 2021

Ping

@mjbvz
Copy link
Collaborator

mjbvz commented Mar 23, 2021

@bpasero @rebornix Is there any more work needed on this issue?

@bpasero
Copy link
Member Author

bpasero commented Mar 29, 2021

I think not from my end, looks like what I mentioned in #107438 (comment) has been addressed. If notebooks work fine when vscode-file:// protocol is enabled, feel free to close.

@mjbvz
Copy link
Collaborator

mjbvz commented Apr 30, 2021

Closing this based on comments

I believe we also plan on removing the loader: #121245

@mjbvz mjbvz closed this as completed Apr 30, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Jun 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debt Code quality issues notebook sandbox Running VSCode in a node-free environment
Projects
None yet
Development

No branches or pull requests

4 participants
@rebornix @bpasero @mjbvz and others