1
0
mirror of synced 2025-02-17 11:18:33 +01:00

Make the read-only filter smarter, to stop false-positives on score endpoints.

This commit is contained in:
Jennifer Taylor 2022-10-07 01:58:15 +00:00
parent 14374ef2d3
commit 6004929b35

View File

@ -69,12 +69,14 @@ class BaseData:
"""
if self.__config.database.read_only:
# See if this is an insert/update/delete
for write_statement in [
"insert into ",
"update ",
"delete from ",
lowered = sql.lower()
for write_statement_group in [
["insert into"],
["update", "set"],
["delete from"],
]:
if write_statement in sql.lower() and not safe_write_operation:
includes = all(s in lowered for s in write_statement_group)
if includes and not safe_write_operation:
raise Exception('Read-only mode is active!')
return self.__conn.execute(
text(sql),