Skip to content

Update WebSocket blocked ports to match the Fetch spec - #10014

Merged
bors-servo merged 1 commit into
servo:masterfrom
sauravsc:pr1
Mar 17, 2016
Merged

bors-servo merged 1 commit into
servo:masterfrom
sauravsc:pr1

Conversation

@sauravsc

Copy link
Copy Markdown
Contributor

Adresses #9949.

This adds a function that tests whether a request should be blocked or not based on it's url's scheme and port. It also adds testing for port restriction to the main_fetch method. More info in whatwg/fetch@eb07418.

@Ms2ger In whatwg/html#841, @annevk proposes to remove port restrictions from websockets. Should we go ahead do that, given that the spec hasn't been changed yet?


This change is Reviewable

@highfive

Copy link
Copy Markdown

warning Warning warning

  • These commits modify net and script code, but no tests are modified. Please consider adding a test!

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Mar 15, 2016
@Ms2ger

Ms2ger commented Mar 16, 2016

Copy link
Copy Markdown
Contributor

Since the fetch code isn't used yet, this PR effectively removes the restrictions from WebSocket. I don't think we should attempt to fix #9950 right now. My apologies for not making this clear in the issue.

(In either case, I would have asked to fix the two issues in separate commits.)


if BLOCKED_PORTS_LIST.iter().any(|&p| p == port) {
return Err(Error::Security);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In other words, this piece of code should not be deleted.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Okay.

@KiChjang KiChjang added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels Mar 16, 2016
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Mar 16, 2016
@KiChjang

Copy link
Copy Markdown
Contributor

Currently this is still trying to fix #9950 instead of #9949. This is trying to add functionality for the fetch.rs module while what was requested was to update the blocked ports in the BLOCKED_PORTS_LIST in websocket.rs. Also, tests need to be written.

@KiChjang KiChjang added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. S-needs-tests New tests have been requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels Mar 16, 2016
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Mar 16, 2016
@sauravsc sauravsc changed the title Generalize ports restrictions to the Fetch methods Update WebSocket blocked ports to match the Fetch spec Mar 16, 2016
@sauravsc

Copy link
Copy Markdown
Contributor Author

@KiChjang Should I write a test which checks if the websocket constructor throws a security error if a bad port is detected?

@jdm

jdm commented Mar 16, 2016

Copy link
Copy Markdown
Member

tests/wpt/web-platform-tests/websockets/Create-Secure-blocked-port.htm already exists that does that.

@KiChjang

Copy link
Copy Markdown
Contributor

@Ms2ger Are there any other additional tests that you wish to have?

@jdm

jdm commented Mar 16, 2016

Copy link
Copy Markdown
Member

I think this can merge as-is. We can write different tests when we get the fetch integration.

@jdm jdm removed the S-needs-tests New tests have been requested by a reviewer. label Mar 16, 2016
@Ms2ger

Ms2ger commented Mar 17, 2016

Copy link
Copy Markdown
Contributor

It would be nice to update tests/wpt/web-platform-tests/websockets/Create-Secure-blocked-port.htm with all the blocked ports.

@KiChjang KiChjang added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels Mar 17, 2016
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Mar 17, 2016
@sauravsc

Copy link
Copy Markdown
Contributor Author

I've added testing for all the blocked ports.

6668, // irc (alternate)
6669, // irc (alternate)
];
for (var i = 0; i < BLOCKED_PORTS_LIST.length; i++) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not a huge issue, but I think you can do something like for (var port in BLOCKED_PORTS_LIST) in ES6.

@KiChjang

Copy link
Copy Markdown
Contributor

@bors-servo r+

Thanks for working on this!

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 4ddf4e7 has been approved by KiChjang

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Mar 17, 2016
bors-servo pushed a commit that referenced this pull request Mar 17, 2016
Update WebSocket blocked ports to match the Fetch spec

Adresses #9949.

This adds a function that tests whether a request should be blocked or not based on it's url's scheme and port. It also adds testing for port restriction to the `main_fetch` method. More info in whatwg/fetch@eb07418.

@Ms2ger In whatwg/html#841, @annevk proposes to remove port restrictions from websockets. Should we go ahead do that, given that the spec hasn't been changed yet?

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10014)
<!-- Reviewable:end -->
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 4ddf4e7 with merge 0008c07...

@bors-servo

Copy link
Copy Markdown
Contributor

☀️ Test successful - android, gonk, linux-dev, linux-rel, mac-dev-unit, mac-rel-css, mac-rel-wpt, status-appveyor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants