Closed Bug 1204703 Opened 9 years ago Closed 9 years ago

Make nsContentSecurityManager scriptable and add security checks to nsIChannel implementation in JS

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla43
Tracking Status
firefox43 --- fixed

People

(Reporter: ckerschb, Assigned: ckerschb)

References

Details

Attachments

(3 files, 3 obsolete files)

      No description provided.
Assignee: nobody → mozilla
Blocks: 1143922
Summary: Add asyncOpen2 to JS implementation of nsIChannel → Make nsContentSecurityManager scriptable and add security checks to nsIChannel implementation in JS
Attached patch bug_1143922_toolit_and_b2g.patch (obsolete) — Splinter Review
Attachment #8661533 - Flags: review?(jonas)
Attached patch bug_1143922_test_updates.patch (obsolete) — Splinter Review
Attachment #8661535 - Flags: review?(jonas)
Comment on attachment 8661532 [details] [diff] [review]
bug_1143922_make_contentsecuritymanager_scriptable.patch

Review of attachment 8661532 [details] [diff] [review]:
-----------------------------------------------------------------

r=me with that fixed.

::: dom/interfaces/security/nsIContentSecurityManager.idl
@@ +32,5 @@
> +   *     Whether or not the channel should be openend or not.
> +   */
> +   bool performSecurityCheck(in nsIChannel aChannel,
> +                             in nsIStreamListener aStreamListener,
> +                             out nsIStreamListener outStreamListener);

I would say just return the new streamlistener rather than use an out-argument.

You can still throw an exception if the security checks fail.
Attachment #8661532 - Flags: review?(jonas) → review+
Comment on attachment 8661533 [details] [diff] [review]
bug_1143922_toolit_and_b2g.patch

Review of attachment 8661533 [details] [diff] [review]:
-----------------------------------------------------------------

::: b2g/components/ActivityChannel.jsm
@@ +57,5 @@
>    asyncOpen2: function(aListener) {
> +    var outListener = {};
> +    var allowed = contentSecManager.performSecurityCheck(this, aListener, outListener);
> +    if (!allowed) {
> +      return Cr.NS_ERROR_CONTENT_BLOCKED;

You don't want to return an error code here. You want to throw one.

Returning an error in C++ maps to throwing an exception in JS.

::: toolkit/components/addoncompat/RemoteAddonsChild.jsm
@@ +281,5 @@
> +  asyncOpen2: function(listener) {
> +    var outListener = {};
> +    var allowed = contentSecManager.performSecurityCheck(this, aListener, outListener);
> +    if (!allowed) {
> +      return Cr.NS_ERROR_CONTENT_BLOCKED;

Same here.
Attachment #8661533 - Flags: review?(jonas) → review-
Comment on attachment 8661535 [details] [diff] [review]
bug_1143922_test_updates.patch

Review of attachment 8661535 [details] [diff] [review]:
-----------------------------------------------------------------

Here too
Attachment #8661535 - Flags: review?(jonas) → review-
Agreed, lets return a streamListener instead of using an out-argument. Carrying over r+ from Jonas.
Attachment #8661532 - Attachment is obsolete: true
Attachment #8661533 - Attachment is obsolete: true
Attachment #8661535 - Attachment is obsolete: true
Attachment #8662656 - Flags: review+
Depends on: 1213646
>    2.25 +   * whether the channel should be openend or should be blocked consulting

"opened"?
Flags: needinfo?(mozilla)
(In reply to Boris Zbarsky [:bz] from comment #12)
> >    2.25 +   * whether the channel should be openend or should be blocked consulting
> 
> "opened"?

Indeed, will get that updated. Thanks for pointing it out.
Flags: needinfo?(mozilla)
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: