Skip to content

feat(plugins): item 23 archive 插件源 + SHA-256 锁定 (CC 2.1.224, #117) - #118

Merged
dahai80 merged 1 commit into
mainfrom
feat/archive-plugin-source-sha256-item23
Aug 22, 2026
Merged

dahai80 merged 1 commit into
mainfrom
feat/archive-plugin-source-sha256-item23

Conversation

@dahai80

@dahai80 dahai80 commented Aug 22, 2026

Copy link
Copy Markdown
Owner

Closes #117

改动

  • src/utils/plugins/schemas.ts — PluginSourceSchema 新增 archive arm (第 7 源): source: 'archive' + HTTPS url + 可选 sha256 (64-hex regex) + 可选 rootDir。vendored ink 风格 (2-space/no-semi/single-quote), surgical +28/-1。refine 消息加 archive。
  • src/utils/plugins/archiveSource.ts (新, 213 行) — installFromArchive: validateHttpsUrl (拒 http://, 同 mcpbHandler/validateGitUrl precedent) → axios arraybuffer 下载 (120s timeout) → 可选 verifyArchiveIntegrity (createHash sha256 + timingSafeEqual 常量时间) → extractArchiveBuffer (复用 dxt/zip.ts unzipFile/parseZipModes/isPathSafe)。fail-visible (mismatch throw 不解压, Rule 12) / fail-open (无 sha256 跳过+log)。rootDir 剥离 + exec-bit 保留。
  • src/utils/plugins/pluginLoader.ts — cachePlugin switch + generateTemporaryCacheNameForPlugin switch 各加 case 'archive'。surgical +8。
  • src/__tests__/archiveSource.test.ts (新, 250 行) — 20 单测: PluginSourceSchema archive (7) + isArchivePluginSource (3) + verifyArchiveIntegrity (3) + extractArchiveBuffer (5) + installFromArchive validateHttpsUrl (2)。真 zip 字节 (fflate zipSync), 不 mock axios — 安全逻辑走纯函数直测。

安全 (供应链防篡改)

  • 仅 HTTPS (拒 http://)
  • SHA-256 常量时间比较 (防 timing attack)
  • zip-bomb 防护 (复用 dxt/zip.ts: 100k files / 512MB / 1024MB / 50:1 比率)
  • 路径遍历防护 (isPathSafe)
  • exec-bit 保留 (hooks/scripts +x)

验证

  • 20/20 新测 pass
  • 282 全 pass (262 prior + 20 new), 0 fail
  • typecheck 0 errors
  • build:dev + build:dev:full pass
  • 新文件 lint clean; 编辑文件 (schemas.ts) lint baseline 不变 (HEAD 1 error + 2 warning = 预存, 我的编辑 0 新增)
  • schemas.ts diff surgical +28/-1 (无全文件 reformat, 守 vendored ink 风格)

Co-Authored-By: Claude Fable 5 [email protected]

schemas.ts: PluginSourceSchema 新增 archive arm (第 7 源) — HTTPS url
+ 可选 sha256 (64-hex) + 可选 rootDir。vendored ink 风格 surgical +28/-1。

archiveSource.ts (新): installFromArchive — validateHttpsUrl (拒 http://)
→ axios arraybuffer 下载 → 可选 SHA-256 常量时间校验 (createHash
+ timingSafeEqual) → extractArchiveBuffer (复用 dxt/zip.ts unzipFile
/parseZipModes/isPathSafe, zip-bomb + 路径遍历防护 + exec-bit 保留)。
fail-visible (mismatch throw 不解压) / fail-open (无 sha256 跳过+log)。

pluginLoader.ts: cachePlugin + generateTemporaryCacheNameForPlugin 各加
case 'archive'。surgical +8。

20 单测: schema 校验/isArchivePluginSource/verifyArchiveIntegrity
/extractArchiveBuffer/installFromArchive validateHttpsUrl。真 zip 字节
(fflate zipSync), 不 mock axios。

Refs #117
Closes #117

Co-Authored-By: Claude Fable 5 <[email protected]>
@dahai80
dahai80 merged commit 2d6b3ed into main Aug 22, 2026
1 check passed
@dahai80
dahai80 deleted the feat/archive-plugin-source-sha256-item23 branch August 22, 2026 01:15
dahai80 added a commit that referenced this pull request Aug 22, 2026
Patch release bundling 17 commits since v0.4.23:
- item 15(a) MLX OOM auto-recovery gc+retry (#129)
- #7 one-click diagnostic fixAction framework (#131)
- 维度5 background-default spawn FUSION_SUBAGENT_DEFAULT_BACKGROUND (#127)
- #4 proactive MLX OOM detection via /v1/health (#125)
- item 17 fullscreen pre-compact history + :598 synthetic decouple (#123)
- item 25B workflow stagger fan-out (#122)
- item 21 auto-mode local rule classifier test coverage (#120)
- item 23 archive plugin source + SHA-256 lock (#118)
- item 24 marketplace command source (#116)
- item 6 transcript disk trimming + crash-safe checkpoint (#114)
- item 5 normalizeMessages secondary normalize cache (#112)
- item 19 screen-reader plaintext render (#110)
- item 16 compact retry countdown + stall hint (#108)
- item 25A workflow execution runtime docs (#106)
- item 25A minimal workflow execution runtime (#105)
- item 12 subagent auto-background threshold (#103)
- item 20 vimInsertModeRemaps dual-key INSERT sequence (#101)

Co-Authored-By: Claude Fable 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

item 23: archive 插件源 + SHA-256 锁定 (CC 2.1.224, §138/§215)

1 participant