Build/Test Tools: Avoid npx when running build and test tooling. - #13021
Build/Test Tools: Avoid npx when running build and test tooling.#13021adimoldovan wants to merge 2 commits into
Conversation
`npx` downloads a package and its dependencies from the registry when it cannot find that package locally, then runs the install scripts of everything it downloaded. Each call is a point where a compromised package can run code during a build. Replace every `npx` call in the repository with `npm exec --no`, which runs an installed binary and fails when the package is missing. `update-browserslist-db` is now a devDependency at 1.3.1. `browserslist` already required it as `^1.2.3`, so the lockfile hoists a package that was present and adds none. See #65864.
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
a68383d to
73ca3ca
Compare
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
73ca3ca to
5cd9e04
Compare
There was a problem hiding this comment.
Pull request overview
This PR hardens the build/test toolchain by removing npx usage (which can implicitly download and run install scripts) and switching to npm exec --no so tooling runs only when already present in the workspace.
Changes:
- Replace
npxinvocations withnpm exec --noin Grunt tasks and GitHub Actions workflows. - Add
update-browserslist-db@1.3.1as a devDependency and update the lockfile accordingly. - Update the QUnit Playwright config comment to reflect the CI browser strategy (system Chrome channel).
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
tests/qunit/playwright.config.js |
Updates CI-related comment for Playwright browser selection. |
package.json |
Adds update-browserslist-db as a pinned devDependency. |
package-lock.json |
Updates lock entries to reflect the added/pinned dependency version. |
Gruntfile.js |
Switches QUnit, package update, and Browserslist update tasks from npx to npm exec --no. |
.github/workflows/reusable-performance-test-v2.yml |
Uses npm exec --no for Playwright browser installation in performance workflow. |
.github/workflows/reusable-end-to-end-tests.yml |
Uses npm exec --no for Playwright browser installation in E2E workflow. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Trac ticket: 65864
npxdownloads a package and its dependencies from the registry when it cannot find that package locally, then runs the install scripts of everything it downloaded. Each call is a point where a compromised package can run code during a build.This patch replaces every
npxcall in the repository withnpm exec --no, which runs an installed binary and fails when the package is missing.update-browserslist-dbis now a devDependency at 1.3.1.browserslistalready required it as^1.2.3, so the lockfile hoists a package that was present and adds none.Testing instructions
npm ci.npm exec --no -- playwright --version. It prints the installed version and downloads nothing.node_modules/update-browserslist-dband runnpm exec --no -- update-browserslist-db. It fails withnpx canceled due to missing packages and no YES optioninstead of fetching the package. Restore the tree withnpm ci.grunt qunitand confirm the QUnit tests still run.Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5
Used for: Auditing the
npxcall sites. I reviewed and verified the result, including thenpm exec --nobehavior described above.This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.