mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-11 20:01:16 +00:00
only allow setup for allowed system fields
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import json
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
@@ -7,7 +8,14 @@ from openbb_core.app.model.system_settings import SystemSettings
|
|||||||
|
|
||||||
class SystemService:
|
class SystemService:
|
||||||
SYSTEM_SETTINGS_PATH = SYSTEM_SETTINGS_PATH
|
SYSTEM_SETTINGS_PATH = SYSTEM_SETTINGS_PATH
|
||||||
SYSTEM_SETTINGS_ALLOWED_FIELD_SET = {"run_in_isolation", "dbms_uri"}
|
SYSTEM_SETTINGS_ALLOWED_FIELD_SET = {
|
||||||
|
"log_collect",
|
||||||
|
"test_mode",
|
||||||
|
"headless",
|
||||||
|
"debug_mode",
|
||||||
|
"run_in_isolation",
|
||||||
|
"dbms_uri",
|
||||||
|
}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def read_default_system_settings(
|
def read_default_system_settings(
|
||||||
@@ -19,7 +27,13 @@ class SystemService:
|
|||||||
with path.open(mode="r") as file:
|
with path.open(mode="r") as file:
|
||||||
system_settings_json = file.read()
|
system_settings_json = file.read()
|
||||||
|
|
||||||
system_settings = SystemSettings.parse_raw(system_settings_json)
|
system_settings_dict = json.loads(system_settings_json)
|
||||||
|
S = system_settings_dict.copy()
|
||||||
|
for field in S:
|
||||||
|
if field not in cls.SYSTEM_SETTINGS_ALLOWED_FIELD_SET:
|
||||||
|
del system_settings_dict[field]
|
||||||
|
|
||||||
|
system_settings = SystemSettings.parse_obj(system_settings_dict)
|
||||||
else:
|
else:
|
||||||
system_settings = SystemSettings()
|
system_settings = SystemSettings()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user