Repository navigation
workspace-guard 抽取 + safe-patch 脚本(纠正即约束第二批) - #136
Merged
Merged
Conversation
- workspace-guard.js:sameWorkspace / knownWorkspace 从 routes-v07.js 抽成独立模块。 设计消除:其他路由要校验工作区路径时直接 import,让「不校验」变成「import 不到」。 routes-v07.js 删掉内联副本,改从 workspace-guard.js import + 薄包装。 - safe-patch.mjs:读文件 → 精确替换 → 写回 → 自动 node --check。 替代 node -e(shell 会吃掉正则反斜杠导致假安全)。 找不到旧字符串 / 找到多处都会拒绝执行。
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.
问题
sameWorkspace/knownWorkspace内联在routes-v07.js里,其他路由要校验工作区路径只能自己复制一份(或者忘了校验)。node -e里写正则会被 shell 吃掉反斜杠:\s→s、\d→d,导致「回退脚本写出来的代码是坏的,回退后测试仍然绿」——假安全。这个坑踩过至少 2 次。修法
#3 workspace-guard 抽取(设计消除)
lib/workspace-guard.js:sameWorkspace/knownWorkspace抽成独立模块导出。routes-v07.js删掉内联副本,改从 workspace-guard.js import + 薄包装(保留原来的调用签名)。让「不校验」变成「import 不到」——其他路由需要校验时直接 import,不会漏。
#4 safe-patch.mjs(自行验证)
scripts/safe-patch.mjs:读文件 → 精确字符串替换(不是正则)→ 写回 → 自动node --check。替代
node -e,不会被 shell 转义坑。验证
sticker-manage/sticker-backfill/sticker-manual-tags全绿(行为不变)client-lint/ 三个静态检查全绿safe-patch.mjs --check验证通过workspace-guard.js/routes-v07.js通过