From 95a2f375e8b68262613b0e0f7d11932e53c49b4b Mon Sep 17 00:00:00 2001 From: qinglong Date: Sat, 13 Jun 2026 21:04:52 +0800 Subject: [PATCH] =?UTF-8?q?security:=20Sentinel=20=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=A8=A1=E6=9D=BF=E5=8C=96=20=E2=80=94=20con?= =?UTF-8?q?fig.yaml=20=E4=B8=8D=E5=85=A5=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - config.yaml → .gitignore (含 API Key 不入库) - config.yaml.example 模板 (空节点列表) - 首次启动自动从模板复制 - 所有插件 config.yaml 统一保护 Co-Authored-By: Claude --- .gitignore | 2 ++ plugins/sentinel/__init__.py | 9 +++++++++ plugins/sentinel/{config.yaml => config.yaml.example} | 8 +------- 3 files changed, 12 insertions(+), 7 deletions(-) rename plugins/sentinel/{config.yaml => config.yaml.example} (57%) diff --git a/.gitignore b/.gitignore index 76f436a..5958261 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,5 @@ config/services/ !docs/API_Auth_Flow.md !docs/SenSu 插件开发详细指南.md !docs/SenSu 框架基本架构.md +plugins/*/config.yaml +!plugins/*/config.yaml.example diff --git a/plugins/sentinel/__init__.py b/plugins/sentinel/__init__.py index da2b9df..0e7b253 100644 --- a/plugins/sentinel/__init__.py +++ b/plugins/sentinel/__init__.py @@ -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 {} diff --git a/plugins/sentinel/config.yaml b/plugins/sentinel/config.yaml.example similarity index 57% rename from plugins/sentinel/config.yaml rename to plugins/sentinel/config.yaml.example index bb1eb51..e98526e 100644 --- a/plugins/sentinel/config.yaml +++ b/plugins/sentinel/config.yaml.example @@ -1,13 +1,7 @@ author: SenSu Team description: 🛡️ 多节点 SenSu 集群性能监控 — 实时仪表盘 + 节点管理 name: Sentinel -nodes: -- api_key: sk-035259bb700b17ae51cfd50a717b27281b1a5347b2aa4723 - enabled: true - id: node-3733a070 - name: PLK110 - notes: LocalBian - url: http://127.0.0.1:4200 +nodes: [] settings: auto_start: true isolation: false