Skip to content

fix: drop cpx and child-process-promise to clear vulnerable transitive deps - #37

Open
varzager wants to merge 1 commit into
wix-incubator:masterfrom
varzager:fix/drop-vulnerable-build-deps
Open

fix: drop cpx and child-process-promise to clear vulnerable transitive deps#37
varzager wants to merge 1 commit into
wix-incubator:masterfrom
varzager:fix/drop-vulnerable-build-deps

Conversation

@varzager

@varzager varzager commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

cpx@1 and child-process-promise@2 are listed as runtime dependencies but are only used by build/test tooling. Both drag vulnerable transitive packages into the published tree, which Dependabot flags for consumers:

  • cpx@^1.5.0chokidar@2micromatch@3braces@1.x/2.xGHSA-grv7-fg5c-xmjg (no patch on the 1.x/2.x line)
  • child-process-promise@^2.2.1cross-spawn@4.0.2GHSA-3xgq-45jj-v275

This PR removes both and replaces them with Node built-ins, so both advisories are fixed at the source with zero new dependencies.

Changes

  • copy-templates: replaced cpx 'src/**/*.template.*' dist/ with scripts/copy-templates.js — a small, dependency-free fs-based recursive copy that preserves the src/-relative structure into dist/.
  • scripts/generateReadme.ts / tests/driver.ts: replaced child-process-promise with the built-in child_process module — util.promisify(exec) for the readme script and a tiny spawnPromise wrapper for the test driver.
  • Removed cpx, child-process-promise, and @types/child-process-promise from package.json; regenerated yarn.lock.
  • Added scripts/copy-templates.js to .eslintignore (the repo's lint script only targets .ts/.tsx).

Result

cpx, child-process-promise, cross-spawn@4, and the chokidar@2 → micromatch@3 → braces@2 chain are gone from the tree entirely. The only remaining braces/cross-spawn copies now come exclusively from devDependencies (eslint, lint-staged), are already patched (braces@3.0.3, cross-spawn@7.0.3), and are never installed by consumers of the published package.

Verification

yarn test (clean-generated → generate-for-type-tests → lint → typecheck → build → jest) passes locally: 31/31 tests, 7/7 snapshots, and the build confirms the template is copied to dist/proxyEngine/proxyEngine.template.ts.


Surfaced by Dependabot in a downstream project consuming this package. Thanks for maintaining this! 🙏

🤖 Generated with Claude Code

…e deps

Both packages were only used by build/test tooling but pulled vulnerable
transitive dependencies into the published package's runtime tree, which
Dependabot flags for consumers:

- cpx@1 -> chokidar@2 -> micromatch@3 -> braces@1.x/2.x
  (GHSA-grv7-fg5c-xmjg, no patch on the 1.x/2.x line)
- child-process-promise@2 -> cross-spawn@4.0.2
  (GHSA-3xgq-45jj-v275)

Replace them with Node built-ins so both advisories are resolved at the
source with zero new dependencies:

- copy-templates: swap `cpx` for scripts/copy-templates.js, a small
  fs-based recursive copy of src/**/*.template.* into dist/.
- generateReadme.ts / tests/driver.ts: swap child-process-promise for
  the built-in child_process module (util.promisify(exec) and a small
  spawn->Promise wrapper).
- Remove cpx, child-process-promise, and @types/child-process-promise
  from package.json and regenerate yarn.lock.

The only remaining braces/cross-spawn copies now come exclusively from
devDependencies (eslint, lint-staged), are already patched
(braces@3.0.3, cross-spawn@7.0.3), and are never installed by consumers
of the published package.

Surfaced by Dependabot in a downstream project consuming this package.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@varzager
varzager force-pushed the fix/drop-vulnerable-build-deps branch from 807f2be to 95bcc33 Compare July 9, 2026 12:11
@eliranhWix

Copy link
Copy Markdown

#skipreview

@wix-s-github-tools

Copy link
Copy Markdown

skipreview by eliranhWix is not available in org wix-incubator.
If the issue persists, contact #dx-platform.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes two runtime dependencies (cpx and child-process-promise) that are only used for build/test tooling, replacing them with Node.js built-ins to eliminate vulnerable transitive dependencies from the published dependency tree.

Changes:

  • Replace cpx with a small fs-based recursive template copy script.
  • Replace child-process-promise usage with built-in child_process (exec + spawn wrapper).
  • Remove the unused deps from package.json and regenerate yarn.lock.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
scripts/copy-templates.js Adds a dependency-free template copier to replace cpx.
package.json Removes cpx / child-process-promise from runtime deps and updates the copy script.
scripts/generateReadme.ts Switches to child_process.exec (promisified) instead of child-process-promise.
tests/driver.ts Replaces child-process-promise spawn with a small Promise-wrapped child_process.spawn.
.eslintignore Excludes the new script file (though lint targets TS/TSX only).
yarn.lock Lockfile update reflecting dependency removals and transitive changes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/copy-templates.js

const SRC_DIR = path.resolve(__dirname, '..', 'src');
const DIST_DIR = path.resolve(__dirname, '..', 'dist');
const TEMPLATE_RE = /\.template\.[^.]+$/;
Comment thread tests/driver.ts
Comment on lines +24 to +30
child.on('close', (code) => {
if (code === 0) {
resolve();
} else {
reject(new Error(`${command} exited with code ${code ?? 'null'}`));
}
});
Comment thread package.json
Comment on lines 18 to 22
"dependencies": {
"@types/flat": "^5.0.2",
"child-process-promise": "^2.2.1",
"cosmiconfig": "^7.0.1",
"cpx": "^1.5.0",
"flat": "^5.0.2",
"format-message-parse": "^6.2.4",
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.

3 participants