## 背景 enhance-0819.md item 23 (矩阵 §138, §215): ``archive`` 插件源 — HTTPS zip 下载 + 可选 SHA-256 锁定。 CC 2.1.224 §138: "Install zip over HTTPS + optional SHA-256 pinning" CC 2.1.224 §215: "src/plugins/ + zip-over-HTTPS" ## 现状 `PluginSourceSchema` (schemas.ts) 现有 6 源: RelativePath/npm/pip/url(git-clone)/github/git-subdir。无 raw zip 下载源。供应链防篡改缺失 — 无字节级校验。 ## 方案 - schemas.ts: 新增 `archive` arm (第 7 源) — `source: 'archive'` + `url` (HTTPS) + 可选 `sha256` (64-hex) + 可选 `rootDir`。vendored ink 风格 (2-space/no-semi/single-quote), surgical +28/-1。 - archiveSource.ts (新): `installFromArchive` — validateHttpsUrl (拒 http://) → axios arraybuffer 下载 → 可选 SHA-256 常量时间校验 (createHash + timingSafeEqual) → extractArchiveBuffer (复用 dxt/zip.ts unzipFile/parseZipModes/isPathSafe)。fail-visible (mismatch throw 不解压) / fail-open (无 sha256 跳过+log)。 - pluginLoader.ts: cachePlugin switch + generateTemporaryCacheNameForPlugin 各加 `case 'archive'`。surgical +8。 - 20 单测: schema 校验 (7) + isArchivePluginSource (3) + verifyArchiveIntegrity (3) + extractArchiveBuffer (5) + installFromArchive validateHttpsUrl (2)。真 zip 字节 (fflate zipSync), 不 mock axios。 ## 安全 仅 HTTPS / SHA-256 常量时间比较 / zip-bomb 防护 (复用 dxt/zip.ts) / 路径遍历防护 (isPathSafe) / exec-bit 保留。 ## 验证 20/20 新测, 282 全 pass, typecheck 0, build:dev + build:dev:full pass, 新文件 lint clean, 编辑文件 lint baseline 不变。
Activity