Closed Bug 1583790 Opened 6 years ago Closed 5 years ago

SitePermissions should validate principal arguments

Categories

(Firefox :: Site Permissions, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
Firefox 76
Tracking Status
firefox76 --- fixed

People

(Reporter: emz, Assigned: gaurijove, Mentored)

References

Details

Attachments

(2 files)

SitePermissions methods should throw if principal arguments aren't of type nsIPrincipal. Currently they silently fail to default state.

Mentor: pbz
Priority: -- → P3
Component: Site Identity → Site Permissions

The component has been changed since the backlog priority was decided, so we're resetting it.
For more information, please visit auto_nag documentation.

Priority: P3 → --
Priority: -- → P3

To fix this, you will need to modify all functions in SitePermissions.jsm (only in the exposed SitePermissions object) that handle principals to return an error when the given principal is not instanceof Ci.nsIPrincipal.

However, note that some functions also take a browser argument. In those cases, it's okay to have either a browser or a principal or both, but one of them has to be there.

Please also add a test for the new errors here: https://searchfox.org/mozilla-central/rev/557a0e222dd104c5d805ba344c45d6abc27d3db0/browser/modules/SitePermissions.jsm#258

Jayati, would you like to take this bug?

Note that with this change we might break some stuff (which would be good!), so it's important to do a run on our Try server. You can find instructions about how to get access to Try on our contribution document.

Mentor: jhofmann
Flags: needinfo?(gaurijove)

Thanks Johann . Will begin working on this straightaway.

Flags: needinfo?(gaurijove)
Assignee: nobody → gaurijove
Status: NEW → ASSIGNED
Attachment #9132238 - Attachment is obsolete: true
Attachment #9132238 - Attachment description: Bug 1583790- Check instance of principal. r=prathiksha → Bug 1583790- Ensure that we are passing valid principal values as arguments to functions in SitePermissions.jsm. r=prathiksha
Attachment #9132238 - Attachment is obsolete: false
Attachment #9132700 - Attachment is obsolete: true
Flags: needinfo?(prathikshaprasadsuman)

Ignore the above link ,posted accidently.

This is the try server run for the patch- https://treeherder.mozilla.org/#/jobs?repo=try&revision=94fda26b68cee453f6b4ee0b775708cc150d37df

Flags: needinfo?(prathikshaprasadsuman)

(In reply to Johann Hofmann [:johannh] from comment #2)

Note that with this change we might break some stuff (which would be good!), so it's important to do a run on our Try server.

Several uncaught exceptions were thrown.We are passing invalid arguments like null as principal at many places....What do you suggest ?

Flags: needinfo?(jhofmann)

The reason for the failures seems to be that the patch is missing this detail from comment 2:

However, note that some functions also take a browser argument. In those cases, it's okay to have either a browser or a principal or both, but one of them has to be there.

e.g. here we're calling the API with null as the principal, but there's a browser argument, so that would be valid: https://searchfox.org/mozilla-central/rev/f36cb2af46edd2659f446b7acdb2154e230ee445/browser/base/content/test/permissions/browser_permission_delegate_geo.js#176

You'll need to update your patch to handle that case.

Flags: needinfo?(prathikshaprasadsuman)
Flags: needinfo?(jhofmann)
Attachment #9132238 - Attachment description: Bug 1583790- Ensure that we are passing valid principal values as arguments to functions in SitePermissions.jsm. r=prathiksha → Bug 1583790 - Ensure that we are passing valid principal values as arguments to functions in SitePermissions.jsm. r=prathiksha
Pushed by prathikshaprasadsuman@gmail.com: https://hg.mozilla.org/integration/autoland/rev/d93b4a6d9bd4 Ensure that we are passing valid principal values as arguments to functions in SitePermissions.jsm. r=johannh,prathiksha
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 76
Attachment #9132700 - Attachment is obsolete: false
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: