Improve CORS origin validation and enhance callback handling#21
Open
stefanogermano wants to merge 4 commits intomasterfrom
Open
Improve CORS origin validation and enhance callback handling#21stefanogermano wants to merge 4 commits intomasterfrom
stefanogermano wants to merge 4 commits intomasterfrom
Conversation
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 6. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](actions/checkout@v4...v6) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '6' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com>
Improve origin validation in ESEWebSocket.check_origin: parse and normalize hostnames (lowercase, strip trailing dots) when comparing against ec.cors_origins and guard the logic with a try/except that returns False on parse errors to avoid exceptions from malformed origins. Also add a FIXME comment to validate incoming JSON against a schema before processing, as a reminder to add structural validation later.
…ctions/checkout-6 Bump actions/checkout from 4 to 6
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.
Several core components refined:
check_originmethod inese_websocket.pynow normalises hostnames (by converting to lowercase and removing trailing dots) before comparing them to the list in the configuration. This prevents false negatives caused by case sensitivity or accidental trailing periods.ese_websocket.pyhas been rewritten to:ese_utils.pyas a reminder for future JSON schema validation of incoming messages.Overall, this pull request makes the WebSocket service more robust against invalid origins, resolves the event loop error, improves user feedback when responses are too long, and tidies the codebase for easier maintenance.