已开启
fix(op-lint): Stop false-blocking read-only state-file verification commands #587
fix(op-lint): Stop false-blocking read-only state-file verification commands #587
已开启
lizixuan创建于 2 天前
lizixuan
lizixuan
2 天前

Closes #115

问题

isStateWriteCommand 把合法只读核验命令误判为写入,在执行前 throw(报错文案"禁止写入"与实际只读行为矛盾):

  • 只读动词白名单只有 11 个,git diff/status/logsha256sumpython json.loadfor ... stat 全部不覆盖 → 纯只读组合被拦。
  • ; 切分复合命令会把 python3 -c "import json; json.load(...)"(Python 也用 ; 作语句分隔符)切开,状态文件那段 st=json.load(...) 段首不在白名单 → 误判。
  • heredoc 正文提及状态文件名也会被误伤(实际写 MEMORY.md)。

修复(pypto-op-lint.ts)

  • 整命令 python 检测python3 -c / python - <<EOF 不按 ; 切段,只在整个命令层面检测显式写信号(open(...w/a/x)、write_text、json.dump 等);只读 json.load/open(默认 r) 放行。
  • 只读动词集合扩展:git(-C dir) diff/status/log/show/rev-parsesha256sum/sha1sum/md5sum/cksumechofor 循环。
  • 重定向(> / >> 指向状态文件)仍是明确写信号,保持拦截。

验证

新增 5 个测试(git -C diff / sha256sum / python3 json.load / for-stat / heredoc 读 = 放行;echo 重定向 / python json.dump = 拦截);opencode hooks 59 个测试全部通过。

likedislike
合并受阻
lizixuanlizixuan
2 天前 创建了 pull request,commit 5db61133
lizixuanlizixuan
2 天前 关联了issue:[Bug-Report|缺陷反馈]: 【断裂点】pypto-op-lint isStateWriteCommand 对 .orchestrator_state.json 只读命令误拦截(git/sha256sum/python json.load 未入白名单
CANN-robotCANN-robot成员
2 天前 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
2 天前 评论:

Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.


PR Approval Progress

⚠️ This PR does not yet meet the following requirements:lgtm (requires ≥ 2 person(s) per module)、approve (requires ≥ 1 person(s) per module)

Module Approval Details

module lgtm status approve status
repo-cann/pypto-gym ❌ (0/2)(You can also ask: xinweiliu, congqiannan, 周若愚, wangzheng97, wangbing110) ❌ (0/1)(You can also ask: xinweiliu, gaoxingwang, 冯思远, 林嘉树, 尹杰)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

lizixuan1020, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike