-
-
Notifications
You must be signed in to change notification settings - Fork 813
Closed
Milestone
Description
I just spotted this while working on #2261:
datasette/datasette/views/table.py
Lines 439 to 457 in 569aacd
| if upsert: | |
| # Must have insert-row AND upsert-row permissions | |
| if not ( | |
| await self.ds.permission_allowed( | |
| request.actor, "insert-row", database_name, table_name | |
| ) | |
| and await self.ds.permission_allowed( | |
| request.actor, "update-row", database_name, table_name | |
| ) | |
| ): | |
| return _error( | |
| ["Permission denied: need both insert-row and update-row"], 403 | |
| ) | |
| else: | |
| # Must have insert-row permission | |
| if not await self.ds.permission_allowed( | |
| request.actor, "insert-row", resource=(database_name, table_name) | |
| ): | |
| return _error(["Permission denied"], 403) |
That looks wrong to me. Note how the later check does this:
self.ds.permission_allowed(request.actor, "insert-row", resource=(database_name, table_name))But the earlier checks do this:
self.ds.permission_allowed(request.actor, "insert-row", database_name, table_name)From looking at the code I think that second example is incorrect, it's using table_name as the default value:
Lines 898 to 900 in 569aacd
| async def permission_allowed( | |
| self, actor, action, resource=None, default=DEFAULT_NOT_SET | |
| ): |
Reactions are currently unavailable