Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[Windows] 插件安装管线文本模式写入 vendor 资源:CRLF 注入致 sha256 全失配与渲染损坏(visualize 0.1.0 实证)

未关闭
#109 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
74/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
node.js, python

调研方向

Trace the Windows plugin vendor extraction and file-writing path around ~/.zcode/cli/plugins/cache/zcode-plugins-official/visualize/0.1.0/skills/visualize/assets/vendor/, then ensure resources are written as binary data without newline conversion. Use the issue’s Python SHA-256 script to compare installed files with manifest.json, and reproduce against the preserved .backup-crlf-20261016/ sample. Done means restored LF resources match their manifest hashes and installation-time hash verification reports mismatches.

由索引模型根据 Issue 内容生成。

描述

环境
  • Windows 11 ARM64(10.0.26200)
  • ZCode Desktop(GLM 桌面版)
  • 插件:visualize 0.1.0(zcode-plugins-official 官方市场安装)
  • 路径:~/.zcode/cli/plugins/cache/zcode-plugins-official/visualize/0.1.0/skills/visualize/assets/vendor/
现象

插件 vendor 资源安装后,实际文件 sha256 与该目录 manifest.json 内声明的 sha256 全部不匹配(8/8 MISMATCH),官方导出(render 管线)产物损坏无法渲染。

根因取证(损坏安装产物 vs npm tarball 恢复版)

损坏产物中 所有 LF 行尾被写为 CRLF(文本模式写入的典型特征);从 npm 原版 tarball(sha512 验真)恢复后 8/8 哈希全部 OK:

文件 损坏态字节 恢复态字节 损坏态 CRLF 数 恢复态 CRLF 数
lucide-1.17.0.js 621,166 601,680 19,521 0
d3-7.9.0.min.js 279,708 279,706 2 0
floating-ui-core-1.7.3.min.js 12,530 12,529 1 0
floating-ui-dom-1.7.4.min.js 10,252 10,251 1 0
(4 个 *.LICENSE 同样 100% CRLF,如 MIT LICENSE 20 处)

首个差异字节示例(d3-7.9.0.min.js @ byte 59):

损坏: ...Mike Bostock\r\n!function(t,n){"ob
恢复: ...Mike Bostock\n!function(t,n){"obj

npm 发布的原版资源均为纯 LF;损坏态把每一个 \n 都变成了 \r\n(lucide.js 19,521 行全部命中,膨胀 19.5KB),manifest.json 的 sha256 因此全部失配。

推断与建议
  • 推断:Windows 安装管线在解包/落盘 vendor 资源时走了文本模式(换行转换)而非二进制流写入。
  • 建议:①vendor 资源写入统一走二进制(Buffer/stream,不做 newline 转换);②安装完成后对 manifest 声明的 sha256 做一次自检,失配即重装/告警,避免损坏静默累积到运行期。
  • 现场保留:损坏样本已备份于该 vendor 目录下 .backup-crlf-20261016/,如需原始样本可提供。
最小复现/校验脚本
import hashlib, json
from pathlib import Path
V = Path.home() / ".zcode/cli/plugins/cache/zcode-plugins-official/visualize/0.1.0/skills/visualize/assets/vendor"
m = json.loads((V / "manifest.json").read_text(encoding="utf-8"))
for e in m["resources"]:
    f = V / e["file"]
    actual = hashlib.sha256(f.read_bytes()).hexdigest()
    print(e["file"], "OK" if actual == e["sha256"] else "MISMATCH")

(恢复方法:从 npm registry 拉 tarball,sha512 验真后覆盖 vendor 文件,哈希即全部对上。)

主要语言
Python
星标
103
派生
78
PR 合并指标
30 天内没有已合并 PR

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

zai-org/zcode-plugins 的其他 Issue

查看 zai-org/zcode-plugins 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。