Skip to content

test(safety): O97a ln/touch/rm/shred 受保护路径用例 + O97b .moss/config.json 不泄密 - #99

Merged
QiaolongLi1201 merged 1 commit into
mainfrom
test/o97-protected-path-and-config-secrets
Oct 11, 2026
Merged

QiaolongLi1201 merged 1 commit into
mainfrom
test/o97-protected-path-and-config-secrets

Conversation

@QiaolongLi1201

Copy link
Copy Markdown
Collaborator

O97a + O97b:#92 合后跟进(只加测试)

对应 QA 安全复审 qa/o97-pr92-security-review.md §3 里的两条存疑项 1、2。这个 PR 只新增一个测试文件 test/o97-followup-protected-and-config.spec.mjs,src 一行没改。

O97a:ln / touch / rm / shred

  • detectShellWriteTargets:ln -s、ln -sf、touch、touch -c、rm、rm -f、shred、shred -u 都识别为写目标(8 条)。
  • findProtectedWrite:同样 8 条命令,在文件被锁时都会被拦;换成别的文件则不拦。
  • O94 受保护路径闸门:这四个命令写入 .git/、~/.ssh、shell rc、.env、.moss/config.json 时,都能命中,类别和操作(write 或 delete)也对;普通文件不命中。

O97b:.moss/config.json 不泄密

先局部读,再 edit 项目里的 .moss/config.json(里面放了一个特征明显的 apiKey)。断言:拒绝信息里写明「not attached for credential files」;不带 [full file:;不出现密钥、apiKey/"model"、首行、字符/字节/行数;文件仍然锁着、内容没改。

撤掉拦截会变红(实测)

  • 把 shell-write-detect.ts 里 ln 和 touch/rm/unlink/shred 两个 case 删掉:17/19 红(剩下 2 条是「不误拦」护栏)。
  • 把 tool-helpers.ts 里 isMossCredentialPath 的判断删掉:O97b 变红。
  • 恢复后 19/19 绿。和 shell-write-detect、partial-read-recovery、o94-protected-paths 一起跑共 66/66 绿。npm run check 本地绿(Node 22.16)。

顺带发现(不在本 PR 范围,请 QA 看)

read_file 不带 offset 读项目 .moss/config.json 时,工具结果里的 apiKey 是原文(假的 sk-ZZZ… 实测没被脱敏)。本 PR 只断言局部读回附这条路径;完整读要不要拦或脱敏,请 QA 定。

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@QiaolongLi1201
QiaolongLi1201 merged commit 9ae3738 into main Oct 11, 2026
10 of 12 checks passed
@QiaolongLi1201
QiaolongLi1201 deleted the test/o97-protected-path-and-config-secrets branch October 11, 2026 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant