Repository navigation
fix(local): reject unsafe paths in installer state - #911
Open
rudycelekli wants to merge 1 commit into
Open
rudycelekli wants to merge 1 commit into
rudycelekli wants to merge 1 commit into
Conversation
Port the state-path validation from Tencent#33 into local/. Co-authored-by: Qiaochu Hu <110803307+hobostay@users.noreply.github.com>
Yanami-2K
approved these changes
Nov 16, 2026
Yanami-2K
left a comment
Collaborator
There was a problem hiding this comment.
已核对 local/src/devflow_cli/core.py:load_state 现在会拒绝非 dict 的状态和缺少 files 列表的安装记录;is_safe_state_path 同时按 POSIX 和 Windows 规则拒绝带 anchor 的路径、..、空串、. 和 NUL。我逐一推演了 C:keep.txt、\keep.txt、. 等边界,都会被拦下。这是真实的安全问题:篡改过的安装状态可能让 update 或 uninstall 写入、删除项目外的文件。新测试对 8 种非法路径分别验证了 force update、uninstall 和 status 三个入口,并断言项目外的文件内容不变,断言充分。
提示:本 PR 与 #934 改的是同一文件中紧邻的 load_state 和 save_state,后合入的一方可能需要简单 rebase;两者功能互不重叠,都应保留。校验只做字面判断,不处理项目内指向外部的符号链接,这与 PR 描述一致。
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.
What changed
This ports the install-state path validation from @hobostay's #33 to the current
local/tree, following the maintainer's request for a rebased fix. Installer state now requires each recorded path to be relative and contained lexically under the project. The checks apply POSIX and Windows path rules so a state file moved between hosts gets the same validation.Scope
Compatibility
Valid existing install state needs no migration. Invalid paths cause a clear CLI error before managed files are processed.
Validation
cd local && PYTHONPATH=src python3.12 -m unittest discover -s tests -p test_installer.py -vpassed 23 tests.validate.shon this base stops on its existing ripgrep self-match, addressed independently in fix(local): avoid self-matches in public-content validation #909. Full E2E and Gitleaks were not run for this change.Safety