From 1778044bd84d80c14fa65316cf95e32c46b5ea27 Mon Sep 17 00:00:00 2001 From: LamGC Date: Wed, 14 Oct 2026 17:02:44 +0800 Subject: [PATCH] fix: validate dependency upgrades and mitigate tooling advisories --- .github/workflows/ci.yml | 4 +- SOURCE.md | 6 +- docs/dependency-security-review.md | 96 ++++++++++++ docs/player-bundle-review.md | 62 ++++++++ languages/wp-asciiplayer.pot | 2 +- package-lock.json | 234 ++++++++++++++++++++++------- package.json | 22 ++- scripts/i18n.mjs | 6 +- tests/js/i18n.test.js | 8 +- tests/js/toolchain.test.js | 37 +++++ 10 files changed, 408 insertions(+), 69 deletions(-) create mode 100644 docs/dependency-security-review.md create mode 100644 docs/player-bundle-review.md create mode 100644 tests/js/toolchain.test.js diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 782d0db..fdb4576 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,8 +47,10 @@ jobs: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: - node-version: '24' + node-version: '24.18.0' cache: npm + - name: Use the documented npm toolchain + run: npm install --global npm@11.19.0 - run: npm ci - run: npm run build - run: npm test diff --git a/SOURCE.md b/SOURCE.md index a7cdd6d..16c7247 100644 --- a/SOURCE.md +++ b/SOURCE.md @@ -4,12 +4,16 @@ This distribution contains the plugin's PHP and JavaScript source, block metadat build configuration, scripts, and npm lockfile. The development repository is https://github.com/LamGC/wp-asciiplayer . -Use Node.js 24 (24.15 or later), npm, and the standard `zip` command: +Use Node.js 24.18+ (24.x) or 26+, npm 11.16+, and the standard `zip` command: npm ci npm run build npm run package +Node.js 22 and 25 are not supported by the complete development toolchain. +The Node requirement is for building/testing only; the plugin still supports +WordPress 6.3 and PHP 7.4. + The installable output is `dist/wp-asciiplayer.zip`. Generated assets are never loaded from a CDN. `scripts/vendor.mjs` copies the pinned official npm `asciinema-player@3.17.0` distribution, verified by package-lock integrity, into diff --git a/docs/dependency-security-review.md b/docs/dependency-security-review.md new file mode 100644 index 0000000..d5d309f --- /dev/null +++ b/docs/dependency-security-review.md @@ -0,0 +1,96 @@ +# Dependency security review + +Reviewed 2026-10-14 against the main-branch lockfile and fresh npm audit. Baseline: **44 affected package records (2 critical, 19 high, 20 moderate, 3 low), representing 15 distinct advisories**. The package-record count includes vulnerable packages and their affected parents; it is not 44 distinct security defects. All mapped paths originate in development dependencies. The final production-only root-lock audit reports zero findings; the separately vendored browser player is assessed in [player-bundle-review.md](player-bundle-review.md). + +## Implemented narrow changes + +Retain the current WordPress parent packages: npm registry reports `@wordpress/env@11.17.0` and `@wordpress/scripts@36.1.0` as current latest. This change uses scoped overrides: + +```json +{ + "copy-webpack-plugin": { "serialize-javascript": "7.0.5" }, + "markdownlint-cli": { "js-yaml": "5.4.3", "smol-toml": "1.9.1" }, + "simple-git": { "@simple-git/argv-parser": "2.0.1" } +} +``` + +- `serialize-javascript`: the current `copy-webpack-plugin@10.2.4` calls the CommonJS serializer for cache keys. Version 7 retains that callable CommonJS API. Its major-version requirement is Node >=20, already satisfied by this project. Isolated serialization smoke tests passed. Upgrading the entire plugin to 14 would be a larger, unnecessary compatibility change. [v7 release](https://github.com/yahoo/serialize-javascript/releases/tag/v7.0.0) +- `js-yaml`: 5.4.1 is the minimum patched version; 5.4.3 is the latest verified patch. Scope it to `markdownlint-cli`; that package pins `~5.2.1`. Do not override js-yaml globally: wp-env still calls `yaml.safeLoad`, which is unavailable in modern majors. The separate wp-env -> js-yaml 3 -> argparse 1 -> sprintf-js path remains. +- `smol-toml`: 1.9.0 is the minimum patched version; 1.9.1 is the latest verified patch. Scope it to markdownlint-cli, which pins `~1.7.0`. The CommonJS parse API works and the null-prototype result matches the installed older version. +- `qs`: 6.16.0 fixes both findings. **Prefer the in-range Express 4.22.2 -> 4.22.3 update**, because official metadata confirms 4.22.3 pins qs `~6.16.0`. If lockfile regeneration cannot resolve that parent update, a scoped `express -> qs: 6.16.0` override is a fallback. Avoid a disruptive Express 5 migration. The existing body-parser path already has 6.16.0. +- `@simple-git/argv-parser`: the scoped 2.0.1 override is a partial mitigation only, with targeted no-execution tests. Preserve and document remaining simple-git alerts; details below. + +These recommendations were based on official npm metadata, published tarballs, source inspection, and small isolated API smoke tests. Local build, 41 JS tests and packaging pass on Node 24.18.0. CI covers PHP 7.4/8.3 and real WordPress 6.3/PHP 7.4 and latest/PHP 8.2 integration. + +## Critical simple-git findings: migration blocker + +Path: `@wordpress/env@11.17.0 -> simple-git@3.36.0 -> @simple-git/argv-parser@1.1.1`. + +**Do not directly override simple-git to v4.** v4 removes the callable CommonJS default export and requires `const { simpleGit } = require('simple-git')`. wp-env currently uses `const SimpleGit = require('simple-git')` and then calls it in both `lib/download-sources.js` and `lib/runtime/docker/download-wp-phpunit.js`. A direct v4 override would fail during Git source/PHPUnit downloads. [Official v4 breaking changes](https://github.com/steveukx/git-js/releases/tag/simple-git@4.0.0) + +The fully patched latest combination is simple-git **4.0.2**, which pins argv-parser **2.0.1**. Note that simple-git 4.0.1 pins parser 2.0.0, so it does not by itself clear the VISUAL finding. + +A scoped parser-only override to 2.0.1 is included as a **partial mitigation**, with regression tests of the CommonJS API and rejected unsafe inputs. The `vulnerabilityCheck(tokens, env)` signature is unchanged, and isolated simple-git 3.36.0 with parser 2.0.1 passed read-only `checkIsRepo('root')`, `raw('rev-parse', '--show-toplevel')`, and `status()` checks. Parser checks rejected VISUAL, trailer command configuration, and include.path. However, `--receive-p` still produced no finding in that parser-only combination, and version-based simple-git advisories remain. This is not a complete fix and has not been validated through all wp-env Docker/download flows. It is reasonable to include the scoped parser override with the focused regressions while explicitly retaining the residual alerts; a full fix still needs a reviewed wp-env migration. + +The examined wp-env call sites use clone/fetch/checkout/reset and fixed sparse-checkout commands; no commit, rebase, interpret-trailers, push, or explicit `.env()` calls were observed in these files. This reduces reachability of the reported flows for ordinary trusted wp-env use, but does not establish that the vulnerable dependency is harmless. Keep development configuration, Git arguments, environment values and source URLs trusted; do not run these tools on attacker-controlled configuration with privileged credentials. + +## Advisory matrix + +Ranges below are the audit's affected ranges and GitHub Advisory Database's patched versions. Registry availability was checked on the review date. + +| Package / baseline | Advisory | Affected range | First patched version | Decision | +|---|---|---|---|---| +| @simple-git/argv-parser 1.1.1 | [VISUAL editor bypass](https://github.com/advisories/GHSA-v5rq-49vh-5v5c) | <2.0.1 | 2.0.1 | Parser 2.0.1 removes this finding; simple-git mitigation remains incomplete overall | +| simple-git 3.36.0 | [Trailer command configuration](https://github.com/advisories/GHSA-x6jw-m9v5-85vh) | >=3.15.0 <4.0.1 | 4.0.1 | v4 is not drop-in for wp-env | +| simple-git 3.36.0 | [Git configuration includes](https://github.com/advisories/GHSA-g4wm-2vf7-vfgr) | <=3.36.0 | 4.0.0 | Same migration blocker | +| simple-git 3.36.0 | [Long-option abbreviation bypass](https://github.com/advisories/GHSA-858h-whjf-mvg5) | <=3.36.0 | 4.0.0 | Parser-only override does not fix this path | +| serialize-javascript 6.0.2 | [RegExp/Date code injection](https://github.com/advisories/GHSA-5c6j-r48x-rmvq) | <=7.0.2 | 7.0.3 | Scoped 7.0.5 clears both findings | +| serialize-javascript 6.0.2 | [Array-like object CPU exhaustion](https://github.com/advisories/GHSA-qj8w-gfj5-8c6v) | >=5.0.0 <7.0.5 | 7.0.5 | Scoped 7.0.5 | +| braces 3.0.3 | [Deep nesting stack exhaustion](https://github.com/advisories/GHSA-vfj7-8cjw-p6xm) | <=3.0.3 | None | Latest published version still affected; trusted build globs only | +| js-yaml 5.2.3 | [Empty merge source CPU exhaustion](https://github.com/advisories/GHSA-r3ph-w7gj-g6xm) | >=5.0.0 <=5.4.0 | 5.4.1 | Scoped 5.4.3 under markdownlint-cli | +| smol-toml 1.7.2 | [Quadratic key parsing](https://github.com/advisories/GHSA-r4xh-jqrq-34v2) | <=1.8.0 | 1.9.0 | Scoped 1.9.1 | +| sprintf-js 1.0.3 | [Unbounded precision DoS](https://github.com/advisories/GHSA-hp3w-g68c-fv3c) | <=1.1.3 | None | Latest published version still affected; wp-env parent migration needed | +| qs 6.15.3 | [Array-limit bypass](https://github.com/advisories/GHSA-x5fp-wj9c-mxmx) | >=6.14.2 <=6.15.3 | 6.16.0 | Express 4.22.3 / qs 6.16.0 | +| qs 6.15.3 | [Attacker-controlled isBuffer](https://github.com/advisories/GHSA-4mjr-xmp4-gh2g) | >=2.2.5 <6.16.0 | 6.16.0 | Scoped 6.16.0 | +| postcss-selector-parser 6.1.4 | [Flat selector CPU exhaustion](https://github.com/advisories/GHSA-rj75-hqrm-r3gf) | <7.1.6 | 7.1.6 | Requires v6 -> v7 range override or parent migration; defer pending CSS-specific regression tests | +| uuid 8.3.2 | [Missing output buffer checks](https://github.com/advisories/GHSA-w5hq-g745-h8pq) | <11.1.1 (installed line) | 11.1.1 | Cross-major candidate; sockjs only calls v4(), not the affected v3/v5/v6 APIs | +| katex 0.16.47 | [Prototype pollution trust bypass](https://github.com/advisories/GHSA-238p-pmpm-9mq7) | >=0.11.0 <0.18.2 | 0.18.2 | 0.x minor-range migration; defer pending markdown math regression validation | + +The KaTeX advisory range is from the fresh npm audit. Its GitHub advisory page could not be retrieved during this pass; registry 0.18.2 was downloaded and its rendering API smoke-tested. The fix boundary is inferred from the audit range rather than independently confirmed from that advisory page. + +## Paths behind remaining package records + +- braces: scripts -> fast-glob -> micromatch -> braces; also transitively affects copy-webpack-plugin, stylelint-family tooling, webpack-dev-server's chokidar and http-proxy-middleware paths. No patched braces release is available, despite some propagated `fixAvailable: true` flags in npm audit. +- postcss-selector-parser: scripts -> cssnano 6.1.2 -> cssnano-preset-default 6.1.2 -> postcss-calc 9.0.1, postcss-merge-rules 6.1.1, postcss-minify-selectors 6.0.4, postcss-unique-selectors 6.0.4, or postcss-merge-longhand 6.0.5 -> stylehacks 6.1.1. Each currently resolves a nested parser 6.1.4. The hoisted parser 7.1.6 is already patched. v7's notable breaking behavior is safe insertion during iteration; avoid a blind global replacement. The advisory explicitly excludes ordinary build-time parsing of trusted source CSS from exposed request-path scenarios. [v7 release](https://github.com/postcss/postcss-selector-parser/releases/tag/v7.0.0) +- sprintf-js: env -> js-yaml 3.15.2 -> argparse 1.0.10 -> sprintf-js 1.0.3. Updating sprintf-js to its latest 1.1.3 does not fix the advisory. Updating js-yaml globally breaks wp-env's safeLoad call. +- uuid: scripts -> webpack-dev-server 5.2.6 -> sockjs 0.3.24 -> uuid 8.3.2. Source inspection finds `require('uuid').v4` and `uuidv4()` only. A scoped uuid11.1.1 override retains CommonJS and passed v4()/validate() smoke testing, but it remains outside sockjs's supported ^8 range. Do not choose uuid12+ blindly because of later module-format changes. +- KaTeX: scripts -> markdownlint-cli 0.49.1 -> markdownlint 0.41.1 -> micromark-extension-math 3.1.0 -> katex 0.16.47. Minimum nonaffected release 0.18.2 exposes renderToString and passed a basic rendering smoke test, but is outside micromark's ^0.16 range. +- qs (recommended fix): env -> @wp-playground/cli 3.1.57 -> express 4.22.2 -> qs 6.15.3; shared Express is also used by webpack-dev-server. +- serialize-javascript (recommended fix): scripts -> copy-webpack-plugin 10.2.4 -> serialize-javascript 6.0.2. + +## Engine consistency + +The existing Playground/PHP-WASM 3.1.57 tree requires Node >=24.18.0 and npm >=11.16.0. `@wordpress/scripts@36.1.0` accepts Node `^22.22.2 || ^24.15.0 || >=26.0.0`, so the intersection is **`^24.18.0 || >=26.0.0`**, not plain >=24.18.0 (which would misleadingly include Node 25). Use npm >=11.16.0 and test the supported minimum in CI. The build and tests were rerun on Node 24.18.0 with npm 11.19.0. CI pins these versions. Node 26 is admitted by dependency engine declarations but has not been separately exercised here. + +## Verification checklist + +1. Regenerate the lockfile without force and inspect that only intended subtree changes occur. +2. Run `npm ci`, build, JS tests, PHP tests where supported, and release packaging. +3. Validate markdownlint YAML and TOML configuration loading after its minor-range overrides. +4. Run final `npm audit --json` and `npm audit --omit=dev --json`; describe residuals honestly, including the critical simple-git findings. +5. Track wp-env's simple-git v4 migration and braces/sprintf-js upstream releases. Do not suppress remaining advisories merely to make the report green. + +## Final audit snapshot + +After these changes, npm 11.19.0 reports **39 affected package records** +(1 critical, 20 high, 14 moderate, 4 low), representing **8 distinct advisories**, +versus 15 distinct advisories in the initial snapshot. Counts can change as the +registry advisory database changes; do not equate affected parents with unique flaws. +The remaining advisory packages are braces, KaTeX, postcss-selector-parser, +simple-git (three advisories), sprintf-js and uuid. No advisory is suppressed. + +`npm audit --omit=dev --json` reports zero findings for the root production lock. +This does not certify arbitrary bundled code or establish a complete security audit. +Do not run development servers or wp-env against untrusted configurations or +source URLs, or expose development services publicly. A full simple-git fix +needs a compatible wp-env migration; the parser override is not a complete fix. diff --git a/docs/player-bundle-review.md b/docs/player-bundle-review.md new file mode 100644 index 0000000..2b148f4 --- /dev/null +++ b/docs/player-bundle-review.md @@ -0,0 +1,62 @@ +# Prebuilt player dependency reachability review + +Reviewed 2026-10-14 for `asciinema-player@3.17.0`. This is a static review of +specific published bytes, not an independent rebuild or a full security audit. + +`scripts/vendor.mjs` copies the npm package's prebuilt browser bundle unchanged. +The root lockfile therefore does not describe all components used to build it. +The upstream dependency inventory is deliberately conservative: it includes +Seroval 1.5.0 through Solid 1.9.6, including server-only dependency paths. + +## Verified artifact + +The official npm package integrity is recorded in package-lock.json. + +- Minified bundle SHA-256: `a13c37632e1b5c49fe9128417b9319a9b5bc64cb457dd5ae52cbba8a3aceb880` +- Readable bundle SHA-256: `4d63cfb88859f158d1eef5d8a5550861abcb7ec195fb5d684f35f6446a29fe11` + +The minified hash also matches THIRD-PARTY-NOTICES.md and the installed package. + +## Import and artifact evidence + +1. [Player view.js](https://github.com/asciinema/asciinema-player/blob/v3.17.0/src/view.js) + imports `render` from `solid-js/web`. +2. Solid 1.9.6's package exports select `web/dist/web.js` for the browser/default + import. Its only external import is `solid-js`; the client `dist/solid.js` + has no imports. Neither imports Seroval. +3. Seroval is imported by the separate `web/dist/server.js` SSR renderer, + not the browser renderer. +4. The [Rollup configuration](https://github.com/asciinema/asciinema-player/blob/v3.17.0/rollup.config.mjs) + creates both readable and minified IIFEs from the same intermediate ESM bundle. + The inspected readable IIFE contains the client renderer and does not contain + Seroval deserialization implementations. +5. Both bundles lack `Seroval`, `fromJSON`, `fromCrossJSON`, `deserialize`, + `__SEROVAL_STREAM__`, and distinctive Seroval error/typed-array registry + signatures. Name searches alone are not proof; they corroborate the import trace. +6. Recording/live input paths use native `JSON.parse`/`response.json`, not + Seroval decoding. + +## Advisory-specific conclusion + +No reachable affected Seroval decoder was found in these browser bundle bytes: + +- [GHSA-mv8w-475r-vwqw](https://github.com/advisories/GHSA-mv8w-475r-vwqw): + affected <=1.5.2, fixed 1.5.3; requires `fromJSON` Promise-control deserialization. +- [GHSA-p6vx-979v-rg4c](https://github.com/advisories/GHSA-p6vx-979v-rg4c): + affected >=0.12.0, <=1.6.0, fixed 1.6.2; requires `fromJSON` with plugin-produced + callables and Promise assimilation. +- [GHSA-jp82-f5mq-hwhp](https://github.com/advisories/GHSA-jp82-f5mq-hwhp): + affected <=1.6.2, fixed 1.6.3; requires Seroval typed-array JSON deserialization. + +Seroval 1.5.0 is inside these version ranges, but the necessary decoder is absent +from this browser dependency path. Do not label the player vulnerable solely from +that inventory, or claim the entire plugin safe from this limited review. +Re-review after any player artifact or build-path change. + +## Reproduction + +Fetch official npm tarballs into separate directories using `npm pack --ignore-scripts` +for `asciinema-player@3.17.0`, `solid-js@1.9.6`, and `seroval@1.5.0`. +Verify both player hashes with `sha256sum`, inspect Solid's package exports and +client/server imports, and compare the readable bundle implementation against +those modules. Search both bundles for the decoder names/signatures above. diff --git a/languages/wp-asciiplayer.pot b/languages/wp-asciiplayer.pot index 531c279..ffd7cf1 100644 --- a/languages/wp-asciiplayer.pot +++ b/languages/wp-asciiplayer.pot @@ -357,4 +357,4 @@ msgstr "" #: block.json:1 msgctxt "block title" msgid "Asciicast Player" -msgstr "" \ No newline at end of file +msgstr "" diff --git a/package-lock.json b/package-lock.json index c3e2867..6d40a61 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,14 +12,15 @@ "asciinema-player": "3.17.0" }, "devDependencies": { - "@babel/parser": "7.29.9", + "@babel/parser": "8.0.7", "@playwright/test": "1.64.0", "@wordpress/env": "11.17.0", "@wordpress/scripts": "36.1.0", - "gettext-parser": "1.4.0" + "gettext-parser": "9.1.1" }, "engines": { - "node": ">=22.22.2" + "node": "^24.18.0 || >=26.0.0", + "npm": ">=11.16.0" } }, "node_modules/@babel/code-frame": { @@ -78,6 +79,22 @@ "url": "https://opencollective.com/babel" } }, + "node_modules/@babel/core/node_modules/@babel/parser": { + "version": "7.29.9", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.9.tgz", + "integrity": "sha512-CjXrNHTnvqBVqHgdBysY3vk2T8tpJHb5/RMeHJBTyVa9xgugCB0CJTx/3oO8RV2QRQP391RWpB7D6hLjm8V9uA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.29.8" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/@babel/generator": { "version": "7.29.8", "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.29.8.tgz", @@ -95,6 +112,22 @@ "node": ">=6.9.0" } }, + "node_modules/@babel/generator/node_modules/@babel/parser": { + "version": "7.29.9", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.9.tgz", + "integrity": "sha512-CjXrNHTnvqBVqHgdBysY3vk2T8tpJHb5/RMeHJBTyVa9xgugCB0CJTx/3oO8RV2QRQP391RWpB7D6hLjm8V9uA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.29.8" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/@babel/helper-annotate-as-pure": { "version": "7.29.7", "resolved": "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.29.7.tgz", @@ -371,19 +404,53 @@ } }, "node_modules/@babel/parser": { - "version": "7.29.9", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.9.tgz", - "integrity": "sha512-CjXrNHTnvqBVqHgdBysY3vk2T8tpJHb5/RMeHJBTyVa9xgugCB0CJTx/3oO8RV2QRQP391RWpB7D6hLjm8V9uA==", + "version": "8.0.7", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-8.0.7.tgz", + "integrity": "sha512-UkDwEbPO1px2JQSrdh4qIgaH1JgG7GO/pFeJkpxhDxIETkT/QvGpnigXIw75ViHYPtIgKITmVUJqLjiO+JuWjA==", "dev": true, "license": "MIT", "dependencies": { - "@babel/types": "^7.29.8" + "@babel/types": "^8.0.6" }, "bin": { "parser": "bin/babel-parser.js" }, "engines": { - "node": ">=6.0.0" + "node": "^22.18.0 || >=24.11.0" + } + }, + "node_modules/@babel/parser/node_modules/@babel/helper-string-parser": { + "version": "8.0.6", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-8.0.6.tgz", + "integrity": "sha512-+6HYEBnsDRZHJtUTAEfMQd0zMDqdFHS7C+5vAsEZqBUr3vEMWOWlHJ0Jz1gS8jJIlCvLsuA6ivmeoqzH936YcA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^22.18.0 || >=24.11.0" + } + }, + "node_modules/@babel/parser/node_modules/@babel/helper-validator-identifier": { + "version": "8.0.6", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-8.0.6.tgz", + "integrity": "sha512-HYx0YmuchRxRSpnjvcNffnPS8DCauKNmnumIuHG3jnQAVewRA7kfJGwF13ayEpSZs7s4R/oBH4eppuXcAQd5JQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^22.18.0 || >=24.11.0" + } + }, + "node_modules/@babel/parser/node_modules/@babel/types": { + "version": "8.0.6", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-8.0.6.tgz", + "integrity": "sha512-c+xgSWboV2pdwXP67BUWDVRHi2BO5Q3KwxyFVs7taVTY+fsK47/L51ZXQoV9rozHJDNHvJ4v4WEsI/IlxV2l2A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^8.0.6", + "@babel/helper-validator-identifier": "^8.0.6" + }, + "engines": { + "node": "^22.18.0 || >=24.11.0" } }, "node_modules/@babel/plugin-bugfix-firefox-class-in-computed-class-key": { @@ -1743,6 +1810,22 @@ "node": ">=6.9.0" } }, + "node_modules/@babel/template/node_modules/@babel/parser": { + "version": "7.29.9", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.9.tgz", + "integrity": "sha512-CjXrNHTnvqBVqHgdBysY3vk2T8tpJHb5/RMeHJBTyVa9xgugCB0CJTx/3oO8RV2QRQP391RWpB7D6hLjm8V9uA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.29.8" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/@babel/traverse": { "version": "7.29.10", "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.29.10.tgz", @@ -1762,6 +1845,22 @@ "node": ">=6.9.0" } }, + "node_modules/@babel/traverse/node_modules/@babel/parser": { + "version": "7.29.9", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.9.tgz", + "integrity": "sha512-CjXrNHTnvqBVqHgdBysY3vk2T8tpJHb5/RMeHJBTyVa9xgugCB0CJTx/3oO8RV2QRQP391RWpB7D6hLjm8V9uA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.29.8" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/@babel/types": { "version": "7.29.8", "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.8.tgz", @@ -5527,13 +5626,13 @@ "license": "MIT" }, "node_modules/@simple-git/argv-parser": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@simple-git/argv-parser/-/argv-parser-1.1.1.tgz", - "integrity": "sha512-Q9lBcfQ+VQCpQqGJFHe5yooOS5hGdLFFbJ5R+R5aDsnkPCahtn1hSkMcORX65J2Z5lxSkD0lQorMsncuBQxYUw==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@simple-git/argv-parser/-/argv-parser-2.0.1.tgz", + "integrity": "sha512-M++IaVWrN+vYalilOHfwvT2IL3wYZtVEBQpmX6DLSOJLtxbZ+SUeIDE3IiPogzhPACLajwtxfa5rp+ZX1FczzQ==", "dev": true, "license": "MIT", "dependencies": { - "@simple-git/args-pathspec": "^1.0.3" + "@simple-git/args-pathspec": "^1.0.4" } }, "node_modules/@sindresorhus/base62": { @@ -7402,6 +7501,17 @@ "node": ">=18.12.0" } }, + "node_modules/@wordpress/i18n/node_modules/gettext-parser": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/gettext-parser/-/gettext-parser-1.4.0.tgz", + "integrity": "sha512-sedZYLHlHeBop/gZ1jdg59hlUEcpcZJofLq2JFwJT1zTqAU3l2wFv6IsuwFHGqbiT9DWzMUW4/em2+hspnmMMA==", + "dev": true, + "license": "MIT", + "dependencies": { + "encoding": "^0.1.12", + "safe-buffer": "^5.1.1" + } + }, "node_modules/@wordpress/is-shallow-equal": { "version": "5.57.0", "resolved": "https://registry.npmjs.org/@wordpress/is-shallow-equal/-/is-shallow-equal-5.57.0.tgz", @@ -7897,6 +8007,22 @@ } } }, + "node_modules/@wordpress/theme/node_modules/@babel/parser": { + "version": "7.29.9", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.9.tgz", + "integrity": "sha512-CjXrNHTnvqBVqHgdBysY3vk2T8tpJHb5/RMeHJBTyVa9xgugCB0CJTx/3oO8RV2QRQP391RWpB7D6hLjm8V9uA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.29.8" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/@wordpress/undo-manager": { "version": "1.57.0", "resolved": "https://registry.npmjs.org/@wordpress/undo-manager/-/undo-manager-1.57.0.tgz", @@ -8909,23 +9035,6 @@ "dev": true, "license": "MIT" }, - "node_modules/body-parser/node_modules/qs": { - "version": "6.16.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.16.0.tgz", - "integrity": "sha512-h6fhOIaRrID2CbEY2fqs+7t+UXZo+MLAnU5gRIq85uFtdiUPCdsApMlHhXogKVM4HM2DVbIjGNTTYH2OcmP1vA==", - "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "es-define-property": "^1.0.1", - "side-channel": "^1.1.1" - }, - "engines": { - "node": ">=0.6" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/bonjour-service": { "version": "1.4.4", "resolved": "https://registry.npmjs.org/bonjour-service/-/bonjour-service-1.4.4.tgz", @@ -11852,6 +11961,22 @@ "eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0 || ^9.0.0 || ^10.0.0" } }, + "node_modules/eslint-plugin-react-hooks/node_modules/@babel/parser": { + "version": "7.29.9", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.9.tgz", + "integrity": "sha512-CjXrNHTnvqBVqHgdBysY3vk2T8tpJHb5/RMeHJBTyVa9xgugCB0CJTx/3oO8RV2QRQP391RWpB7D6hLjm8V9uA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.29.8" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/eslint-plugin-react/node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -12842,14 +12967,17 @@ } }, "node_modules/gettext-parser": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/gettext-parser/-/gettext-parser-1.4.0.tgz", - "integrity": "sha512-sedZYLHlHeBop/gZ1jdg59hlUEcpcZJofLq2JFwJT1zTqAU3l2wFv6IsuwFHGqbiT9DWzMUW4/em2+hspnmMMA==", + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/gettext-parser/-/gettext-parser-9.1.1.tgz", + "integrity": "sha512-ZLeqWPz9OMNrTgMuww0C22kkcNqis+e4059R94t7L7ERlZ2rUNpiDbaAUus+esBC6uBAQWbS9N+R5vJIJg//lw==", "dev": true, "license": "MIT", "dependencies": { - "encoding": "^0.1.12", - "safe-buffer": "^5.1.1" + "content-type": "^1.0.5", + "encoding": "^0.1.13" + }, + "engines": { + "node": ">=20" } }, "node_modules/glob": { @@ -15442,9 +15570,9 @@ "license": "Python-2.0" }, "node_modules/markdownlint-cli/node_modules/js-yaml": { - "version": "5.2.3", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-5.2.3.tgz", - "integrity": "sha512-n+mUVyUX5bVv7G/G2zyIHOhdxfuU1dY2NOFzTQUWiMUbFss8b57NFlgCCaggU78wSw5KVS9cllzeLyzyR+n5nw==", + "version": "5.4.3", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-5.4.3.tgz", + "integrity": "sha512-yzzNtgczwgoVHNigCyKTXcQJU4Y8t/ikU4UxXW0BvrLfHTGWZhsNcOT2s/a7vn81/4KqVnNmHjaUEPlvWnNwVw==", "dev": true, "funding": [ { @@ -18719,9 +18847,9 @@ "license": "MIT" }, "node_modules/qs": { - "version": "6.15.3", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.15.3.tgz", - "integrity": "sha512-O9gl3zCl5h5blw1KGUzQKhA5oUXSl8rwUIM5o0S3nCXMliSvy5Dzx7/DJcI+SwgICv+IneSZwhBh1oSyEHA71A==", + "version": "6.16.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.16.0.tgz", + "integrity": "sha512-h6fhOIaRrID2CbEY2fqs+7t+UXZo+MLAnU5gRIq85uFtdiUPCdsApMlHhXogKVM4HM2DVbIjGNTTYH2OcmP1vA==", "dev": true, "license": "BSD-3-Clause", "dependencies": { @@ -18769,16 +18897,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/randombytes": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", - "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "safe-buffer": "^5.1.0" - } - }, "node_modules/range-parser": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", @@ -19843,13 +19961,13 @@ } }, "node_modules/serialize-javascript": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz", - "integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-7.0.5.tgz", + "integrity": "sha512-F4LcB0UqUl1zErq+1nYEEzSHJnIwb3AF2XWB94b+afhrekOUijwooAYqFyRbjYkm2PAKBabx6oYv/xDxNi8IBw==", "dev": true, "license": "BSD-3-Clause", - "dependencies": { - "randombytes": "^2.1.0" + "engines": { + "node": ">=20.0.0" } }, "node_modules/seroval": { @@ -20293,9 +20411,9 @@ } }, "node_modules/smol-toml": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/smol-toml/-/smol-toml-1.7.2.tgz", - "integrity": "sha512-pXFZ9B2WinEPzxWkMmlYE/oYx2BP+qLrE95wP8tCuK901uLSMGdCb6QSr82z+wnhXkG4+cO+OMLbZB2Cn+97zw==", + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/smol-toml/-/smol-toml-1.9.1.tgz", + "integrity": "sha512-j7WyPdf0CJoutMzMoPLF/bVXHtKZIT9Rb4eGeEbWw8X2t5oirjPgpL+OpaENZrILYaXqYwnVH+qgUwVbl+pUJQ==", "dev": true, "license": "BSD-3-Clause", "engines": { diff --git a/package.json b/package.json index 31b91de..fbc9981 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "type": "module", "license": "GPL-3.0-only", "engines": { - "node": ">=22.22.2" + "node": "^24.18.0 || >=26.0.0", + "npm": ">=11.16.0" }, "scripts": { "build": "wp-scripts build --config webpack.config.cjs && node scripts/vendor.mjs && npm run i18n && node scripts/verify-build.mjs", @@ -26,8 +27,8 @@ "@playwright/test": "1.64.0", "@wordpress/env": "11.17.0", "@wordpress/scripts": "36.1.0", - "@babel/parser": "7.29.9", - "gettext-parser": "1.4.0" + "@babel/parser": "8.0.7", + "gettext-parser": "9.1.1" }, "cssnano": { "preset": [ @@ -38,5 +39,20 @@ } } ] + }, + "overrides": { + "copy-webpack-plugin": { + "serialize-javascript": "7.0.5" + }, + "markdownlint-cli": { + "js-yaml": "5.4.3", + "smol-toml": "1.9.1" + }, + "express": { + "qs": "6.16.0" + }, + "simple-git": { + "@simple-git/argv-parser": "2.0.1" + } } } diff --git a/scripts/i18n.mjs b/scripts/i18n.mjs index dc96218..be1fdde 100644 --- a/scripts/i18n.mjs +++ b/scripts/i18n.mjs @@ -51,7 +51,7 @@ const metadata = JSON.parse(fs.readFileSync('block.json')); for (const [field, context] of [['title', 'block title'], ['description', 'block description'], ['keywords', 'block keyword']]) { for (const value of [].concat(metadata[field])) add(value, context, 'block.json', 1); } -const headers = { 'project-id-version': `${domain} ${version}`, 'mime-version': '1.0', 'content-type': 'text/plain; charset=UTF-8', 'content-transfer-encoding': '8bit', 'x-domain': domain }; +const headers = { 'Project-Id-Version': `${domain} ${version}`, 'MIME-Version': '1.0', 'Content-Type': 'text/plain; charset=UTF-8', 'Content-Transfer-Encoding': '8bit', 'X-Domain': domain }; const pot = { charset: 'utf-8', headers, translations: { '': {} } }; for (const entry of [...entries.values()].sort((a, b) => `${a.msgctxt || ''}\u0004${a.msgid}`.localeCompare(`${b.msgctxt || ''}\u0004${b.msgid}`, 'en'))) { const context = entry.msgctxt || ''; @@ -61,8 +61,8 @@ fs.mkdirSync('languages', { recursive: true }); const output = new Map([['languages/wp-asciiplayer.pot', gettext.po.compile(pot)]]); if (!process.argv.includes('--pot-only')) { const po = gettext.po.parse(fs.readFileSync('languages/wp-asciiplayer-zh_CN.po')); - assert.equal(po.headers.language, 'zh_CN'); - assert.match(po.headers['plural-forms'], /^nplurals=1;\s*plural=0;$/); + assert.equal(po.headers.Language, 'zh_CN'); + assert.match(po.headers['Plural-Forms'], /^nplurals=1;\s*plural=0;$/); const messages = { '': { domain, lang: 'zh_CN', 'plural-forms': 'nplurals=1; plural=0;' } }; for (const entry of entries.values()) { const translation = po.translations[entry.msgctxt || '']?.[entry.msgid]; diff --git a/tests/js/i18n.test.js b/tests/js/i18n.test.js index cb093b4..a5b3861 100644 --- a/tests/js/i18n.test.js +++ b/tests/js/i18n.test.js @@ -27,8 +27,12 @@ test('all extracted strings and gettext contexts round-trip through MO and both }); test('catalogs use Chinese plural rules, exact locale, and standard WordPress textdomain', () => { - assert.equal(po.headers.language, 'zh_CN'); - assert.equal(mo.headers.language, 'zh_CN'); + assert.equal(po.headers.Language, 'zh_CN'); + assert.equal(mo.headers.Language, 'zh_CN'); + assert.equal(po.headers['Plural-Forms'], 'nplurals=1; plural=0;'); + assert.equal(mo.headers['Plural-Forms'], 'nplurals=1; plural=0;'); + assert.equal(pot.headers['Project-Id-Version'], `wp-asciiplayer ${JSON.parse(fs.readFileSync('package.json')).version}`); + assert.equal(pot.headers['Content-Type'], 'text/plain; charset=utf-8'); assert.equal(editor[''].lang, 'zh_CN'); assert.equal(editor[''].domain, 'wp-asciiplayer'); assert.equal(editor['']['plural-forms'], 'nplurals=1; plural=0;'); diff --git a/tests/js/toolchain.test.js b/tests/js/toolchain.test.js new file mode 100644 index 0000000..f01760d --- /dev/null +++ b/tests/js/toolchain.test.js @@ -0,0 +1,37 @@ +import test from 'node:test'; +import assert from 'node:assert/strict'; +import { createRequire } from 'node:module'; + +const require = createRequire(import.meta.url); +const SimpleGit = require('simple-git'); +const requireFromGit = createRequire(require.resolve('simple-git')); +const { vulnerabilityCheck } = requireFromGit('@simple-git/argv-parser'); + +test('wp-env CommonJS simple-git API remains callable with the scoped parser update', async () => { + assert.equal(typeof SimpleGit, 'function'); + const git = SimpleGit({ baseDir: process.cwd() }); + assert.equal(await git.checkIsRepo(), true); + assert.equal((await git.raw(['rev-parse', '--is-inside-work-tree'])).trim(), 'true'); +}); + +test('git argument parser rejects unsafe editor and configuration inputs without executing them', () => { + assert.deepEqual(vulnerabilityCheck(['status'], {}), []); + for (const [args, env, category] of [ + [['commit'], { VISUAL: 'untrusted-editor' }, 'allowUnsafeEditor'], + [['-c', 'trailer.test.cmd=untrusted-command', 'log'], {}, 'allowUnsafeCommandBinaries'], + [['-c', 'include.path=/untrusted/config', 'status'], {}, 'allowUnsafeInclude'], + ]) { + assert.ok(vulnerabilityCheck(args, env).some((finding) => finding.category === category)); + } +}); + +test('git argument parser accepts wp-env download command shapes', () => { + // Validate parser inputs only; these commands are never executed by this test. + for (const args of [ + ['clone', 'https://github.com/WordPress/wordpress-develop.git', '/tmp/wp-example', '--depth', '1', '--filter', 'blob:none', '--no-checkout'], + ['fetch', 'origin', 'trunk', '--depth', '1'], + ['checkout', 'trunk'], + ['reset', '--hard', 'FETCH_HEAD'], + ['sparse-checkout', 'set', '--cone', 'tests/phpunit'], + ]) assert.deepEqual(vulnerabilityCheck(args, {}), []); +});