security: 配置文件模板化 — base_config.yaml 不再入库
- base_config.yaml → .gitignore (含真实密码不入库) - 新增 base_config.yaml.example 模板 (password: CHANGE_ME) - InitService: 检测缺失时自动从模板复制 - 首次启动自动创建配置文件 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -12,3 +12,5 @@ _patches_applied/
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
docs/
|
docs/
|
||||||
data/
|
data/
|
||||||
|
config/framework/base_config.yaml
|
||||||
|
!config/framework/base_config.yaml.example
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
framework:
|
framework:
|
||||||
debug: true
|
debug: true
|
||||||
name: SenSu
|
name: SenSu
|
||||||
version: v0.6.0
|
version: v0.7.0
|
||||||
logging:
|
logging:
|
||||||
debug_level_file: true
|
debug_level_file: true
|
||||||
level: DEBUG
|
level: DEBUG
|
||||||
@@ -22,19 +22,18 @@ auto_start_scripts:
|
|||||||
# enabled: true
|
# enabled: true
|
||||||
# args: []
|
# args: []
|
||||||
# cwd: ~
|
# cwd: ~
|
||||||
|
# API Keys — 服务器间通信凭证 (在 WebUI 设置页管理)
|
||||||
|
# api_keys: []
|
||||||
# TUI配置
|
# TUI配置
|
||||||
tui:
|
tui:
|
||||||
enabled: true
|
enabled: true
|
||||||
refresh_rate: 30
|
refresh_rate: 30
|
||||||
# TUI布局配置
|
|
||||||
layout:
|
layout:
|
||||||
grid_rows: "4fr 5fr 1fr" # 三行布局:日志区域、消息区域、输入区域的比例
|
grid_rows: "4fr 5fr 1fr"
|
||||||
# TUI样式配置
|
|
||||||
styles:
|
styles:
|
||||||
log_area: "border: solid green; overflow-y: auto;"
|
log_area: "border: solid green; overflow-y: auto;"
|
||||||
message_area: "border: solid yellow; overflow-y: auto;"
|
message_area: "border: solid yellow; overflow-y: auto;"
|
||||||
input_area: "border: solid red;"
|
input_area: "border: solid red;"
|
||||||
# TUI日志显示配置
|
|
||||||
log_display:
|
log_display:
|
||||||
max_lines: 200
|
max_lines: 200
|
||||||
# 互联网服务配置
|
# 互联网服务配置
|
||||||
@@ -42,15 +41,11 @@ internet:
|
|||||||
websocket:
|
websocket:
|
||||||
host: "0.0.0.0"
|
host: "0.0.0.0"
|
||||||
port: 4240
|
port: 4240
|
||||||
# 其他websocket配置...
|
|
||||||
http:
|
http:
|
||||||
host: "0.0.0.0"
|
host: "0.0.0.0"
|
||||||
port: 4200
|
port: 4200
|
||||||
# 其他http配置...
|
|
||||||
panel:
|
panel:
|
||||||
entrance:
|
entrance:
|
||||||
path: "/SenSu"
|
path: "/SenSu"
|
||||||
username: "admin"
|
username: "admin"
|
||||||
password: "admin"
|
password: "CHANGE_ME" # 首次启动请修改!
|
||||||
|
|
||||||
|
|
||||||
@@ -20,5 +20,27 @@
|
|||||||
"framework.command.execute"
|
"framework.command.execute"
|
||||||
],
|
],
|
||||||
"timestamp": 16793.53933677
|
"timestamp": 16793.53933677
|
||||||
|
},
|
||||||
|
"0262acd7": {
|
||||||
|
"plugin_name": "sentinel",
|
||||||
|
"permissions": [
|
||||||
|
"plugin.sentinel.read",
|
||||||
|
"plugin.sentinel.write",
|
||||||
|
"plugin.network.access",
|
||||||
|
"framework.event.subscribe",
|
||||||
|
"framework.command.execute"
|
||||||
|
],
|
||||||
|
"timestamp": 17027.386824076
|
||||||
|
},
|
||||||
|
"900e1365": {
|
||||||
|
"plugin_name": "sentinel",
|
||||||
|
"permissions": [
|
||||||
|
"plugin.sentinel.read",
|
||||||
|
"plugin.sentinel.write",
|
||||||
|
"plugin.network.access",
|
||||||
|
"framework.event.subscribe",
|
||||||
|
"framework.command.execute"
|
||||||
|
],
|
||||||
|
"timestamp": 17177.106703342
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -93,7 +93,7 @@ commands:
|
|||||||
permissions:
|
permissions:
|
||||||
- framework.command.test
|
- framework.command.test
|
||||||
source: internal
|
source: internal
|
||||||
last_updated: 16793.516549165
|
last_updated: 17177.060053342
|
||||||
plugin_commands:
|
plugin_commands:
|
||||||
sentinel:
|
sentinel:
|
||||||
sentinel: *id001
|
sentinel: *id001
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
http_port: 4200
|
http_port: 4200
|
||||||
last_updated: 16793.540021822
|
last_updated: 17177.1104973
|
||||||
plugin_routes:
|
plugin_routes:
|
||||||
sentinel:
|
sentinel:
|
||||||
- methods:
|
- methods:
|
||||||
|
|||||||
@@ -118,6 +118,15 @@ class InitService:
|
|||||||
with open(base_config_file, 'r', encoding='utf-8') as f:
|
with open(base_config_file, 'r', encoding='utf-8') as f:
|
||||||
self.configs['base'] = yaml.safe_load(f)
|
self.configs['base'] = yaml.safe_load(f)
|
||||||
logger.debug("基础配置加载成功")
|
logger.debug("基础配置加载成功")
|
||||||
|
else:
|
||||||
|
# 从模板复制
|
||||||
|
template = self.config_path / "base_config.yaml.example"
|
||||||
|
if template.exists():
|
||||||
|
import shutil
|
||||||
|
shutil.copy(template, base_config_file)
|
||||||
|
logger.info(f"📋 从模板创建配置文件: {base_config_file}")
|
||||||
|
with open(base_config_file, 'r', encoding='utf-8') as f:
|
||||||
|
self.configs['base'] = yaml.safe_load(f)
|
||||||
else:
|
else:
|
||||||
logger.warning("基础配置文件不存在,使用默认配置")
|
logger.warning("基础配置文件不存在,使用默认配置")
|
||||||
self.configs['base'] = self._get_default_base_config()
|
self.configs['base'] = self._get_default_base_config()
|
||||||
|
|||||||
Reference in New Issue
Block a user