Repository navigation
fix(validate): plugin.json 里的路径也按可移植性判定 - #169
Merged
MyPrototypeWhat merged 1 commit intoNov 27, 2026
Merged
Conversation
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.
plugin.json里的路径以前没过可移植性检查,现在过了。icon写成../../../outside-icon.png时npm run check报 OK,然后顺着这条路径真去读了包外的文件。宿主 MiniMax Code 对同一个路径报PATH_TRAVERSAL。这回把icon、darkIcon、mcpServers、skills四个字段交给miniapp.json已经在用的normalizePluginPath,判定挪到查文件之前。这不是理论问题。包外放一张真 PNG,校验报
icon-dotdot: OK;把那张 PNG 移走,同一条命令立刻变成LAYOUT_IMAGE_INVALID icon file does not exist。它确实去包外找了文件。宿主那三个读取入口对同一个路径都报PATH_TRAVERSAL。docs/package-contract.md的 Portable paths 那节一直写着 every path inside the package, and every path written in a manifest, must be portable,下面还列了 No . or .. segments。AGENTS.md也有一句 Paths are portable: ASCII, no symlinks, no .., npm run check enforces the full rule set。但实现里只有miniapp.json走了normalizePluginPath,plugin.json一个字段都没走,全靠ICON_PATH这类正则挡着。而[A-Za-z0-9._-]这个字符类本身就把..当合法的一段,所以挡不住。改动就是在两个地方插进
normalizePluginPath,一处管两个图标字段,一处管引用字段,都用规范化后的值去拼路径。没有另写一套点段判断,两处路径现在共用同一个函数。有一处我特意没收。宿主对
apps和hooks是放行加一条诊断,文档写着客户端遇到坏的 apps 条目是跳过而不是拒绝整包。这两个字段保持原样,判定不出来就交给宿主。hostBindings和agents也一样,它们的前缀正则本来就会挡掉带..的写法,这次没动。合法写法没有误伤。
icon.png和./icon.png在改前改后都是 exit 0。这也是没用portablePathIssue的原因,那个函数会把./icon.png判成非法,而宿主接受它。normalizePluginPath会先剥掉前导的./再比。零回归是量出来的。完整克隆上
node scripts/validate.mjs的输出与未改基线逐字节相同,md5 都是22e5461b67389f133403ca8c2b5490c0。仓库 36 个包共 77 条 manifest 路径(icon 39、darkIcon 3、mcpServers 15、skills 20),按新规则全过,没有一条含..。测试加了五条。三条有判别力,单独盖到未改的上游会红:
sub/../icon.png这种解析后还在包内的点段、../shared/icon.png这种真越界、以及引用字段的点段。另外两条是护栏,在改前改后都是绿的,一条锁合法路径不回归,一条锁apps和hooks的宽容不被顺手改掉。全量 96 条过。没验证的部分说清楚。本机只有 3.1.14,没在 3.1.11 上复核,
PATH_TRAVERSAL在三个读取入口一致,但我没翻旧版源码确认它当年也这样。另外同一轮还发现非 UTF-8 文本和大小写折叠这两类也是仓库放行、宿主拒绝,按仓库规矩契约改动单独开 PR,这次没塞进来。Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.