-
-
Notifications
You must be signed in to change notification settings - Fork 679
fix(editor): execute oxc.path.server
in win32 with shell, when its the node_module binary
#14203
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
base: main
Are you sure you want to change the base?
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
f043cd9
to
b5d59db
Compare
4217436
to
a462aff
Compare
b5d59db
to
834e42b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes cross-platform support for the oxc language server by enabling Windows to execute npm binary scripts through shell execution when the user configures oxc.path.server
to point to node_modules/.bin/oxc_language_server
.
- Modifies the binary execution logic to use shell mode on Windows for node_modules binaries
- Updates path validation comments to reflect the new shell usage
- Enables cross-platform configuration where projects can define a single path that works on all platforms
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
editors/vscode/client/extension.ts | Adds conditional shell execution for Windows node_modules binaries and refactors findBinary function |
editors/vscode/client/PathValidator.ts | Updates comment to reflect that shell execution is now used on Windows |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
834e42b
to
d9659cd
Compare
d9659cd
to
385c4cb
Compare
a462aff
to
f8abab2
Compare
385c4cb
to
6e8cd59
Compare
6e8cd59
to
de35c6e
Compare
…the node_module binary
de35c6e
to
d2e1615
Compare
const run: Executable = { | ||
command: command!, | ||
options: { | ||
// On Windows we need to run the binary in a shell to be able to execute the shell npm bin script. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this because windows can’t execute this script directly? I think there’s another alternative to spawn a cmd prompt with the argument to execute the script, then you don’t need shell: true.
Not sure if it matters or if there’s any reason to prefer one or the other.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it does not handle the sh shebang in the file. Calling the CMD file or ps1 file inside node_modules/.bin/
will not work. This is the only solution or searching for the .exe
file.
But searching for the .exe
file will create more problems with the location of the .exe.
Your examples in the issue did not check for different package versions. Calling the wrapper script in node_modules/.bin/
"should" be the right way.
// The npm bin script is a shell script that points to the actual binary. | ||
// Security: We validated the userDefinedBinary in `configService.getUserServerBinPath()`. | ||
shell: process.platform === 'win32' && command === userDefinedBinary && | ||
userDefinedBinary?.endsWith('node_modules\\.bin\\oxc_language_server'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t personally think this (or the other path validations) are necessary.
If the user has opted into the trusted workspace, they have consented to these settings. I don’t think the extension is responsible for validating what the path might look like or what the contents of the evaluated file might be.
It has potential to make it harder for users to use, for what I would consider little to no real security benefit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A user would trust the extension more than a freshly opened workspace. Even when a user has trusted a workspace by accident (when the workspace is inside a parent folder, which is already been trusted). Opening the extension to execute untrusted binaries / shell script should still be validated.
Maybe not all restrictions are needed and can frustrate users to set up the oxc.path.server
correctly.
But I will take the cost for better end-user security.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what you’re trying to solve is possibly a gap in the trusted workspace feature. Instead of trusting an entire workspace, you want users to trust specific values within the workspace. It doesn’t feel like the responsibility of the extension.
I think the definition of setting the oxc.path.server “correctly” is subjective. If I want to use whatever characters in my path, that shouldn’t be prevented by the extension.
I understand the desire for security though. I don’t think this is a blocker by any means, just wanted to bring it up as something to consider.
I won’t be able to actually review any code for a few days, but I don’t think I’ll have much to share other than the few considerations I mentioned before. Just things for the team to consider. For what it’s worth, the IntelliJ plugin doesn’t do any path validation and it’s not something I would personally add. The IntelliJ plugin also uses some abstraction provided by IntelliJ, but I believe by default it executes the same file that is being suggested for this PR. However, if a user specifies an exe path directly, that still works too. Specifying an exe path directly just won’t work cross platform (in typical scenarios). I think I mentioned this a while ago when the IDE development was only beginning. It might be beneficial to have documentation on how we want the different IDE plugins owned by the Oxc team to function. This would provide users with a consistent experience across the different IDEs. Currently, users likely have a slightly different experience between the various IDEs (VS Code, IntelliJ, Zed, etc.) |
closes #14167
This allows cross-platform configuration in a project.
The project can now define
oxc.path.server
tonode_modules/.bin/oxc_language_server
and windows will pick it up too.With
validateSafeBinaryPath
inPathvalidator.ts
, we should be sure that bad actors can not harm the user's machine.