feat(config): 涉密内容外置到配置目录(档案 140)

把散落在代码里的真实部署值统一收进 config/,代码改为引用配置,
使仓库副本/开源导出不再带出生产域名、IP、内网路径与凭据。

新增 config/:platform.env.example(模板)· load.sh(shell 加载器)·
index.cjs(node 加载器)· README.md(键一览与优先级)。
真实值放 config/platform.env —— 已 .gitignore 排除,不入库、不进导出。

TS 侧新增 src/platform-paths.ts 作部署路径的唯一解析处(零副作用):
platformDir/stateDir/backupDir/artifactDir/installDir/scriptPath。
config.ts 接入这些字段;内置中继种子由生产 URL 改为空(改由
DSHS_OVERLAY_BOOTSTRAP_SEEDS 提供)。修掉 5 处硬编码绝对路径,
src/** 注释中性化 116 行/53 文件。

scripts/** 36 个内部运维脚本:真令牌/PG 口令/隧道目标/主机号/路径
一律改从配置取;web/wake.html 的注册域白名单改为运行时从
location.hostname 推导;test/** 夹具 119 行/13 文件改 RFC 2606/5737
保留值,并把「内置种子必须为空」固化为回归断言。

取证:tsc 0 错;npm test 373/375(唯一失败 lease 属既有);
全仓扫描(大小写不敏感)代码面涉密标识 = 0;已部署 47 并零回归
(/opt/dsh/* 未搬家,/var/lib/dshs/platform 未被误建)。
This commit is contained in:
admin committed 2026-09-19 15:12:19 +08:00
1 parent 9c2e7975ac
commit 452924d89c
100 files changed
+1167 -453

No files matched your search

+7 -6
View File
@@ -1,11 +1,12 @@
#!/usr/bin/env bash
. "$(cd "$(dirname "$0")/.." && pwd)/config/load.sh"
# 校验:SQLite 与 PG 两侧的 users 明细 + 与磁盘目录对照(判断 2 vs 7 是孤儿目录还是迁移漏行)
set -uo pipefail
cd /opt/dshs-cluster || exit 1
cd "$DSH_INSTALL_DIR"-cluster || exit 1
echo "=== SQLite 侧(只读打开,含 WAL) ==="
node -e '
const D = require("better-sqlite3");
const db = new D("/var/lib/dshs/dshs.db", { readonly: true });
const db = new D(""$DSH_DB_FILE"", { readonly: true });
const users = db.prepare("select id, username, role, uid from users order by rowid").all();
console.log(" users 行数:", users.length);
for (const u of users) console.log(` ${u.username} role=${u.role} uid=${u.uid} id=${u.id}`);
@@ -13,9 +14,9 @@ console.log(" credential_vault:", db.prepare("select count(*) c from credential
console.log(" business_plugins:", db.prepare("select count(*) c from business_plugins").get().c);
'
echo "=== PG 侧 ==="
PGPASSWORD=dshs_cluster_2026 /usr/bin/psql -h 127.0.0.1 -p 15432 -U dshs -d dshs -tAc \
PGPASSWORD=dshs_cluster_2026 /usr/bin/psql -h 127.0.0.1 -p "$DSHS_PG_PORT" -U dshs -d dshs -tAc \
"select username||' role='||role||' uid='||coalesce(uid::text,'NULL')||' id='||id from users order by rowid" 2>&1 | sed 's/^/ /'
echo " PG users 总数: $(PGPASSWORD=dshs_cluster_2026 /usr/bin/psql -h 127.0.0.1 -p 15432 -U dshs -d dshs -tAc 'select count(*) from users')"
echo " PG users 总数: $(PGPASSWORD=dshs_cluster_2026 /usr/bin/psql -h 127.0.0.1 -p "$DSHS_PG_PORT" -U dshs -d dshs -tAc 'select count(*) from users')"
echo "=== 磁盘目录 vs DB ==="
echo " 目录($(ls /var/lib/dshs/users | wc -l) 个):"
ls /var/lib/dshs/users | sed 's/^/ /'
echo " 目录($(ls "$DSH_USERS_DIR" | wc -l) 个):"
ls "$DSH_USERS_DIR" | sed 's/^/ /'