Repository navigation
Only accept base protocol framing on the socket launcher - #305
Merged
Merged
Conversation
The base protocol framing resembles an HTTP request closely enough that a request posted by a web page could be misread as a JSON-RPC message. - Close a connection whose stream does not start with "Content-", the prefix of the only headers lsp4j parses. This rejects HTTP requests and any other traffic that is not a GLSP client. The peeked bytes are pushed back, so a regular client is unaffected. - Close a connection whose peer hangs up without sending anything. - Run both checks before creating the injector. The server instance used to be created on accept, so any connection allocated an injector and a server before a single byte had been read. - Add a launcher test that drives a real socket.
- Size the peek buffer from the header prefix directly, since an overridden length could reject every client or throw on 0 - Log rejected connections on debug, so requests from web pages can't flood the log
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What it does
Defer injector and server creation until the incoming stream starts with a JSON-RPC base protocol header prefix.
Content-prefix with the same case sensitivity as lsp4j.Related TypeScript implementation: eclipse-glsp/glsp-core#47.
Part of: eclipse-glsp/glsp#1825
How to test
mvn -B -Pm2 -pl tests/org.eclipse.glsp.server.test -am -Dtest=SocketGLSPServerLauncherTest -Dsurefire.failIfNoSpecifiedTests=false testFollow-ups
Changelog