Make the read-only filter smarter, to stop false-positives on score endpoints.
This commit is contained in:
parent
14374ef2d3
commit
6004929b35
@ -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),
|
||||
|
Loading…
x
Reference in New Issue
Block a user