Skip to content

Commit bd097c7

Browse files
committed
Provide a method for identifying invalid properties in permissions
issue2551062: roundup-admin security validates all properties in permissions. It reports invalid properties.
1 parent 08bb800 commit bd097c7

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

CHANGES.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ Features:
9797
- issue2551059: added new values for tx_Source to indicate when /rest
9898
or /xmlrpc endpoint is being used rather than the normal web
9999
endpoints. (John Rouillard)
100-
100+
- issue2551062: roundup-admin security now validates all properties in
101+
permissions. It reports invalid properties. (John Rouillard)
102+
101103
Fixed:
102104

103105
- issue2550811: work around Unicode encoding issues in jinja2 template

doc/customizing.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,6 +1258,10 @@ Put together, these settings appear in the tracker's ``schema.py`` file::
12581258
# db.security.addPermissionToRole('Anonymous', 'Create', cl)
12591259
# db.security.addPermissionToRole('Anonymous', 'Edit', cl)
12601260

1261+
You can use ``roundup-admin security`` to verify the permissions
1262+
defined in the schema. It also verifies that properties specified in
1263+
permissions are valid for the class. This helps detect typos that can
1264+
cause baffling permission issues.
12611265

12621266
Automatic Permission Checks
12631267
---------------------------
@@ -1344,6 +1348,15 @@ The ``addPermission`` method takes a few optional parameters:
13441348
including properties would be used only for determining the
13451349
access permission for those properties.
13461350

1351+
``roundup-admin security`` will report invalid properties for the
1352+
class. For example a permission with an invalid summary property is
1353+
presented as::
1354+
1355+
Allowed to see content of object regardless of spam status
1356+
(View for "file": ('content', 'summary') only)
1357+
1358+
**Invalid properties for file: ['summary']
1359+
13471360
Setting ``props_only=True`` will make the permission valid only for
13481361
those properties.
13491362

roundup/admin.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,6 +1446,17 @@ def do_security(self, args):
14461446
if permission.properties:
14471447
sys.stdout.write( _(' %(description)s (%(name)s for "%(klass)s"' +
14481448
': %(properties)s only)\n')%d )
1449+
# verify that properties exist; report bad props
1450+
bad_props=[]
1451+
cl = self.db.getclass(permission.klass)
1452+
class_props = cl.getprops(protected=True)
1453+
for p in permission.properties:
1454+
if p in class_props:
1455+
continue
1456+
else:
1457+
bad_props.append(p)
1458+
if bad_props:
1459+
sys.stdout.write( _('\n **Invalid properties for %(class)s: %(props)s\n\n') % { "class": permission.klass, "props": bad_props })
14491460
else:
14501461
sys.stdout.write( _(' %(description)s (%(name)s for "%(klass)s" ' +
14511462
'only)\n')%d )

0 commit comments

Comments
 (0)