-
Notifications
You must be signed in to change notification settings - Fork 29.3k
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
Allow command:
links in hover decorations
#29076
Comments
@eamodio Yes there's a bit of history to that change. In summary: /**
* Does stuff
*
* [Learn More](command:runShellComamnd?rm%20-rf%20%25)
*/
export function doStuff() { ... } fe8ea99 attempted to fix this I don't know if there is a safe way to selectively re-enable this functionality. Let me know if you have any thoughts on this |
Ah - I see. Could maybe the extension provide a whitelist of commands that should be allowed in a hover? Because having commands in hovers can be quite powerful, and I'd hate to completely lose that ability (even though I didn't think it worked because I was always trying to wrap a link around a Or maybe have an |
@jrieken Any thoughts on supporting some form of interactivity in hovers? I'm inclined to keep hovers limited to static content. If we did want to support actions in the hover, the HoverProvider may be a good place to handle these. |
I would argue that there was (and still is) interactivity in hovers -- you have just taken away a part of it (for perfectly reasonable security concerns). But I would hope that the feature that used to work (which could have the security concerns mitigated) would not be lost altogether -- just changed for security. As for hover decorations vs hover providers -- again I would argue that this feature has already existed and will continue to exist for both external links as well as internal file links. Also, I want to point out that not only have command links been lost, but also custom |
Yeah, I think is critical that we are taking features aways. This has been working and advertised since at least a year. Why don't we do something similar to script execution and the preview command? There we didn't just disable script execution but prompted the user in some way. I think taking the big hammer to solve this problem won't make people happy. |
I only recall seeing command uris documented for html previews. That they worked in hovers seemed like a side effect of using the In the markdown preview, we disabled scripts by default and then provided a setting to enable them again. Prompting works fine for the markdown preview because the markdown content comes from the user. For UX, I'm not in favor of a prompt based solution here because the content is coming from an extension which the user has already trusted. How should they know which commands to trust and which not to? A whitelist of valid commands for given hover would be better. Unless a large number of users will be negatively impacted when some existing extensions stop working, we need to ship 1.14 with the current change that uses a whitelist of valid link schemes, or at the very least entirely disable command uris in hovers. If we ever do want to interactive functionality in hovers, we should look into a proper solution that does not use marked strings and command uris |
I didn't say prompt allow user in some way to keep/restore the old behaviour. Generally, the dislike is expressed when things are taken away. How about making it a user-setting? I don't think that whitelisting necessary works because my good and proper extension might be (ab)used by a third party to with special crafted contents. So, I'd its a generic, single trust switch which defaults to "safe" |
Depending on how "safe" things need to be having something like a Where as if we are worried about that security risk, having something like As for a single trust switch -- I'm not sure I understand what that means -- would it be per extensions? Would it be on the first executing of a specific command? Would there be a blacklist of commands that would be considered "unsafe" (blacklists are of course problematic)? |
That is correct and there is little we can do. However, there is a scenario in which a good extension can be made do evil thing by special input, e.g. a source file which results in a special hover command. Because of that a list of approached commands won't help much and I'd opt for a global flag (user-setting) that says "I understand and I am OK with the risk" |
Why wouldn't a separate callback or whitelist of commands not help? In the callback case the extension could decide to execute the command or not. And in the whitelist case, there wouldn't even be a command execution unless the extension expressed that the command should be allowed - e.g. in GitLens I would allow the And at least that way -- the extension doesn't get "tricked" into doing something it didn't expect |
I'm not in favor of a user setting to disable security for the same reasons I'm not in favor of a prompt. My proposal:
|
😞
@mjbvz is the above still a risk? Or only |
We are using |
We'll leave |
So, idea is to deprecate The proposal is to have a export class MarkdownString {
value: string;
trusted?: boolean;
constructor(value?: string);
appendText(value: string): MarkdownString;
appendMarkdown(value: string): MarkdownString;
} So, basically Pros
Cons
Another proposal is to have a second enum-style type that contains information about export enum MarkedStringType {
TrustedMarkdown,
Markdown,
Plaintext
}
export class Hover {
contents: MarkedString[];
contentsType: MarkedStringType Pros
Cons
|
Please forgive me is this is a stupid questions -- but why couldn't So if it was a string or if the |
Yeah, a common pitfall ;-). The So, yes we could add another type-definition |
I personally would go with the MarkdownString type. But for better compatibility I would define export type MarkedString = string | { language: string; value: string } | MardownString; |
Unsure, it will make the the API look cleaner but I also want to add the |
May be it is not a good idea. For the hover example should that be: |
Unsure, I believe we have it because each of them is separated by a horizontal line... Tho, we could also deprecate a level up so export interface DecorationOptions {
/**
* @deprecated
*/
hoverMessage?: MarkedString | MarkedString[];
hoverMessage?: MarkdownString | MarkdownString[] Tho it makes it harder to describe what to do. Use |
Ugh, this is getting ugly |
Moving this to September when we turn off command-links unless explicitly enabled via |
@jrieken will the api be in August but not enforced until Sept or no api until Sept too? |
Yes, the new |
Awesome -- thank you. New GitLens features coming ;) |
Closing this as the new API is out and adopting is being tracked here: #33577 |
Can you clarify what the change was for september, and what part of it needs to be verified for this issue? |
Not sure if @jrieken wanted something specific checked, but this works for me in GitLens now: Those links are all command links now |
It would be great to be able to execute commands from hover decorations. It would provide for powerful navigation options as well as open up many other uses.
For example, in GitLens I would love to have the shas
eb411003
&078960e8
be links that would open the commit details command. And theChanges
be a link to open the diff with previous command.The text was updated successfully, but these errors were encountered: