Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upcheck http_state in determine_request_referrer #26546
Conversation
highfive
commented
May 16, 2020
|
Heads up! This PR modifies the following files:
|
|
Sadly, it seems there are no tests for HttpsState::Deprecated value. At least in enabled tests. |
| /// <https://w3c.github.io/webappsec-secure-contexts/#is-origin-trustworthy> | ||
| fn is_origin_trustworthy(url: ServoUrl) -> bool { | ||
| match url.origin() { | ||
| // Step 1 | ||
| ImmutableOrigin::Opaque(_) => false, | ||
| ImmutableOrigin::Tuple(_, _, _) => { | ||
| // Step 3 | ||
| if url.scheme() == "https" || url.scheme() == "wss" { | ||
| return true; | ||
| } | ||
| // Step 4-5 TODO | ||
| // Step 6 | ||
| if url.scheme() == "file" { | ||
| return true; | ||
| } | ||
| // Step 7-8 TODO | ||
| // Step 9 | ||
| false | ||
| }, | ||
| } | ||
| } |
This comment has been minimized.
This comment has been minimized.
CYBAI
May 17, 2020
Collaborator
IIRC, we've had this function in urlhelper so you can just use UrlHelper::is_origin_trustworthy.
servo/components/script/dom/urlhelper.rs
Lines 75 to 94 in 0a00ea3
|
Thank you!
Then I think:
1. It should be moved to somewhere in the net, may be there is something
like net/url helpers? What is the best place?
2. The check for local ip is incorrect, I'll fix it using Rust std Ipv*Addr
structs methods.
…---------------------------------------------------------
Александров Сергей Васильевич
вс, 17 мая 2020 г., 5:42 cybai <notifications@github.com>:
*@CYBAI* commented on this pull request.
------------------------------
In components/net/http_loader.rs
<#26546 (comment)>:
> +/// <https://w3c.github.io/webappsec-secure-contexts/#is-origin-trustworthy>
+fn is_origin_trustworthy(url: ServoUrl) -> bool {
+ match url.origin() {
+ // Step 1
+ ImmutableOrigin::Opaque(_) => false,
+ ImmutableOrigin::Tuple(_, _, _) => {
+ // Step 3
+ if url.scheme() == "https" || url.scheme() == "wss" {
+ return true;
+ }
+ // Step 4-5 TODO
+ // Step 6
+ if url.scheme() == "file" {
+ return true;
+ }
+ // Step 7-8 TODO
+ // Step 9
+ false
+ },
+ }
}
IIRC, we've had this function in urlhelper so you can just use
UrlHelper::is_origin_trustworthy.
https://github.com/servo/servo/blob/0a00ea3db3c2353c78435030040fd3f57f5f4497/components/script/dom/urlhelper.rs#L75-L94
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#26546 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABMOIUCCWT535MQPG6W5Q3RR5FLFANCNFSM4NDBUZGQ>
.
|
Yes, agree! @gterzian tried to move it as a method of See https://github.com/servo/servo/pull/26317/files#diff-cac78be29c466ffe8160ad29af53e214R173-R191
|
|
Fixed is_origin_trustworthy + moved it to ServoUrl |
|
We're missing initializing the request's https state in Document::fetch_async. We should also make
Finally we should add the request's HTTPS state as an argument to load_whole_resource and set the Request's https_state member before starting the request. |
| @@ -413,6 +418,7 @@ impl Request { | |||
| redirect_count: 0, | |||
| response_tainting: ResponseTainting::Basic, | |||
| csp_list: None, | |||
| https_state: HttpsState::None, | |||
This comment has been minimized.
This comment has been minimized.
jdm
May 17, 2020
Member
We should make sure that the new https_state member is initialized in net_request_from_global in components/script/dom/request.rs.
| @@ -128,6 +129,7 @@ fn request_init_from_request(request: NetTraitsRequest) -> RequestBuilder { | |||
| parser_metadata: request.parser_metadata, | |||
| initiator: request.initiator, | |||
| csp_list: None, | |||
| https_state: HttpsState::None, | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
splav
May 17, 2020
Author
Contributor
Yes, missed that NetTraitsRequest means 'Request from net_traits'
b7d83d2
to
728fd0e
|
I want to believe that all requested changes are fixed now. |
|
Forgot unit tests, fixing. |
cc83ffd
to
0c42ae7
| @@ -395,6 +395,7 @@ impl DedicatedWorkerGlobalScope { | |||
| Ok((metadata, bytes)) => (metadata, bytes), | |||
| }; | |||
| scope.set_url(metadata.final_url); | |||
| global_scope.set_https_state(metadata.https_state); | |||
This comment has been minimized.
This comment has been minimized.
jdm
May 19, 2020
Member
Since load_whole_resource now uses the default value of global's https state when we call it earlier in this file, please set global_scope's https_state to the https_state of current_global before calling load_whole_resource. This call to set_https_state should remain, however.
This comment has been minimized.
This comment has been minimized.
splav
May 19, 2020
Author
Contributor
Done, essentially it makes the worker global scope inherit parent global scope https state.
| @@ -375,6 +375,8 @@ impl DedicatedWorkerGlobalScope { | |||
| let scope = global.upcast::<WorkerGlobalScope>(); | |||
| let global_scope = global.upcast::<GlobalScope>(); | |||
|
|
|||
| global_scope.set_https_state(current_global.get_https_state()); | |||
This comment has been minimized.
This comment has been minimized.
jdm
May 19, 2020
Member
I'm 99% confident that this doesn't build, since current_global can't be moved between threads. We need to get the https state value before spawning the new thread instead.
This comment has been minimized.
This comment has been minimized.
splav
May 19, 2020
Author
Contributor
Yes, fixed that. Strangely it did build. May be some caching... Also sometimes rustc crashes and builds fine after rerun.
|
@bors-servo try=wpt |
check http_state in determine_request_referrer <!-- Please describe your changes on the following line: --> Check https status inside determine_request_referrer. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #14506 (GitHub issue number if applicable) <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
|
|
|
Huh, I'm surprised there are still no test result changes. I want to figure out what's missing before we merge this. |
|
Ok. If there are candidates - I can investigate concrete tests. I'll try to look for appropriate tests manually though. |
|
I dug into it, and it turns out that there are no referrer-policy tests that start in an HTTPS context and make an HTTP request. This appears to be an oversight in the test suite generation, based on:
It looks like either the mixed-content exclusions are over-enthusiastic, or the author thought that the mixed content standard subsumes this for some reason. I'm inclined to merge these changes and investigate extending the test suite separately. |
|
@bors-servo r+ |
|
|
|
Random thought: The other thing I fixed - is_origin_trustworthy implementation. And here I do expect some test results changes. |
|
@bors-servo r- |
|
Looks like the is_origin_trustworthy changes are difficult to test as part of the WPT harness, so let's merge these. |
|
|
check http_state in determine_request_referrer <!-- Please describe your changes on the following line: --> Check https status inside determine_request_referrer. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #14506 (GitHub issue number if applicable) <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
|
|
|
@bors-servo retry |
|
|
splav commentedMay 16, 2020
Check https status inside determine_request_referrer.
./mach build -ddoes not report any errors./mach test-tidydoes not report any errors