Skip to content

Conversation

@joefarebrother
Copy link
Contributor

Adds models for WebSocketHandler remote flow sources.

@joefarebrother joefarebrother requested a review from a team as a code owner November 20, 2025 10:59
Copilot AI review requested due to automatic review settings November 20, 2025 10:59
Copilot finished reviewing on behalf of joefarebrother November 20, 2025 11:02
Copy link
Contributor

Copilot AI left a 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 pull request adds support for modeling WebSocket handlers in the Tornado framework, specifically adding remote flow source models for tornado.websocket.WebSocketHandler.

  • Added modeling for tornado.websocket.WebSocketHandler class and its event handler methods
  • Created TornadoWebSocketEventHandler class to identify WebSocket event handlers as request handlers with routed parameters
  • Added test cases for WebSocket handler methods including open, on_message, on_ping, on_pong, select_subprotocol, and check_origin

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
python/ql/lib/semmle/python/frameworks/Tornado.qll Added WebSocket module modeling including WebSocketHandler class reference, WebSocketHandlerClass extending RequestHandlerClass, and TornadoWebSocketEventHandler for treating WebSocket event handlers as request handlers
python/ql/test/library-tests/frameworks/tornado/routing_test.py Added test class WebSocket extending tornado.websocket.WebSocketHandler with test methods for various WebSocket event handlers and corresponding route setup
python/ql/lib/change-notes/2025-11-22-tornado-websockets.md Added change note documenting the addition of remote flow source models for tornado.websocket.WebSocketHandler

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

override string getFramework() { result = "Tornado" }
}

/** A request handler for WebSocket events */
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment should end with a period for consistency with other similar comments in the file, such as the comment on line 560.

Copilot generated this review using guidance from repository custom instructions.
result.getName() = "open"
}

/** Gets a function that could handle incoming websocket events, if any. */
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The term "websocket" should be capitalized as "WebSocket" to maintain consistency with line 583 and adhere to the standard capitalization of the WebSocket protocol name.

Copilot generated this review using guidance from repository custom instructions.
def get(self): # $ requestHandler
self.write("NotRouted") # $ HttpResponse

class WebSocket(tornado.websocket.WebSocketHandler):
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The WebSocket class inherits from tornado.websocket.WebSocketHandler on line 57, but the module tornado.websocket is not imported. An import statement should be added at the top of the file, e.g., import tornado.websocket.

Copilot uses AI. Check for mistakes.

class WebSocket(tornado.websocket.WebSocketHandler):
def open(self, x): # $ requestHandler routedParameter=x
self.write_message("WebSocket open {}".format(x))
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace should be removed from this line.

Suggested change
self.write_message("WebSocket open {}".format(x))
self.write_message("WebSocket open {}".format(x))

Copilot uses AI. Check for mistakes.
Comment on lines +77 to 78


Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace should be removed from this blank line.

Suggested change

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant