mirror of
https://github.com/simonw/datasette.git
synced 2026-09-12 11:34:06 +02:00
Require view permission before returning written rows
This commit is contained in:
parent
4c56ce2103
commit
a365903d56
2 changed files with 17 additions and 1 deletions
|
|
@ -838,7 +838,14 @@ class RowUpdateView(BaseView):
|
|||
|
||||
result = {"ok": True}
|
||||
returned_row = None
|
||||
if data.get("return"):
|
||||
# Only read back and disclose the stored row if the actor is also
|
||||
# allowed to view this table - update-row alone must not be usable
|
||||
# to read data the actor cannot otherwise see.
|
||||
if data.get("return") and await self.ds.allowed(
|
||||
action="view-table",
|
||||
resource=TableResource(database=resolved.db.name, table=resolved.table),
|
||||
actor=request.actor,
|
||||
):
|
||||
results = await resolved.db.execute(
|
||||
resolved.sql, resolved.params, truncate=True
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1157,6 +1157,15 @@ class TableInsertView(BaseView):
|
|||
# TODO: narrow to expected write errors so Datasette bugs surface as 500s
|
||||
return Response.error([str(e)])
|
||||
result = {"ok": True}
|
||||
# Only read back and disclose stored rows if the actor is also
|
||||
# allowed to view this table - insert-row/update-row alone must
|
||||
# not be usable to read data the actor cannot otherwise see.
|
||||
if should_return and not await self.ds.allowed(
|
||||
action="view-table",
|
||||
resource=TableResource(database=database_name, table=table_name),
|
||||
actor=request.actor,
|
||||
):
|
||||
should_return = False
|
||||
if should_return:
|
||||
if upsert:
|
||||
# Fetch based on initial input IDs
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue