Skip to content

feat: support requiring approval to run process plugins in editors - #1401

Merged
dsherret merged 9 commits into
feat/workspace-editor-servicefrom
feat/lsp-process-plugin-approval
Oct 29, 2026
Merged

dsherret merged 9 commits into
feat/workspace-editor-servicefrom
feat/lsp-process-plugin-approval

Conversation

@dsherret

@dsherret dsherret commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Part of #1400. Stacked on #1408.

Process plugins aren't sandboxed, and an editor opening a project or a file (ex. a repository that was just cloned or a file in node_modules) isn't the same as the user choosing to run dprint there. This adds a way to require approving process plugins in editors, which is opt-in to start:

// settings.json next to the global config file (ex. ~/.config/dprint/settings.json)
{
  "editor": {
    "allowProcessPlugins": false
  }
}
  • The language server, the editor service and dprint editor-info then don't set up or start the process plugins of a config file until the user allows them. This is checked before resolving the plugins because setting up a process plugin runs it to get its information.
  • What's allowed is a config file with a hash of its plugins and trusted configuration, so a change to it (ex. the commands of dprint-plugin-exec) needs to be allowed again. It's per config file rather than per plugin url and plugin config because a plugin's config key isn't known until it's set up. "Always Allow" and "Always Deny" are stored in an editor-state.json file in the cache directory (the language server's lsp-state.json renamed), which keeps the most recent 5000. Losing it only has the user asked again.
  • The process plugins of the global config file are always allowed.
  • settings.json is a new file for dprint's settings that aren't formatting configuration. It's only read from the global config directory. It's deliberately not a language server setting because an editor's workspace settings can come from the project (ex. .vscode/settings.json).
  • The CLI doesn't use it because running dprint fmt is choosing to run dprint there.

Language server: asks with a window/showMessageRequest that has Allow (for the session), Always Allow, Deny (for the session) and Always Deny actions once per session for each configuration. A client that can't show the actions gets a message saying they weren't allowed and that running dprint config allow-process-plugins allows them.

Editor service: schema version 6 (#1408) asks with a show message request that has the same actions, which every editor using schema version 6 already handles, so this doesn't add any messages. Schema version 5 isn't changed and doesn't start the process plugins that weren't allowed, with a warning on stderr that says how to allow them. The current dprint-vscode and dprint-intellij use schema version 5, so they keep working the same way.

dprint config allow-process-plugins allows the process plugins of the config file (--config or the one found from the current directory), the same as "Always Allow". It's for editors that can't ask.

The preferences of dprint init move to settings.json too (in an init property). They're still read from the init.json file dprint 0.64 saved them to, which is removed the next time they're saved. Only the property being changed is written, so the rest of the file (ex. its comments) is kept as it is.

@dsherret
dsherret force-pushed the feat/lsp-process-plugin-approval branch from ead48be to ba43a2a Compare October 27, 2026 17:41
@dsherret
dsherret changed the base branch from main to feat/workspace-editor-service October 27, 2026 17:41
@dsherret
dsherret added this pull request to stack #1409 October 27, 2026 17:43
@dsherret
dsherret force-pushed the feat/lsp-process-plugin-approval branch 6 times, most recently from 204053c to e6399ab Compare October 28, 2026 17:01
This is the work of this branch so far restacked onto schema version 6 of
the editor service. The capabilities and approve process plugins messages
that were added to schema version 5 are left out because schema version 6
replaces them, so schema version 5 only says in the log when process
plugins weren't allowed to run.
…r service

The editor service asks with a show message request that has the same
actions as the language server, which every editor that uses schema
version 6 handles, so this doesn't need new messages or a capability.
…gins are allowed

- Editors don't use any plugins of a config file whose process plugins weren't
  allowed, so a Wasm plugin doesn't format files differently than the CLI.
  Schema version 6 of the editor service and the language server say why
  with a new `processPluginsNotAllowed` reason.
- Rename `dprint config allow-process-plugins` to `dprint config editor-approve`.
- Ask again when the plugin.json of an npm plugin without a version changes
  in node_modules, which the config file doesn't pin.
- Use the decision for the session when storing it fails, and use the most
  recent decision so that approving after denying for the session works.
- Warn once about unknown properties and problems reading settings.json.
…rsion 6 of the editor service

The configuration info says why a configuration file doesn't format anything when its process plugins aren't allowed, and the editor is told when they're allowed outside of it (ex. with `dprint config editor-approve`).
…hema version 6 of the editor service

Not choosing an action leaves running the process plugins undecided instead of denying them for the session.
A process plugin is now allowed with its own configuration in the configuration file, so changing the configuration of another plugin or the global configuration doesn't ask again. A plugin that isn't set up yet is allowed to be set up first because its configuration isn't known until then, and it's allowed with its configuration once it is.

Running `dprint fmt` or `dprint config install` with a configuration file allows its process plugins in editors because that's the same as choosing to run them, which replaces `dprint config editor-approve`.

With schema version 6 of the editor service, the install plugins message asks the user to allow the process plugins it installs, which replaces the message to ask again, and a format only asks when the plugins are installed.
Denying a process plugin that isn't set up denies it with any configuration
because its configuration isn't known until then, so neither formatting nor
installing asks about it again, and `Always Deny` stores that.
@dsherret
dsherret force-pushed the feat/lsp-process-plugin-approval branch from f121642 to 25b6339 Compare October 28, 2026 19:51
@dsherret
dsherret merged commit 25b6339 into main Oct 29, 2026
7 checks passed
@dsherret

Copy link
Copy Markdown
Member Author

These commits are now part of #1408, which also replaces the editor service's schema version 6 with dprint/* methods of the language server, so GitHub shows this as merged into that branch.

An error occurred while trying to automatically change base from feat/workspace-editor-service to main November 16, 2026 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant