security: Sentinel 配置文件模板化 — config.yaml 不入库
- config.yaml → .gitignore (含 API Key 不入库) - config.yaml.example 模板 (空节点列表) - 首次启动自动从模板复制 - 所有插件 config.yaml 统一保护 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -77,6 +77,15 @@ class Plugin(PluginWebMixin):
|
||||
try:
|
||||
with open(self._config_path, "r") as f:
|
||||
return yaml.safe_load(f) or {}
|
||||
except FileNotFoundError:
|
||||
# 从模板创建
|
||||
template = self._config_path + ".example"
|
||||
if os.path.exists(template):
|
||||
import shutil
|
||||
shutil.copy(template, self._config_path)
|
||||
with open(self._config_path, "r") as f:
|
||||
return yaml.safe_load(f) or {}
|
||||
return {}
|
||||
except Exception:
|
||||
return {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user