Closed
Bug 986107
Opened 11 years ago
Closed 11 years ago
Make new sandboxes inherit the metadata of the creating sandbox by default
Categories
(DevTools :: Debugger, defect)
DevTools
Debugger
Tracking
(Not tracked)
RESOLVED
FIXED
Firefox 31
People
(Reporter: mossop, Assigned: mossop)
References
Details
Attachments
(1 file, 1 obsolete file)
1.84 KB,
patch
|
bholley
:
review+
|
Details | Diff | Splinter Review |
Bug 898559 added the notion of metadata to tag a sandbox for the add-on debugger but it requires add-ons to set it correctly when creating custom sandboxes. This patch makes the sandbox use the same metadata as the sandbox that is creating it by default.
Assignee | ||
Updated•11 years ago
|
Assignee: nobody → dtownsend+bugmail
Assignee | ||
Comment 1•11 years ago
|
||
Assignee | ||
Comment 2•11 years ago
|
||
Comment on attachment 8395005 [details] [diff] [review]
patch rev 1
Failry straightforward I think but I don't know my way around xpconnect so I mostly cribbed from other places. This just tries to get the global from the JS context and then get its metadata and use that in the event that there was no metadata passed in.
Attachment #8395005 -
Flags: review?(bobbyholley)
Comment 3•11 years ago
|
||
Comment on attachment 8395005 [details] [diff] [review]
patch rev 1
Review of attachment 8395005 [details] [diff] [review]:
-----------------------------------------------------------------
::: js/xpconnect/src/Sandbox.cpp
@@ +1574,5 @@
> if (NS_FAILED(AssembleSandboxMemoryReporterName(cx, options.sandboxName)))
> return ThrowAndFail(NS_ERROR_INVALID_ARG, cx, _retval);
>
> + if (options.metadata.isNullOrUndefined())
> + xpc::GetContextMetadata(cx, &options.metadata);
This should just be:
if (options.metadata.isNullOrUndefined()) {
// If the caller is running in a sandbox, inherit.
RootedObject callerGlobal(cx, CurrentGlobalOrNull(cx));
if (IsSandbox(callerGlobal)) {
rv = GetSandboxMetadata(cx, callerGlobal, &options.metadata);
if (NS_WARN_IF(NS_FAILED(rv))
return rv;
}
}
Or somesuch.
@@ +1834,5 @@
> +
> + targetObject = JS_GetGlobalForObject(cx, targetObject);
> +
> + RootedObject sandbox(cx, targetObject);
> + return xpc::GetSandboxMetadata(cx, sandbox, rval);
How do we know that the global here is a sandbox at all? GetSandboxMetadata isn't safe to call on non-sandbox globals.
::: js/xpconnect/tests/unit/test_sandbox_metadata.js
@@ +43,5 @@
> do_check_eq(thrown, true);
> +
> + let systemPrincipal = Components.classes['@mozilla.org/systemprincipal;1']
> + .createInstance(Components.interfaces.nsIPrincipal);
> + sandbox = Components.utils.Sandbox(systemPrincipal, {
You can just pass |this| here, which is a system-principaled global (BackstagePass) instead of explicitly grabbing the system principal.
Attachment #8395005 -
Flags: review?(bobbyholley) → review-
Assignee | ||
Comment 4•11 years ago
|
||
Ah yes, that's much simpler
Attachment #8395005 -
Attachment is obsolete: true
Attachment #8395125 -
Flags: review?(bobbyholley)
Updated•11 years ago
|
Attachment #8395125 -
Flags: review?(bobbyholley) → review+
Assignee | ||
Comment 5•11 years ago
|
||
Comment 6•11 years ago
|
||
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 31
Updated•7 years ago
|
Product: Firefox → DevTools
You need to log in
before you can comment on or make changes to this bug.
Description
•