Skip to content

Windows: DEP0190 警告 — spawn shell:true + args 数组 #85

Description

@dengmik-commits

问题

启动 deepcode 时出现 Node.js 废弃警告:

(node:123548) [DEP0190] DeprecationWarning: Passing args to a child process
with shell option true can lead to security vulnerabilities, as the
arguments are not escaped, only concatenated.

根因

PR #77 修复 Windows CI 时,将 McpClient 的 spawn 调用从:

const cmd = [this.command + ".cmd", ...args].join(" ");
spawn(cmd, [], { shell: true });

改为:

spawn(this.command, args, { shell: true });

目的是去掉强制拼接 .cmd 后缀,让 cmd.exe 通过 PATHEXT 环境变量自动解析 npx → npx.cmd。但 Node.js 在 shell: true 模式下直接传 args 数组会触发 DEP0190 警告——Node 只做简单拼接不转义,存在注入风险。

修复方案

将 args 手动拼成字符串后传入,避免触发 DEP0190:

- this.process = spawn(this.command, args, {
+ this.process = spawn([this.command, ...args].join(" "), [], {
    stdio: ["pipe", "pipe", "pipe"],
    env: childEnv,
    shell: true,
    windowsHide: true,
  });

逻辑等价——cmd.exe 仍通过 PATHEXT 解析命令,不会触发 DEP0190,也不会有之前的 .cmd 后缀 bug。

Activity

  1. qorzj commented on May 17, 2026

    @qorzj
    Collaborator

    @dengmik-commits 好的。请提一个PR解决,以便后续这个问题可被持续追踪和优化。

  2. dengmik-commits commented on May 17, 2026

    @dengmik-commits
    ContributorAuthor

    PR 已经提交:#87

  3. qorzj commented on May 19, 2026

    @qorzj
    Collaborator

    这个问题已修复,需升级到最新版本0.1.23+

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions