-
Notifications
You must be signed in to change notification settings - Fork 233
[DOC] Add security documentation #3928
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| --- | ||
| layout: default | ||
| title: Security | ||
| nav_order: 25 | ||
| --- | ||
|
|
||
| # Security | ||
|
|
||
| This page documents potential risks when using the Ruby LSP VS Code extension and the Ruby LSP language server with untrusted code. | ||
|
|
||
| ## Trust Model | ||
|
|
||
| **Ruby LSP assumes that all code in your workspace (including dependencies) is trusted.** | ||
|
|
||
| When you open a project with Ruby LSP, the extension and language server will execute code from that project as part of | ||
| normal operation. This is fundamentally similar to running `bundle install` in that project directory. | ||
|
|
||
| If you are working with code you do not fully trust, you should be aware of the potential risks documented below. | ||
|
|
||
| ## Code Execution Vectors | ||
|
|
||
| The following is a non-exhaustive list of ways that Ruby LSP may execute code from your workspace: | ||
|
|
||
| ### Bundle Installation | ||
|
|
||
| Ruby LSP automatically performs bundler operations (e.g. `bundle install`, `bundle update`) when starting up or when detecting changes to your | ||
| Gemfile. This will: | ||
|
|
||
| - Execute any code in your Gemfile (Gemfiles are Ruby code) | ||
| - Install gems specified in the Gemfile, which may include native extensions that execute during installation | ||
| - Run any post-install hooks defined by gems | ||
|
|
||
| ### Add-ons / Plugins | ||
|
|
||
| Ruby LSP has an add-on system that automatically discovers and loads add-ons from: | ||
|
|
||
| - Gems in your bundle that contain `ruby_lsp/**/addon.rb` files | ||
| - Files matching `ruby_lsp/**/addon.rb` anywhere in your workspace | ||
|
|
||
| Add-ons are loaded via `require` and their `activate` method is called, allowing them to execute arbitrary Ruby code. | ||
| This is by design - add-ons can spawn processes, make network requests, or perform any other operation. | ||
|
|
||
| ## Recommendations | ||
vinistock marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| 1. **Understand what "Trust" means** - Trusting a project with Ruby LSP installed is equivalent to feeling comfortable running `bundle install` in that directory. | ||
| 2. **Understand [VS Code's Workspace Trust](https://code.visualstudio.com/docs/editor/workspace-trust)** - When opening unfamiliar projects, click "Don't Trust" on the workspace trust prompt. | ||
| Ruby LSP will not run in untrusted workspaces, eliminating any risk. | ||
| 3. **Be cautious with unfamiliar add-ons** - Add-ons have full access to your system when activated. | ||
|
|
||
| ## Reporting Security Issues | ||
|
|
||
| If you discover a security vulnerability in Ruby LSP, please report it through | ||
| [GitHub Security Advisories](https://github.com/Shopify/ruby-lsp/security/advisories/new) rather than opening a public | ||
rafaelfranca marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| issue. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Does RubyGems allow for post-install hooks? I thought you could only show messages.
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.
It's not a direct post-install hook. But you can use
spec.rdoc_optionsto specify what RDoc should run to generate your gem's documentation forri(which will be invoked by rubygems), including running your rdoc options etc.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.
Really? I had no idea.