database: remove debug option
This option was intended for Moonraker developers to live test changes to write protected namespaces. This can be accomplished locally with other methods, thus this option has been removed to prevent users from compromising sections of the database. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
0a2c1904c0
commit
79f867ba83
|
@ -78,7 +78,6 @@ class MoonrakerDatabase:
|
||||||
self.eventloop = self.server.get_event_loop()
|
self.eventloop = self.server.get_event_loop()
|
||||||
self.namespaces: Dict[str, object] = {}
|
self.namespaces: Dict[str, object] = {}
|
||||||
self.thread_lock = ThreadLock()
|
self.thread_lock = ThreadLock()
|
||||||
self.enable_debug = config.getboolean("enable_database_debug", False)
|
|
||||||
self.database_path = os.path.expanduser(config.get(
|
self.database_path = os.path.expanduser(config.get(
|
||||||
'database_path', "~/.moonraker_database"))
|
'database_path', "~/.moonraker_database"))
|
||||||
if not os.path.isdir(self.database_path):
|
if not os.path.isdir(self.database_path):
|
||||||
|
@ -137,18 +136,16 @@ class MoonrakerDatabase:
|
||||||
self.forbidden_namespaces = set(self.get_item(
|
self.forbidden_namespaces = set(self.get_item(
|
||||||
"moonraker", "database.forbidden_namespaces",
|
"moonraker", "database.forbidden_namespaces",
|
||||||
[]).result())
|
[]).result())
|
||||||
# Track debug access and unsafe shutdowns
|
# Remove stale debug counter
|
||||||
debug_counter: int = self.get_item(
|
config.getboolean("enable_database_debug", False, deprecate=True)
|
||||||
"moonraker", "database.debug_counter", 0).result()
|
try:
|
||||||
if self.enable_debug:
|
self.delete_item("moonraker", "database.debug_counter")
|
||||||
debug_counter += 1
|
except Exception:
|
||||||
self.insert_item("moonraker", "database.debug_counter",
|
pass
|
||||||
debug_counter)
|
# Track unsafe shutdowns
|
||||||
unsafe_shutdowns: int = self.get_item(
|
unsafe_shutdowns: int = self.get_item(
|
||||||
"moonraker", "database.unsafe_shutdowns", 0).result()
|
"moonraker", "database.unsafe_shutdowns", 0).result()
|
||||||
msg = f"Unsafe Shutdown Count: {unsafe_shutdowns}"
|
msg = f"Unsafe Shutdown Count: {unsafe_shutdowns}"
|
||||||
if debug_counter:
|
|
||||||
msg += f"; Database Debug Count: {debug_counter}"
|
|
||||||
self.server.add_log_rollover_item("database", msg)
|
self.server.add_log_rollover_item("database", msg)
|
||||||
|
|
||||||
# Increment unsafe shutdown counter. This will be reset if
|
# Increment unsafe shutdown counter. This will be reset if
|
||||||
|
@ -714,10 +711,7 @@ class MoonrakerDatabase:
|
||||||
key: Any
|
key: Any
|
||||||
valid_types: Tuple[type, ...]
|
valid_types: Tuple[type, ...]
|
||||||
if action != "GET":
|
if action != "GET":
|
||||||
if (
|
if namespace in self.protected_namespaces:
|
||||||
namespace in self.protected_namespaces and
|
|
||||||
not self.enable_debug
|
|
||||||
):
|
|
||||||
raise self.server.error(
|
raise self.server.error(
|
||||||
f"Write access to namespace '{namespace}'"
|
f"Write access to namespace '{namespace}'"
|
||||||
" is forbidden", 403)
|
" is forbidden", 403)
|
||||||
|
|
Loading…
Reference in New Issue