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:
qinglong
2026-06-13 21:04:52 +08:00
parent 1301aeb9b7
commit 95a2f375e8
3 changed files with 12 additions and 7 deletions
+2
View File
@@ -23,3 +23,5 @@ config/services/
!docs/API_Auth_Flow.md !docs/API_Auth_Flow.md
!docs/SenSu 插件开发详细指南.md !docs/SenSu 插件开发详细指南.md
!docs/SenSu 框架基本架构.md !docs/SenSu 框架基本架构.md
plugins/*/config.yaml
!plugins/*/config.yaml.example
+9
View File
@@ -77,6 +77,15 @@ class Plugin(PluginWebMixin):
try: try:
with open(self._config_path, "r") as f: with open(self._config_path, "r") as f:
return yaml.safe_load(f) or {} 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: except Exception:
return {} return {}
@@ -1,13 +1,7 @@
author: SenSu Team author: SenSu Team
description: 🛡️ 多节点 SenSu 集群性能监控 — 实时仪表盘 + 节点管理 description: 🛡️ 多节点 SenSu 集群性能监控 — 实时仪表盘 + 节点管理
name: Sentinel name: Sentinel
nodes: nodes: []
- api_key: sk-035259bb700b17ae51cfd50a717b27281b1a5347b2aa4723
enabled: true
id: node-3733a070
name: PLK110
notes: LocalBian
url: http://127.0.0.1:4200
settings: settings:
auto_start: true auto_start: true
isolation: false isolation: false