Repository navigation
feat(audit): 审计日志凭证脱敏 (item 22, CC 2.1.224) - #96
Merged
Merged
Conversation
audit log target/detail/error 可能携带嵌入凭证 (e.g. `curl -H "Authorization: Bearer eyJ..."` 200 字符命令切片). sensitiveFiles.ts 仅按路径阻断读, 无内容 脱敏 — 审计落盘仍泄漏 token. redactSecrets() 单遍组合正则 (JWT / Bearer / AWS SigV4 / x-api-key / Basic), 每个 secret span 恰匹配一次, 避免链式 .replace 二次掩码 (Bearer 重掩已掩的 JWT 前缀 eyJ…). maskMiddle: <=8 → 2+…+2, else 4+…+4. createAuditEntry 对 target/detail/error 三字段落盘前脱敏, AuditLogEntry 结构不变. 默认行为: 非凭证文本原样透传, 无副作. 10 单测全过 (JWT/Bearer/SigV4/ x-api-key/Basic/短密钥/空透传/createAuditEntry 三字段/干净字段不动). closes #95 Co-Authored-By: Claude Fable 5 <[email protected]>
dahai80
added a commit
that referenced
this pull request
Aug 20, 2026
追 CC 2.1.196→2.1.234 Tier-1 特性批量落地 (13 PR): 变更自 v0.4.22: - WS1 DirectoryAdded hook + Notification agent_* 类型 (#73) - WS2 堆叠 slash-skill 调用, 最多 5 前导 (#74) - LSP+filecache 内存泄漏 cap, 对齐 CC 2.1.208 (#76) - skill body-defer 懒加载, item 9 (#78) - SessionStart source "fork" 区分 fork 与 resume (#80) - P2.1 子代理护栏 — 并发/会话/深度三限 (#82) - P1.1 大输出 tool_result tail 预览 (#84) - P4.1 --ax-screen-reader 入口点对齐 — env 别名 + settings key (#86) - item 13 WebSearch per-session 搜索次数上限 (#88) - P4.2 §6 /doctor FUSION_* vs ANTHROPIC_* 环境变量冲突检测 (#90) - P4.2 #1+#3 /doctor MLX 网关连通 + 模型加载探测 (#92) - item 4 MCP 工具自动后台化 FUSION_MCP_AUTO_BACKGROUND_MS (#94) - item 22 审计日志凭证脱敏 (#96) - package.json: version 0.4.22 → 0.4.23 Co-authored-by: Claude Fable 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
enhance-0819.md item 22 (CC 2.1.224 沙箱凭证感知). 审计日志落盘的 `target`/`detail`/`error` 字段可能携带嵌入凭证 — Bash 命令切片 (200 字符) 可嵌入 token (`curl -H "Authorization: Bearer eyJ..."`). `sensitiveFiles.ts` 仅按路径模式阻断读 (`.env`/`id_rsa`/`.pem`...), 无内容脱敏 — 审计 JSONL 仍泄漏 secret.
改动
单生产文件 `src/services/audit/auditLog.ts`:
关键设计 — 单遍组合正则: 用 `|` 组合 5 模式到单 regex, 每个 secret span 恰匹配一次. 链式 `.replace` 循环 (初版 bug) 会让后续模式重掩已掩前缀 — Bearer 掩 JWT token 后, 通用 Authorization 模式重掩残留的 `eyJ…` 前缀. 单遍消除该竞态.
不动
验证
默认行为
非凭证文本原样透传 — 无副作, 无 opt-in. 10 单测覆盖: JWT/Bearer/SigV4/x-api-key/Basic/短密钥(<=8)/空透传/`createAuditEntry` 三字段脱敏/干净字段不动.
closes #95
Co-Authored-By: Claude Fable 5 [email protected]