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

API: Support protocol handlers #46256

Closed
joaomoreno opened this issue Mar 21, 2018 · 4 comments
Closed

API: Support protocol handlers #46256

joaomoreno opened this issue Mar 21, 2018 · 4 comments
Assignees
Labels
api-proposal feature-request Request for new features or functionality on-testplan plan-item VS Code - planned item for upcoming
Milestone

Comments

@joaomoreno
Copy link
Member

joaomoreno commented Mar 21, 2018

From #45685

Problem

There is no current way for extension to react on URLs being open with the vscode: scheme. Allowing extensions to do so can enable many different scenarios. A specific one is to provide Clone URLs in Github/TFS which would simply invoke VS Code to clone a URL, using its git extension.

Security Concerns

Allowing extensions to handle a URL doesn't seem to open any additional security concerns, since it's already possible to run arbitrary code by having a user click a URL while taking advantage of the * activation event.

There is no added API for this to happen, since we can leverage commands to handle URLs and the contributes manifest field to expose a URL handler.

An example URL format would be:

vscode://pub.name/...

Proposal

I suggest to keep it simple and allow a single URL handler per extension:

  "contributes": {
    "urlHandler": "handleURLCommand"
  }
}

The handleURLCommand would be invoked with a single instance of vscode.Uri as a single argument:

commands.registerCommand('handleURLCommand', (uri: vscode.Uri) => { /* ... */ });
@jrieken
Copy link
Member

jrieken commented Mar 21, 2018

There is no added API for this to happen, since we can leverage commands to handle URLs

Yeah, technically that allows to implement many things but also a little sneaky Why not explicit API like an activation event and some registerUriHandler-function?

@mjbvz
Copy link
Collaborator

mjbvz commented Mar 21, 2018

For security, the main risk is not that the extension itself would be malicious but that it may unknowingly expose commands that could be used in a dangerous way. The classic example would be a friends list extension that wants to let people easily friend each other by clicking on a link. I then come along and craft a url such as: vscode:extensions/super.friendo?addFriendo=TotallyNotEvilAnalytica and trick you into clicking on it.

Just something to be aware of. At the very least, we should document that extensions must prompt before performing potentially dangerous operations. We could also prompt ourselves, something like: "Are you sure you want to activate extension X?"

@joaomoreno
Copy link
Member Author

Feedback from API discussion:

  • Use an activation event and registerUrlHandler() API instead
  • Always have VS Code prompt whether the user wants to open the URL

@joaomoreno joaomoreno modified the milestones: March 2018, April 2018 Mar 26, 2018
@joaomoreno
Copy link
Member Author

Proposed API pushed!

Created #48426 to promote it to public soon.

@joaomoreno joaomoreno added feature-request Request for new features or functionality plan-item VS Code - planned item for upcoming labels Apr 23, 2018
@joaomoreno joaomoreno changed the title API: Support URL handling API: Support protocol handlers Apr 23, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Jun 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-proposal feature-request Request for new features or functionality on-testplan plan-item VS Code - planned item for upcoming
Projects
None yet
Development

No branches or pull requests

3 participants