Conversation
|
Heads up! This PR modifies the following files:
|
|
Yay, security policy! |
added servojsprincipal skeleton Cross origin wrappers (servo/servo#16501) require JSPrincipals. This PR adds the skeleton and basic functionality required. CC: @jdm <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-mozjs/353) <!-- Reviewable:end -->
|
☔ The latest upstream changes (presumably #16592) made this pull request unmergeable. Please resolve the merge conflicts. |
c8ed375 to
39a524c
Compare
|
|
||
| // avadacatavra: destroy will need to retrieved the boxed origin pointer, turn it back into a box and allow it to be freed | ||
| pub unsafe fn destroy_servo_jsprincipal(principal: &mut ServoJSPrincipal) { | ||
| let origin = GetPrincipalOrigin(principal.0) as *mut Box<MutableOrigin>; |
There was a problem hiding this comment.
Casting to a *mut Box is incorrect; we need *mut MutableOrigin here so we can use from_raw and cause its destructor to run.
| } | ||
| } | ||
|
|
||
| // avadacatavra: destroy will need to retrieved the boxed origin pointer, turn it back into a box and allow it to be freed |
| } | ||
|
|
||
| struct ServoJSPrincipal(*mut JSPrincipals); | ||
| //TODO make principal.rs |
| match &*name { | ||
| "Location" => CrossOriginObjectType::CrossOriginLocation, | ||
| "Window" => CrossOriginObjectType::CrossOriginWindow, | ||
| _ => CrossOriginObjectType::CrossOriginOpaque, |
There was a problem hiding this comment.
let name = CStr::from_ptr((*obj_class).name).to_bytes();
match name {
b"Location" => ...,
b"Window" => ...,
_ => ...,
}| } | ||
| } | ||
|
|
||
| unsafe fn target_subsumes_obj(cx: *mut JSContext, obj: HandleObject) -> bool { |
There was a problem hiding this comment.
Let's call this obj_subsumes_current_compartment.
| values["members"] = "\n".join(members) | ||
|
|
||
| return CGGeneric("""\ | ||
| let origin = object.origin().clone(); |
There was a problem hiding this comment.
Do we need this clone if we pass a reference to create_global_object?
| //TODO is same_origin_domain equivalent to subsumes for our purposes | ||
| pub unsafe extern fn subsumes(obj: *mut JSPrincipals, other: *mut JSPrincipals) -> bool { | ||
| let obj = &ServoJSPrincipal(obj); | ||
| let other = &ServoJSPrincipal(other); |
| //step 7 compare hosts | ||
|
|
||
| //step 8 compare ports | ||
| //false |
There was a problem hiding this comment.
Since these are all covered by subsumes afaict, we don't need to leave references to them here.
|
|
||
| unsafe fn select_wrapper(cx: *mut JSContext, obj: HandleObject) -> *const libc::c_void { | ||
| let security_wrapper = !target_subsumes_obj(cx, obj); | ||
| if !security_wrapper { |
There was a problem hiding this comment.
This will be easier to reason about as if target_subsumes_obj(cx, obj) {.
| @@ -387,7 +478,8 @@ unsafe extern "C" fn wrap(cx: *mut JSContext, | |||
| -> *mut JSObject { | |||
| // FIXME terrible idea. need security wrappers | |||
| // https://github.com/servo/servo/issues/2382 | |||
|
☔ The latest upstream changes (presumably #16845) made this pull request unmergeable. Please resolve the merge conflicts. |
|
We're waiting to return to this work until we have a more recent spidermonkey. |
|
@jdm @avadacatavra should this be re-opened now that SpiderMonkey has been updated? |
|
No need to do that until someone is actually working on it. |
Implement `Location`'s custom internal methods This PR partly resurrects #16501 and introduces the use of principals object to associate objects and Realms with origins. Using this infrastructure, this PR implements [the custom internal methods][1] of the `Location` interface, which is "maybe-cross-origin". Other maybe-cross-origin interfaces, namely `WindowProxy` and `DissimilarWindowLocation`, aren't implemented correctly yet (causing most test cases of `tests/wpt/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects.html` to fail). [The "perform a security check" operation][2] and `Location`'s non-cross-origin properties' relevant `Document` origin checks aren't implemented either (not sure if they are covered by the existing tests). Finally, there are a slight deviation from the standard and inefficiency in `CrossOriginGetOwnPropertyHelper`'s current implementation. [1]: https://html.spec.whatwg.org/multipage/#the-location-interface [2]: https://html.spec.whatwg.org/multipage/browsers.html#integration-with-idl --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #16243 and make some progress in #2382 --- - [x] There are tests for these changes OR - [ ] These changes do not require tests because ___
Implement `Location`'s custom internal methods This PR partly resurrects #16501 and introduces the use of principals object to associate objects and Realms with origins. Using this infrastructure, this PR implements [the custom internal methods][1] of the `Location` interface, which is "maybe-cross-origin". Unimplemented/incomplete things: - Other maybe-cross-origin interfaces, namely `WindowProxy` and `DissimilarWindowLocation`, aren't implemented correctly yet (causing most test cases of `tests/wpt/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects.html` to fail). - `WindowProxy`: #28556 - [The "perform a security check" operation][2] and `Location`'s non-cross-origin properties' relevant `Document` origin checks aren't implemented either (not sure if they are covered by the existing tests). - There are a slight deviation from the standard and inefficiency in `CrossOriginGetOwnPropertyHelper`'s current implementation. - #28557 [1]: https://html.spec.whatwg.org/multipage/#the-location-interface [2]: https://html.spec.whatwg.org/multipage/browsers.html#integration-with-idl --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #16243 and make some progress in #2382 --- - [x] There are tests for these changes OR - [ ] These changes do not require tests because ___
This PR adds some infrastructure required for XOWs.
Addresses #16243 and #2382
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is