[AI][Fix #27] 用带校验的 delete action 取代裸 rm -rf,杜绝路径穿越#32
Open
josephmqiu wants to merge 1 commit into
Open
Conversation
The /delete-ex flow had the agent execute rm -rf with a verbatim
user-supplied slug — '/delete-ex ../..' would escape the exes directory
(with a global install, that's inside the user's skills directory), and
any templating mistake by the model becomes an irreversible deletion.
Adds 'skill_writer.py --action delete' with three layers of defense:
- slug whitelist validation ([a-z0-9][a-z0-9_-]{0,63})
- resolved-path containment check against base-dir
- refusal to delete directories lacking meta.json
SKILL.md (zh + en) now instructs showing the resolved path and name for
explicit confirmation, then calling the tool — never raw rm -rf.
Fixes perkfly#27
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qxv8G25EYkYzQyY6FdJ6qH
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.
Important
🤖 AI 声明:本 PR 由 AI 模型 Claude Fable 5(Anthropic,运行于 Claude Code)编写并在本地测试,经 @josephmqiu 授权提交。
Fixes #27
问题
/delete-ex {slug}让 agent 直接执行rm -rf exes/{slug},slug 来自用户输入且未经任何校验:/delete-ex ../..会拼接出rm -rf exes/../..,删除项目上层目录(全局安装时即用户的 skills 目录内部)rm -rf,任何模板理解偏差都会变成不可逆删除改动
skill_writer.py新增--action delete,内置三重防御:[a-z0-9][a-z0-9_-]{0,63},直接拦截../..之类的输入meta.json的目录拒绝删除(避免误删非 Skill 目录)rm -rf本地测试
测试后确认 base-dir 之外的目录完好无损。
🤖 Generated with Claude Code
https://claude.ai/code/session_01Qxv8G25EYkYzQyY6FdJ6qH