Skip to content

[1.5.2 Patch][P1] 统一报告、端口、日志、commandLine 脱敏工具 #80

Description

@weidonglang

背景

DevEnv Manager 会导出诊断报告、端口详情、MySQL 错误摘要、Python 分析、Git/GitHub 检查、Docker/WSL 状态和本地服务信息。这些内容可能包含用户目录、项目路径、token、password、secret、key、Authorization、Bearer 等敏感信息。

当前不同模块有局部脱敏逻辑,但缺少统一工具和统一测试。

风险

  • 导出报告可能暴露用户名、项目路径、公司信息。
  • commandLine 可能包含 token、password、secret。
  • 端口历史如果保存完整 commandLine,存在隐私风险。
  • 不同模块脱敏标准不一致。

修复目标

新增统一脱敏模块,所有报告、日志、端口详情和历史记录统一调用。

建议函数

redact_sensitive_text(text: &str) -> String
redact_path(path: &str) -> String
redact_command_line(command: &str) -> String
redact_json_value(value: serde_json::Value) -> serde_json::Value

脱敏规则

至少覆盖:

password=
passwd=
pwd=
token=
secret=
apikey=
api_key=
access_key=
private_key=
Authorization: Bearer
Bearer <token>
--token xxx
--password xxx
-p xxx,如上下文明确是密码
C:\Users\真实用户名 → %USERPROFILE%
用户桌面/下载/文档真实路径 → %USERPROFILE%\Desktop 等
私钥文件路径和内容
.env 内容

影响范围

必须接入:

  • doctor report markdown/json。
  • env reliability report。
  • port detail / port history。
  • commandLine 展示。
  • MySQL error log tail。
  • Python analysis / pip output。
  • Git/GitHub diagnostic。
  • Docker/WSL diagnostic。
  • exported JSON。

UI 要求

  • UI 中展示脱敏后的 commandLine。
  • 如果用户需要复制完整路径,必须明确是“复制完整路径”,且只在本地复制,不进入报告。
  • 报告中默认使用脱敏路径。

测试要求

新增测试:

  • password/token/secret 被替换。
  • Bearer token 被替换。
  • Windows 用户目录被替换为 %USERPROFILE%
  • 正常版本号、端口号、工具名不会被误删。
  • JSON 嵌套字段也被脱敏。
  • MySQL error log 脱敏仍保留错误码。
  • 端口 commandLine 脱敏后不含 token。

验收标准

  • 所有报告导出默认脱敏。
  • 端口历史不保存未脱敏 commandLine。
  • cargo test --all-targets 通过。
  • npm run build 通过。
  • release notes 记录隐私保护增强。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions