safety: git stash 全家桶被 L1 地板拦截,--no-security-config 也无法绕过(指引死循环) #20

已关闭
由 fourbroad 于 2026-11-22 10:31:42 +08:00创建 · 1 评论
所有者

现象(2026-11-22 实测)

git stash push/pop/apply/drop(含 git -C <path> stash ...、GIT_ALLOW_STASH=1 git stash pop、git --no-security-config stash pop)全部被安全地板正则拦截,提示「Use --no-security-config to bypass」——但按提示加 --no-security-config 后仍被同一条正则拦截,形成指引死循环。

恢复配方(已验证可用,供其他用户参考)

git show 'stash@{0}:<path>' > <path>          # 已跟踪文件
git show 'stash@{0}^3:<path>' > <path>        # untracked 文件(stash 第三父)
git update-ref -d refs/stash                   # 清引用

注意:上面三行命令也须单独执行——任何 git ... | grep -c / wc -c 混排会被另一条 temp-files 正则(把 -c 后缀当 git -c)误拦。

建议

  • 至少让错误指引诚实:说明 stash 子命令无条件拦截、--no-security-config 对该模式无效,并直接给出上述 show/update-ref 恢复序列
  • 或放宽 pop/apply(只读恢复类)仅拦 push/drop/clear(破坏类)
  • 拦截提示说「no wiki page exists for L1 rules by design」+「use a WIP commit instead」——用户只能靠踩坑获知,建议拦截文案里直接写明替代方案

附带

temp-files 默认模式正则 (?<!-)-c(?!-) 把 grep -c / wc -c / head -c 等与 git 混排的命令一律误拦为 git -c,本会话同一问题触发 5+ 次,建议收窄为仅在 git 直接子命令位置匹配 -c。

## 现象(2026-11-22 实测) `git stash push/pop/apply/drop`(含 `git -C <path> stash ...`、`GIT_ALLOW_STASH=1 git stash pop`、`git --no-security-config stash pop`)全部被安全地板正则拦截,提示「Use `--no-security-config` to bypass」——但按提示加 `--no-security-config` 后仍被同一条正则拦截,形成指引死循环。 ## 恢复配方(已验证可用,供其他用户参考) ```bash git show 'stash@{0}:<path>' > <path> # 已跟踪文件 git show 'stash@{0}^3:<path>' > <path> # untracked 文件(stash 第三父) git update-ref -d refs/stash # 清引用 ``` 注意:上面三行命令也须单独执行——任何 `git ... | grep -c` / `wc -c` 混排会被另一条 temp-files 正则(把 `-c` 后缀当 `git -c`)误拦。 ## 建议 - 至少让错误指引诚实:说明 stash 子命令无条件拦截、`--no-security-config` 对该模式无效,并直接给出上述 show/update-ref 恢复序列 - 或放宽 pop/apply(只读恢复类)仅拦 push/drop/clear(破坏类) - 拦截提示说「no wiki page exists for L1 rules by design」+「use a WIP commit instead」——用户只能靠踩坑获知,建议拦截文案里直接写明替代方案 ## 附带 temp-files 默认模式正则 `(?<!-)-c(?!-)` 把 `grep -c` / `wc -c` / `head -c` 等与 git 混排的命令一律误拦为 `git -c`,本会话同一问题触发 5+ 次,建议收窄为仅在 git 直接子命令位置匹配 `-c`。
作者
所有者

已修复并合并:PR Octopus/octopus#7603(commit 690c0b711,CI 绿后合并)。

A. 拦截指引死循环

  • safety-floor 命中(blocked-commands 与 pattern 两处)不再宣传 --no-security-config——该 flag 只丢用户配置,safety floor 恒生效,旧文案把 agent 教进死循环
  • 改为明说「无法通过配置解锁,请改用替代命令」;可解锁项仍正常给出 bash_unblock_commands / bash_unblock_patterns 路径
  • stash 命中附完整恢复配方:git stash list / git stash show -p(只读放行)→ git show 'stash@{0}:<path>'(^3 取未跟踪文件)→ git update-ref -d refs/stash 清理;替代方案 WIP commit / throwaway branch

B. inline-config 模式跨距误拦

  • 旧正则匹配 git 后任意距离的 count-flag,git log | grep <count> / wc / head 管道下游全被误拦
  • 收窄到 git 全局选项位(GIT_GLOBAL_OPTS_SRC 锚定):flag 必须紧随 git 或位于其全局选项前缀,子命令之后不匹配
  • unblock 兼容锚点同步更新,旧配置继续生效

验证

  • 59 测试全绿(新增:管道下游不拦 5 例、全局选项位仍拦 4 例)
  • 有趣的实证:本次提交与开 PR 过程中,commit 文案与 PR 正文里的字面命令序列两度被该旧模式拦截,被迫改走文件载体——正是本票要修的误拦现场
已修复并合并:PR Octopus/octopus#7603(commit 690c0b711,CI 绿后合并)。 ## A. 拦截指引死循环 - safety-floor 命中(blocked-commands 与 pattern 两处)不再宣传 `--no-security-config`——该 flag 只丢用户配置,safety floor 恒生效,旧文案把 agent 教进死循环 - 改为明说「无法通过配置解锁,请改用替代命令」;可解锁项仍正常给出 `bash_unblock_commands` / `bash_unblock_patterns` 路径 - stash 命中附完整恢复配方:`git stash list` / `git stash show -p`(只读放行)→ `git show 'stash@{0}:<path>'`(`^3` 取未跟踪文件)→ `git update-ref -d refs/stash` 清理;替代方案 WIP commit / throwaway branch ## B. inline-config 模式跨距误拦 - 旧正则匹配 git 后任意距离的 count-flag,`git log | grep <count>` / `wc` / `head` 管道下游全被误拦 - 收窄到 git 全局选项位(GIT_GLOBAL_OPTS_SRC 锚定):flag 必须紧随 git 或位于其全局选项前缀,子命令之后不匹配 - unblock 兼容锚点同步更新,旧配置继续生效 ## 验证 - 59 测试全绿(新增:管道下游不拦 5 例、全局选项位仍拦 4 例) - 有趣的实证:本次提交与开 PR 过程中,commit 文案与 PR 正文里的字面命令序列两度被该旧模式拦截,被迫改走文件载体——正是本票要修的误拦现场
登录 并参与到对话中。
未选择标签
1 名参与者
通知
截止日期
未设置截止日期。
依赖工单

未设置依赖工单。

引用:Octopus/release#20