-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
Hide API implementation proxies, add tests to check for "proxy leakage" #115530
Conversation
This file contains 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
…an API test (with success...)
Tyriar
approved these changes
Feb 1, 2021
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.
Nice work, terminal looks good 👍
alexr00
approved these changes
Feb 2, 2021
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.
Tasks looks good, thank you!
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Our vscode API is mostly implemented through RPC'ing to the renderer. That's done through a protocol implementation and objects that represent a slice of the API, aka proxies, like
MainThreadTextEditorsShape
. These proxies usually mirror the capabilities of the API but are often more powerful.This PR adds marker properties to proxies and the rpc-objects. It also adds a test-util that tries to reach these proxies using the API instance as entry point. In the name of being very strict, it's a test failure when any rpc object can be reached.
Note that the test can only checks on existing objects, e.g if
vscode.window.activeTextEditor
isundefined
it cannot be traversed. That's why a check is performed during teardown of a single test. That increases the coverage but doesn't guarantee that everything is checked.The PR also changes how some APIs are implemented (so that proxies aren't accessible anymore). There is two strategies
#proxy
, so that reflection doesn't find them. However, note that the emitted polyfill is significantly slowervalue
property, e.gExtHostTerminal#value
. There is another benefit to this approach which is TS checking that the literal only implements what is defined in the API, so accidental API leakage is checked by the compiler