1

1

Finalizing my next plug-in and trying to lock down the security.

As I've discussed in the forums before, when you join custom tables into a BugEventQuery (or any of the other standard queries) the built in security check isn't applied and you have to turn on IgnorePermissons to avoid a security error.

This is currently forcing me to instantiate a CBug object for every returned bug and use it to check permissions, which is murder on the DB for larger queries.

I was wondering if you would be willing to reveal the exact joins/where conditions normally used to check security on bugs when IgnorePermissions is turned off. That way I could just manually add that logic to my query and do it all in one hit to the DB.

Is this something you would be willing to divulge?

flag

1 Answer

2

We give you the source code, so it's not exactly a secret :) It looks something like this:

WHERE Bug.ixProject IN (1, 2, 4, 5, 9, 11 .. )

You can generate that list of projects using a CProjectQuery like so:

CProjectQuery query = api.Project.NewProjectQuery()
query.ExcludeUnreadableWithin = true;
int[] ids = query.ListIds();

The unfortunately named ExcludeUnreadableWithin property means "don't include any projects within which I cannot read bugs". If what you're really after is writable, then use the ExcludeUnwritableWithin property.

Edit

These are not to be confused with ExcludeUnreadable and ExcludeUnwritable, which refer to the Project object itself, not Bugs within a project. For example,

  • Modifying the project name (sProject) requires write permission on the Project because you must be an admin.

  • Creating a bug in the project requires write permission within the project, not admin permissions

link|flag
Thanks. BTW: What is the difference between ExcludeUnreadable and ExcludeUnreadableWith? – JohnFx Oct 5 2009 at 16:41
1 
ExcludeUnreadable is for the Project, ExcludeUnreadableWith is for Bugs in a Project. – Jacob Oct 5 2009 at 20:35

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.