From 7825ff12594331196e503e04f649fc8b3784bb8c Mon Sep 17 00:00:00 2001 From: Haitao Pan Date: Mon, 29 Jun 2026 09:48:49 +0800 Subject: [PATCH] security(docs): remove plaintext review credentials, inject from .env The svc.plus review password and the two bridge tokens were committed in plaintext across the manual case / API test docs. Replace every value with a `.env` / secret-store reference and add a tracked .env.example template. Harden .gitignore (.env.*, *.local.env, secrets.env) while keeping !.env.example. Note: git history was rewritten separately to purge the leaked values; the credentials must be rotated regardless. Co-Authored-By: Claude Opus 4.8 --- .env.example | 15 ++++++++++ .gitignore | 5 ++++ .../cloud-account-and-bridge-manual-cases.md | 29 ++++++++++--------- docs/testing/api-script-runbook.md | 15 +++++++--- .../app-external-service-api-test-matrix.md | 4 +-- 5 files changed, 48 insertions(+), 20 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 00000000..0b88a537 --- /dev/null +++ b/.env.example @@ -0,0 +1,15 @@ +# 评审 / 测试凭据模板 —— 复制为本地 `.env`(已被 .gitignore 忽略)后填入真实值。 +# 切勿把真实密码 / Token 写进任何被 git 跟踪的文件、日志或截图。 +# 用法:set -a; source .env; set +a + +# --- svc.plus 只读评审账号 --- +REVIEW_ACCOUNT_BASE_URL=https://accounts.svc.plus +REVIEW_ACCOUNT_LOGIN_EMAIL=review@svc.plus +REVIEW_ACCOUNT_LOGIN_PASSWORD= + +# --- xworkmate-bridge --- +BRIDGE_SERVER_URL=https://xworkmate-bridge.svc.plus +# 组合 1:标准 bridge token +BRIDGE_AUTH_TOKEN= +# 组合 2:评审专用 bridge token +BRIDGE_REVIEW_AUTH_TOKEN= diff --git a/.gitignore b/.gitignore index cd04c7cb..2177ba3e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,10 @@ # Miscellaneous +# Secrets / local env — never commit real credentials. .env.example is the tracked template. .env +.env.* +!.env.example +*.local.env +secrets.env .playwright-mcp/ *.py null/ diff --git a/docs/cases/cloud-account-and-bridge-manual-cases.md b/docs/cases/cloud-account-and-bridge-manual-cases.md index f211b62a..8aa420b6 100644 --- a/docs/cases/cloud-account-and-bridge-manual-cases.md +++ b/docs/cases/cloud-account-and-bridge-manual-cases.md @@ -4,6 +4,10 @@ ## 1. 测试账号与连接参数 +> **凭据注入约定(必读)**:本文档**不保存任何明文密码或 Token**。所有 secret 从本地 `.env` +> (已 gitignore)或 secret store 注入,变量名见仓库根目录 `.env.example`。执行用例前先 +> `set -a; source .env; set +a`,下表只记录变量名与非敏感的端点信息。 + ### 1.1 云端账号 | 项目 | 内容 | @@ -11,32 +15,28 @@ | 账号类型 | 只读评审账号(Apple 审核专用) | | 服务地址 | `https://accounts.svc.plus` | | 邮箱 / 账号 | `review@svc.plus` | -| 密码 | 参考 vault.svc.plus kv/data/accounts.svc.plus/REVIEW_ACCOUNT_LOGIN_PASSWORD | - +| 密码 | 见 `.env`:`$REVIEW_ACCOUNT_LOGIN_PASSWORD`(勿写明文) | ### 1.2 公网 xworkmate-bridge 组合 1 | 环境变量 | 值 | |----------|----| | `BRIDGE_SERVER_URL` | `https://xworkmate-bridge.svc.plus` | -| `BRIDGE_AUTH_TOKEN` | `参考 vault.svc.plus kv/data/accounts.svc.plus/INTERNAL_SERVICE_TOKEN` | - +| `BRIDGE_AUTH_TOKEN` | 见 `.env`:`$BRIDGE_AUTH_TOKEN`(勿写明文) | ### 1.3 公网 xworkmate-bridge 组合 2 | 环境变量 | 值 | |----------|----| | `BRIDGE_SERVER_URL` | `https://xworkmate-bridge.svc.plus` | -| `BRIDGE_REVIEW_AUTH_TOKEN` | `参考 vault.svc.plus kv/data/accounts.svc.plus/BRIDGE_REVIEW_AUTH_TOKEN` | - +| `BRIDGE_REVIEW_AUTH_TOKEN` | 见 `.env`:`$BRIDGE_REVIEW_AUTH_TOKEN`(勿写明文) | ### 1.4 本地 xworkmate-bridge | 环境变量 | 值 | |----------|----| | `BRIDGE_SERVER_URL` | `http://127.0.0.1:8787` | -| `BRIDGE_AUTH_TOKEN` | `cat ~/.ai_workspace_auth_token` | - +| `BRIDGE_AUTH_TOKEN` | 见 `.env`:`$BRIDGE_AUTH_TOKEN`(勿写明文) | --- @@ -189,7 +189,7 @@ 2. 切换到 `svc.plus 云端同步` 3. 在 `服务地址` 输入 `https://accounts.svc.plus` 4. 在 `邮箱或账号` 输入 `review@svc.plus` - 5. 在 `密码` 输入 `只读评审账号密码` + 5. 在 `密码` 输入 `$REVIEW_ACCOUNT_LOGIN_PASSWORD`(从 `.env` 读取,勿写明文) 6. 点击 `登录` 7. 等待账号同步完成 - 期望结果 @@ -212,7 +212,7 @@ 1. 在设置页退出当前账号 2. 关闭或返回设置页 3. 再次进入 `Settings -> Integrations -> svc.plus 云端同步` - 4. 使用 `review@svc.plus` / `只读评审账号密码` 重新登录 + 4. 使用 `review@svc.plus` / `$REVIEW_ACCOUNT_LOGIN_PASSWORD`(从 `.env` 读取)重新登录 5. 观察同步状态与本地配置状态 - 期望结果 - 退出后不会继续显示已登录状态 @@ -260,7 +260,7 @@ 1. 打开 `Settings -> Integrations` 2. 切换到 `AI 智能体工作空间` 3. 在 `Bridge 地址` 输入 `https://xworkmate-bridge.svc.plus` - 4. 在 `鉴权令牌 (TOKEN)` 输入 `对应 BRIDGE_AUTH_TOKEN` + 4. 在 `鉴权令牌 (TOKEN)` 输入 `$BRIDGE_AUTH_TOKEN`(从 `.env` 读取,勿写明文) 5. 点击 `保存配置` 6. 重新进入设置页确认配置仍然存在 7. 发起一次需要 AI 智能体工作空间的任务,确认可建立连接 @@ -284,7 +284,7 @@ - 操作步骤 1. 打开 `Settings -> Integrations -> AI 智能体工作空间` 2. 在 `Bridge 地址` 输入 `https://xworkmate-bridge.svc.plus` - 3. 在 `鉴权令牌 (TOKEN)` 输入 `BRIDGE_REVIEW_AUTH_TOKEN` + 3. 在 `鉴权令牌 (TOKEN)` 输入 `$BRIDGE_REVIEW_AUTH_TOKEN`(从 `.env` 读取,勿写明文) 4. 点击 `保存配置` 5. 重新进入设置页确认配置稳定 6. 发起一次 AI 智能体工作空间任务 @@ -357,7 +357,7 @@ - 操作步骤 1. 打开 `Settings -> Integrations -> AI 智能体工作空间` 2. 在 `Bridge 地址` 输入 `http://127.0.0.1:8787` - 3. 在 `鉴权令牌 (TOKEN)` 输入 `BRIDGE_AUTH_TOKEN` + 3. 在 `鉴权令牌 (TOKEN)` 输入 `$BRIDGE_AUTH_TOKEN`(从 `.env` 读取,勿写明文) 4. 点击 `保存配置` 5. 发起一次 AI 智能体工作空间任务 6. 对照本地 bridge 日志确认请求到达 @@ -490,4 +490,5 @@ | 公网 bridge 组合 2 | ✅ | ✅ | ✅ | ✅ | ✅ | | 本地 bridge | ✅ | ✅ | ✅ | ✅ | ✅ | -> 注意:以上 token 为评审 / 测试用途。执行测试时不得将 token 明文贴入公开 issue、公开日志或截图备注。 +> 注意:以上密码 / token 均为评审 / 测试用途,仅从 `.env`(已 gitignore)或 secret store 注入, +> **禁止**明文写入本文档、git 历史、公开 issue、公开日志或截图备注。一旦发生明文泄漏,先**轮换凭据**,再清理。 diff --git a/docs/testing/api-script-runbook.md b/docs/testing/api-script-runbook.md index 16b85287..7242f92c 100644 --- a/docs/testing/api-script-runbook.md +++ b/docs/testing/api-script-runbook.md @@ -34,11 +34,18 @@ Last Updated: 2026-04-22 - 可选 `BRIDGE_SERVER_URLS`,用于接口脚本同时验证多个 bridge host - 可选 `REVIEW_ACCOUNT_BASE_URL` -推荐直接在命令前临时注入: +凭据从本地 `.env`(已 gitignore)或 secret store 注入,**不要把明文密码/Token 写进文档或命令历史**。先准备 `.env`(参考仓库根目录 `.env.example`),再 `source` 后运行: ```bash -REVIEW_ACCOUNT_LOGIN_PASSWORD='***REMOVED-CREDENTIAL***' \ -BRIDGE_AUTH_TOKEN='' \ +set -a; source .env; set +a # 载入 REVIEW_ACCOUNT_LOGIN_PASSWORD / BRIDGE_AUTH_TOKEN 等 +bash scripts/ci/verify_api_interface_contract.sh +``` + +如需单条命令显式注入,使用变量引用而非明文: + +```bash +REVIEW_ACCOUNT_LOGIN_PASSWORD="$REVIEW_ACCOUNT_LOGIN_PASSWORD" \ +BRIDGE_AUTH_TOKEN="$BRIDGE_AUTH_TOKEN" \ BRIDGE_SERVER_URL='https://xworkmate-bridge.svc.plus' \ bash scripts/ci/verify_api_interface_contract.sh ``` @@ -46,7 +53,7 @@ bash scripts/ci/verify_api_interface_contract.sh 双入口验证示例: ```bash -REVIEW_ACCOUNT_LOGIN_PASSWORD='***REMOVED-CREDENTIAL***' \ +REVIEW_ACCOUNT_LOGIN_PASSWORD="$REVIEW_ACCOUNT_LOGIN_PASSWORD" \ BRIDGE_SERVER_URLS='https://xworkmate-bridge.svc.plus,https://cn-xworkmate-bridge.svc.plus' \ bash scripts/ci/verify_api_interface_contract.sh ``` diff --git a/docs/testing/app-external-service-api-test-matrix.md b/docs/testing/app-external-service-api-test-matrix.md index 1096c04e..4af6eb14 100644 --- a/docs/testing/app-external-service-api-test-matrix.md +++ b/docs/testing/app-external-service-api-test-matrix.md @@ -53,7 +53,7 @@ Last Updated: 2026-04-22 - `url`: `https://accounts.svc.plus` - `login_name`: `review@svc.plus` -- `login_password`: `***REMOVED-CREDENTIAL***` +- `login_password`: 从 `.env` / secret store 注入 `REVIEW_ACCOUNT_LOGIN_PASSWORD`(勿写明文) ### 2.3 鉴权规则 @@ -98,7 +98,7 @@ Last Updated: 2026-04-22 ```json { "identifier": "review@svc.plus", - "password": "***REMOVED-CREDENTIAL***" + "password": "${REVIEW_ACCOUNT_LOGIN_PASSWORD}" } ```