Repository navigation
fix(safety): protected paths need one confirmation even in full mode (O94) - #93
Merged
Merged
Conversation
Writing/deleting/moving .git, .ssh, shell rc, .env, or Moss config always asks once in interactive full mode and is denied in -p. Shell write targets come from O97 detectShellWriteTargets; chmod/chown/chgrp are an O94-only supplement. Default full mode is unchanged for normal paths. Reads and git's own .git writes are not gated.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
…x; script writes tracked as O101
QiaolongLi1201
added a commit
that referenced
this pull request
Oct 11, 2026
Roadmap v1.1: fork's 11 draft PRs all concluded; upstream campaign PRs #76-#92 merged (O13/O43/O57-58/O66-67/O70/O83/O85-88/O90/O97); npm first release @rdk-moss/agent@0.26.1 live (rolling policy supersedes P4 gate, remaining obligations folded into P2/P3); in-flight O94 (#93), O98 (#94), SDK draft #68. AGENTS.md package name fixed to @rdk-moss/agent.
QA BLOCK on #93: approval only took the headless deny path when !stdin.isTTY, so moss -p on a real terminal fell through to defaultAskUser and hung. Detect print mode from the printMode option (wired from parsedArgs.print) or argv -p/--print, and deny immediately. Also: rm maps to delete/「删除」 in the protected-path prompt; startup full-mode banner no longer says "no approval prompts" (protected paths still ask once). Exit code after deny stays with O98. Tests: TTY+printMode and TTY+argv -p regressions with 2s hang timeout; rm label; locale banner assertions updated.
This was referenced Oct 11, 2026
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.
O94: full 模式下写受保护路径也要问一次
Problem
信任工作区不等于同意改
~/.ssh、.bashrc、.git、.env或 Moss 自己的配置。默认full模式对普通路径的行为不变;只在写入 / 删除 / 移动受保护路径时多问一次(-p/ 非交互直接拒绝)。Change
src/safety/protected-paths.ts:分类受保护路径(.git/、~/.ssh/、shell rc/profile、.env/.env.*/.envrc、Moss 配置与信任文件);realpath + 大小写无关匹配;软链接 /../绕过有测。detectShellWriteTargets(src/safety/shell-write-detect.ts)。命中规则:-p拒绝uncertain=true且mentions(或命令文本)点名受保护路径 → 确认 /-p拒绝uncertain但没有任何受保护引用(如python script.py)→ 不问(约定行为)chmod/chown/chgrp当写入;本 PR 本地补充这些操作数,权限变更仍要确认。src/cli/protected-path-prompt.ts:第一行写明操作、路径原文、原因;选项最多三个(允许这一次 / 拒绝 / 本会话同一路径都允许);默认选中拒绝,回车不放行。中英文都有。src/cli/approval.ts:在resolvePermissionDecision之后、ask 之前;deny / block 规则仍优先(只能更严,不放宽)。.git/不拦;git commit/checkout/stash等 git 自己写.git/不拦;普通src//test/编辑不问。默认
full模式未改宽。 只在受保护路径上收紧。Base
基于最新
drobotics/main(含 O97 合并cfd720ce)。Grok 草稿基于 #92 head937a2581;合入时 patch 干净应用。中间态占位shell-write-targets.ts已删除,策略只消费 O97 的detectShellWriteTargets。Known limitations(必须诚实)
python fix.py、npm run x、make):detector 标uncertain但不点名受保护路径 → 不提示。约定行为,不是 bug。$HOME字面量:O97 detector 不展开;靠策略侧 basename / 路径段 / 文本正则兜底。uncertain;只有命令文本 /mentions提到受保护名才确认。Tests
npm run check(format + lint + typecheck)npm test(Node 22.16.0)Revert-red(撤 O94 策略、保留 O97 detector)
撤掉后仍绿约 26 条:
git commit/checkout/stash、读.git、改src//test/、.envrc.example、O90 风格 0 提示、python script.py不问、detector-shape 等护栏 / 负例。其余 44 条变红,覆盖受保护路径确认与-p拒绝。UX gate(待签)
按合门:正常做一单 O90 风格任务,全程确认提示 0 次。本 PR 有对应护栏单测(
O90-style task flow → 0 prompts);端到端 UX 实测由 Moss UX 在 PR head 上跑完再签。QA 合门提醒
.git/不拦node -e写同一受保护路径(与 O97 同一判法)安全边界说明
shell 层受保护路径检测是尽力拦截,不是沙箱:只识别命令行里能静态解析的写入目标;经脚本间接写入(
python x.py/node script.js/bash x.sh)不在覆盖范围,跟踪于 O101(P2)。