|
1 | 1 | # Workspace trust |
2 | 2 |
|
3 | | -Helix has a number of potentially dangerous features, namely LSP and ability to use local to workspace configurations. Those features can lead to unexpected code execution. To protect against code execution in dangerous contexts, Helix has a workspace trust protection, which will prevent these potentially dangerous features from running automatically. |
| 3 | +Helix includes two potentially dangerous features, both of which can execute arbitrary code: |
4 | 4 |
|
5 | | -Helix will not trust any workspace by default. |
| 5 | +- Language servers (LSP) |
| 6 | +- Local workspace configurations (`.helix/config.toml` and `.helix/languages.toml`) |
6 | 7 |
|
7 | | -By default, it will prompt about trust when you open new file in a workspace where you didn't make a decision about trust yet. |
| 8 | +To protect against this, Helix includes workspace trust protection, which prevents these features from running automatically unless the workspace is explicitly trusted. |
8 | 9 |
|
9 | | -If you decide not to trust a workspace and don't want to be prompted about trust every time you start a new session in it, you can exclude the workspace by choosing `Never` option in trust selection window. |
| 10 | +## Default trust behavior |
10 | 11 |
|
11 | | -You can always make current workspace trusted by running `:workspace-trust` command, and untrust it with `:workspace-untrust`. |
| 12 | +Helix does not trust any workspace by default and will prompt you to choose the trust level when you open a file in a workspace where trust has not yet been set. |
12 | 13 |
|
13 | | -Lists of trusted and excluded workspaces, delimited by newline characters, are stored in `~/.local/share/helix/trusted_workspaces` and `~/.local/share/helix/excluded_workspaces` correspondingly. |
14 | | -<!-- TODO: Windows paths --> |
| 14 | +## Changing workspace trust status |
15 | 15 |
|
16 | | -# Configuration |
| 16 | +You can always make the current workspace trusted by running the `:workspace-trust` command, and untrust it using `:workspace-untrust` or `:workspace-exclude`, with latter disabling all further prompts in it. If you wish to trust workspace only once, use `:workspace-trust-once`. |
17 | 17 |
|
18 | | -You can return to the old behaviour of loading every local `.helix/config.toml` and `.helix/languages.toml` and starting LSP's without an explicit permission by setting following option: |
| 18 | +Lists of trusted and excluded workspaces, delimited by newline characters, are stored in: |
| 19 | + |
| 20 | +- Linux and macOS: `~/.local/share/helix/trusted_workspaces` and `~/.local/share/helix/excluded_workspaces` |
| 21 | +- Windows: `%AppData%\Roaming\helix\trusted_workspaces` and `%AppData%\Roaming\helix\excluded_workspaces` |
| 22 | + |
| 23 | + |
| 24 | +## Configuration |
19 | 25 |
|
20 | 26 | ```toml |
21 | | -[editor] |
22 | | -insecure = true |
| 27 | +[editor.workspace-trust] |
| 28 | +# This option will disable workspace trust feature altogether. |
| 29 | +level = "all" |
| 30 | + |
| 31 | + |
| 32 | +# This will make Helix prompt only when there is local configuration |
| 33 | +# present in the workspace. |
| 34 | +# LSP will start automatically without an explicit confirmation. |
| 35 | +level = "lsp" |
| 36 | + |
| 37 | + |
| 38 | +# This is the default option. |
| 39 | +level = "none" |
| 40 | + |
| 41 | + |
| 42 | +# Disable pop-up selector, leaving status bar reminder instead. |
| 43 | +selector = false |
| 44 | + |
| 45 | + |
| 46 | +# Trust recursively every workspace in `~/work` and exclude every workspace |
| 47 | +# that contains "contrib" in its name. |
| 48 | +globs = [ "~/work/**", "!*contrib*" ] |
23 | 49 | ``` |
| 50 | + |
| 51 | +### Glob syntax |
| 52 | + |
| 53 | +For more info about syntax see [globset docs](https://docs.rs/globset/latest/globset/#syntax) |
| 54 | +(`literal_separator` option is enabled). |
| 55 | + |
| 56 | +Additional syntax: |
| 57 | + |
| 58 | + - all `~/` will be expanded to `$HOME`; |
| 59 | + - globs prefixed with `!` will be excluded instead of trusted. |
| 60 | + |
| 61 | +For example, this is valid: |
| 62 | + |
| 63 | +````toml |
| 64 | +[editor] |
| 65 | +# Exclude `$HOME/coding/helix/contrib` and all subdirectories. |
| 66 | +workspace-trust.globs = [ "!{~/coding/helix/contrib/**,~/coding/helix/contrib}" ] |
| 67 | + |
| 68 | +# Same thing, but with a smaller nesting. |
| 69 | +workspace-trust.globs = [ "!~/coding/helix/{contrib/**,contrib}" ] |
| 70 | + |
| 71 | +# Same, but without nesting. |
| 72 | +workspace-trust.globs = [ "!~/coding/helix/contrib/**", "!~/coding/helix/contrib" ] |
| 73 | +```` |
0 commit comments