Fix 2250 - #2255
Merged
Merged
Conversation
…ossbario#2250) check_websocket_compression() is an empty "# FIXME" stub, yet it is wired into check_websocket_options(), so WebSocket `compression` config is accepted entirely unvalidated: unknown codecs, unknown deflate attributes, wrong types and out-of-range window-bits / memory-level all pass silently and only surface (if at all) as a run-time error deep inside the compression backend. Add tests to CheckWebsocketTests covering what crossbar.router.protocol.set_websocket_options actually reads for deflate (request_no_context_takeover, request_max_window_bits, no_context_takeover, max_window_bits, memory_level), asserting malformed blocks are rejected and valid ones accepted. The permissible values mirror autobahn's PerMessageDeflateMixin: window bits 9..15 (plus 0 = "not requested" for request_max_window_bits) and memory level 1..9. Seven rejection tests fail ("InvalidConfigException not raised") because the validator is empty; the validator lands in the next commit. Note: This work was completed with AI assistance (Claude Code).
Fill the empty check_websocket_compression() stub, mirroring the structure of check_websocket_options(): check_dict_args() for permitted keys and types, then explicit range checks. Only permessage-deflate is implemented in set_websocket_options(), so `deflate` is the only accepted codec, and its accepted attributes are exactly the ones set_websocket_options() reads. The permissible window-bits and memory-level values are imported from autobahn's PerMessageDeflateMixin (WINDOW_SIZE_PERMISSIBLE_VALUES / MEM_LEVEL_PERMISSIBLE_VALUES) rather than duplicated, so the validator cannot drift from what autobahn actually accepts at run-time. request_max_window_bits additionally accepts 0, matching autobahn's "do not request a window size" semantics. Makes the tests added in the previous commit pass. Note: This work was completed with AI assistance (Claude Code).
Contributor
Author
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.

fixes #2250