Repository navigation
Keep the test server to this machine and its file middleware inside its roots - #1379
Merged
Merged
Conversation
…ts roots Unless Sauce Labs is configured, drop connections to the web-test-runner server that don't come from a loopback address. Setting hostname to 127.0.0.1 doesn't help: @web/dev-server-core listens on every interface when hostname is localhost or 127.0.0.1. Serve /test_helpers/fixtures/ and /qunit/ requests only when the resolved path stays under the fixtures directory and node_modules/qunit respectively.
There was a problem hiding this comment.
🟢 Approved
No active review issues are recorded for the server connection restrictions and file-path containment changes.
No open issues 🎉
What changed in this PR
This PR hardens the web-test-runner server by restricting local connections and adding path containment checks to its file middleware, while preserving Sauce Connect access.
Changes:
- Reject non-loopback connections when Sauce Labs is not configured, including WebSocket connections.
- Check resolved fixture and QUnit paths against their designated roots before serving files.
[!TIP]
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or rungh pr ready --undo.
Click "Ready for review" or rungh pr readyto reengage.
| File | Description |
|---|---|
web-test-runner.config.mjs |
Adds loopback-only connection filtering and path containment checks for fixture and QUnit files. |
Review effort: Balanced
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.
The web-test-runner server listens on every interface so Sauce Connect can reach it, and that applies to local runs too. Its file middleware joins the request URL onto
src/testornode_moduleswithout checking where the result lands, so a request with..segments reads any file the test process can read. While the suite runs, anyone on the same network can do that.Unless Sauce Labs is configured, a small plugin now drops connections that don't come from a loopback address. Setting
hostnameto127.0.0.1doesn't help, because @web/dev-server-core listens on every interface when the hostname islocalhostor127.0.0.1. Dropping at the connection also covers the test runner's WebSocket, which Koa middleware never sees.The fixture and QUnit middleware now serve a file only when its resolved path stays under
src/test/test_helpers/fixturesornode_modules/qunit.