From 33ff0e7da388bf6efdf284191b1af9d96f167b1a Mon Sep 17 00:00:00 2001 From: kai zhu Date: Sun, 23 Jun 2024 17:38:51 -0500 Subject: [PATCH] - coverage - Fix coverage-function v8CoverageReportCreate() throwing error EINVAL in latest nodejs-security-patch, when running win32-coverage with npm.cmd. --- .ci.sh | 2 +- .github/workflows/ci.yml | 10 ++--- .github/workflows/on_pull_request.yml | 14 +++---- .github/workflows/publish.yml | 1 - CHANGELOG.md | 3 ++ README.md | 56 +++++++++++++-------------- jslint.mjs | 37 ++++++++++++------ jslint_ci.sh | 37 +++++++++++------- package.json | 2 +- 9 files changed, 91 insertions(+), 71 deletions(-) diff --git a/.ci.sh b/.ci.sh index 366939825..11fdec961 100644 --- a/.ci.sh +++ b/.ci.sh @@ -441,7 +441,7 @@ import moduleFs from "fs"; "type": "git", "url": "https://github.com/jslint-org/jslint.git" }, - "version": "2024.3.26" + "version": "2024.6.1" }, undefined, 4) } ].map(async function ({ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 314bcb6df..00d16ba9d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,15 +22,14 @@ jobs: - x64 # - x86 node_version: - - 18 - 20 - # - 22 - python_version: - - "3.10" + - 22 os: - macos-latest - ubuntu-latest - windows-latest + python_version: + - "3.10" # base - .github/workflows/ci.yml - beg env: CI_MATRIX_NAME: > @@ -55,7 +54,7 @@ jobs: steps: # disable autocrlf in windows - run: | - sh -c uname + sh -c "uname -a" echo "$(date -u +"%Y-%m-%d %TZ") - ${{ env.CI_WORKFLOW_NAME }}" # " git config --global core.autocrlf false # https://github.com/actions/checkout @@ -70,7 +69,6 @@ jobs: # https://github.com/actions/setup-node - uses: actions/setup-node@v4 with: - architecture: ${{ matrix.architecture }} node-version: ${{ matrix.node_version }} # https://github.com/actions/setup-python - uses: actions/setup-python@v5 diff --git a/.github/workflows/on_pull_request.yml b/.github/workflows/on_pull_request.yml index d43fdd64c..d9feec7c7 100644 --- a/.github/workflows/on_pull_request.yml +++ b/.github/workflows/on_pull_request.yml @@ -14,9 +14,8 @@ jobs: - x64 # - x86 node_version: - - 18 - 20 - # - 22 + - 22 os: - macos-latest - ubuntu-latest @@ -43,20 +42,21 @@ jobs: ${{ matrix.os }} runs-on: ${{ matrix.os }} steps: - - run: echo "$(date -u +"%Y-%m-%d %TZ") - ${{ env.CI_WORKFLOW_NAME }}" # " # disable autocrlf in windows - - run: git config --global core.autocrlf false + - run: | + sh -c "uname -a" + echo "$(date -u +"%Y-%m-%d %TZ") - ${{ env.CI_WORKFLOW_NAME }}" # " + git config --global core.autocrlf false # https://github.com/actions/checkout - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # fetch jslint_ci.sh from trusted source - run: | git fetch origin alpha --depth=1 sh -c 'for FILE in .ci.sh .ci2.sh jslint_ci.sh myci2.sh; do if [ -f "$FILE" ]; then git checkout origin/alpha "$FILE"; fi; done' # https://github.com/actions/setup-node - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: - architecture: ${{ matrix.architecture }} node-version: ${{ matrix.node_version }} # run nodejs coverages and tests - run: sh jslint_ci.sh shCiBase diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 31995a89a..80cf34292 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -17,7 +17,6 @@ jobs: - x64 # - x86 node_version: - # - 18 - 20 # - 22 os: diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e2e77e70..bdbfbfc0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ - jslint - add new warning requiring paren around plus-separated concatenations. - jslint - try to improve parser to be able to parse jquery.js without stopping. +# v2024.6.1-beta +- coverage - Fix coverage-function v8CoverageReportCreate() throwing error EINVAL in latest nodejs-security-patch, when running win32-coverage with npm.cmd. + # v2024.3.26 - ci - Add shell-functions shGitPullrequestCleanup(), shGitPullrequest() to automatically cleanup or create-and-push github-pull-commit to origin/alpha. - jslint - Allow destructuring-assignment after function-definition. diff --git a/README.md b/README.md index 7125ffe5d..83f07a771 100644 --- a/README.md +++ b/README.md @@ -917,13 +917,13 @@ eval("1"); //jslint-ignore-line

### pull-request merge - find highest issue-number at https://github.com/jslint-org/jslint/issues/, https://github.com/jslint-org/jslint/pulls/, and add +1 to it for PR-xxx -- $ `shGitPullrequest beta beta` +- `shGitPullrequest beta beta` - verify ci-success for origin-branch-alpha - - https://github.com/kaizhu256/jslint/actions/workflows/ci.yml -- $ `git push upstream alpha -f` + - https://github.com/kaizhu256/jslint/actions +- `git push upstream alpha -f` - verify ci-success for upstream-branch-alpha - - https://github.com/jslint-org/jslint/actions/workflows/ci.yml -- goto https://github.com/jslint-org/jslint/compare/beta...kaizhu256:jslint:branch-p2024.3.21 + - https://github.com/jslint-org/jslint/actions +- goto https://github.com/jslint-org/jslint/compare/beta...kaizhu256:jslint:branch-p2024.6.23 - click `Create pull request` - input `Add your description here...` with: ``` @@ -945,24 +945,24 @@ this PR will additionally: - wait awhile before continuing ... - click `Rebase and merge` - verify ci-success for upstream-branch-beta - - https://github.com/jslint-org/jslint/actions/workflows/ci.yml -- $ `shGitPullrequestCleanup` + - https://github.com/jslint-org/jslint/actions +- `shGitPullrequestCleanup` - verify ci-success for origin-branch-alpha - - https://github.com/kaizhu256/jslint/actions/workflows/ci.yml -- $ `git push upstream alpha -f` + - https://github.com/kaizhu256/jslint/actions +- `git push upstream alpha -f` - verify ci-success for upstream-branch-alpha - - https://github.com/jslint-org/jslint/actions/workflows/ci.yml + - https://github.com/jslint-org/jslint/actions - click `Delete branch`

### branch-master commit -- $ `shGitPullrequest master beta` +- `shGitPullrequest master beta` - verify ci-success for origin-branch-alpha - - https://github.com/kaizhu256/jslint/actions/workflows/ci.yml -- $ `git push upstream alpha -f` + - https://github.com/kaizhu256/jslint/actions +- `git push upstream alpha -f` - verify ci-success for upstream-branch-alpha - - https://github.com/jslint-org/jslint/actions/workflows/ci.yml + - https://github.com/jslint-org/jslint/actions - goto https://github.com/jslint-org/jslint/compare/beta...kaizhu256:jslint:branch-v2024.3.26 - click `Create pull request` - input `Add a title` with: `# v20yy.mm.dd` @@ -978,27 +978,27 @@ this PR will additionally: - wait awhile before continuing ... - click `Rebase and merge` - verify ci-success for upstream-branch-beta - - https://github.com/jslint-org/jslint/actions/workflows/ci.yml -- $ `shGitPullrequestCleanup` + - https://github.com/jslint-org/jslint/actions +- `shGitPullrequestCleanup` - verify ci-success for origin-branch-alpha - - https://github.com/kaizhu256/jslint/actions/workflows/ci.yml -- $ `git push upstream alpha -f` + - https://github.com/kaizhu256/jslint/actions +- `git push upstream alpha -f` - verify ci-success for upstream-branch-alpha - - https://github.com/jslint-org/jslint/actions/workflows/ci.yml + - https://github.com/jslint-org/jslint/actions - click `Delete branch` -- $ `git push origin beta:master` +- `git push origin beta:master` - verify ci-success for origin-branch-master - - https://github.com/kaizhu256/jslint/actions/workflows/ci.yml -- $ `git push upstream beta:master` + - https://github.com/kaizhu256/jslint/actions +- `git push upstream beta:master` - verify ci-success for upstream-branch-master - - https://github.com/jslint-org/jslint/actions/workflows/ci.yml + - https://github.com/jslint-org/jslint/actions

### branch-master publish -- $ `git push upstream beta:master` +- `git push upstream beta:master` - verify ci-success for upstream-branch-master - - https://github.com/jslint-org/jslint/actions/workflows/ci.yml + - https://github.com/jslint-org/jslint/actions - goto https://github.com/jslint-org/jslint/releases/new - input `Choose a tag` with: `v20yy.mm.dd` - click `Create new tag: v20yy.mm.dd on publish` @@ -1016,7 +1016,7 @@ this PR will additionally: - click `Preview` and review - click `Publish release` - verify ci-success for upstream-branch-publish - - https://github.com/jslint-org/jslint/actions/workflows/ci.yml + - https://github.com/jslint-org/jslint/actions - verify email-notification `Successfully published @jslint-org/jslint@20yy.mm.dd` @@ -1024,10 +1024,10 @@ this PR will additionally: ### vscode-jslint publish - goto https://github.com/jslint-org/jslint/tree/gh-pages/branch-beta/.artifact/jslint_wrapper_vscode - click `vscode-jslint-20yy.mm.dd.vsix` -- click `Download` +- click `Raw` to download - goto https://marketplace.visualstudio.com/manage/publishers/jslint - right-click `Update` -- drag-and-drop downloaded `vscode-jslint-20yy.mm.dd.vsix` +- upload downloaded file `vscode-jslint-20yy.mm.dd.vsix` - click 'Upload' - verify email-notification `[Succeeded] Extension publish on Visual Studio Marketplace - vscode-jslint` diff --git a/jslint.mjs b/jslint.mjs index b8dd1d950..1cc3d1796 100644 --- a/jslint.mjs +++ b/jslint.mjs @@ -125,8 +125,8 @@ process_env, process_exit, promises, property, property_dict, push, quote, ranges, readFile, readdir, readonly, recursive, reduce, repeat, replace, resolve, result, reverse, role, round, scriptId, search, set, shebang, - shift, signature, single, slice, some, sort, source, spawn, splice, split, - stack, stack_trace, start, startOffset, startsWith, statement, + shell, shift, signature, single, slice, some, sort, source, spawn, splice, + split, stack, stack_trace, start, startOffset, startsWith, statement, statement_prv, stdio, stop, stop_at, stringify, subscript, switch, syntax_dict, tenure, test, test_cause, test_internal_error, this, thru, toLocaleString, toString, token, token_global, token_list, token_nxt, @@ -163,7 +163,7 @@ let jslint_charset_ascii = ( + "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_" + "`abcdefghijklmnopqrstuvwxyz{|}~\u007f" ); -let jslint_edition = "v2024.3.26"; +let jslint_edition = "v2024.6.1-beta"; let jslint_export; // The jslint object to be exported. let jslint_fudge = 1; // Fudge starting line and starting // ... column to 1. @@ -11285,24 +11285,37 @@ function sentinel() {} } })); exitCode = await new Promise(function (resolve) { - moduleChildProcess.spawn( - ( - processArgv[0] === "npm" + let processArgv0 = processArgv[0]; // If win32 environment, then replace program npm with npm.cmd. // Coverage-hack - Ugly-hack to get test-coverage under both win32 and linux. - ? process.platform.replace("win32", "npm.cmd").replace( - process.platform, - "npm" - ) - : processArgv[0] - ), + if (processArgv0 === "npm") { + processArgv0 = process.platform.replace( + "win32", + "npm.cmd" + ).replace( + process.platform, + "npm" + ); + } + moduleChildProcess.spawn( + processArgv0, processArgv.slice(1), { env: Object.assign({}, process.env, { NODE_V8_COVERAGE: coverageDir }), + +// PR-465 +// https://nodejs.org/en/blog/vulnerability/april-2024-security-releases-2 +// Node.js will now error with EINVAL if a .bat or .cmd file is passed to +// child_process.spawn and child_process.spawnSync without the shell option set. + + shell: ( + processArgv0.endsWith(".bat") + || processArgv0.endsWith(".cmd") + ), stdio: ["ignore", 1, 2] } ).on("exit", resolve); diff --git a/jslint_ci.sh b/jslint_ci.sh index 6bef270fb..2f5490808 100644 --- a/jslint_ci.sh +++ b/jslint_ci.sh @@ -922,7 +922,7 @@ shGitInitBase() {(set -e shGitLsTree() {(set -e # this function will "git ls-tree" all files committed in HEAD -# example use: +# example usage: # shGitLsTree | sort -rk3 # sort by date # shGitLsTree | sort -rk4 # sort by size node --input-type=module --eval ' @@ -1062,7 +1062,7 @@ import moduleFs from "fs"; default: version = `p${version}`; commitMessage = ( - /\n\n# v\d\d\d\d\.\d\d?\.\d\d?(?:-.*?)?\n(- [\S\s]+?)\n- / + /\n\n# v\d\d\d\d\.\d\d?\.\d\d?(?:-.*?)?\n(- [\S\s]+?)(?:\n- |\n\n)/ ).exec(data)[1]; } branchPull = `branch-${version}`; @@ -1171,7 +1171,7 @@ shGithubCheckoutRemote() {(set -e shGithubFileDownload() {(set -e # this function will download file $1 from github repo/branch # https://docs.github.com/en/rest/reference/repos#create-or-update-file-contents -# example use: +# example usage: # shGithubFileDownload octocat/hello-world/master/hello.txt shGithubFileDownloadUpload download "$1" "$2" )} @@ -1179,7 +1179,7 @@ shGithubFileDownload() {(set -e shGithubFileDownloadUpload() {(set -e # this function will upload file $2 to github repo/branch $1 # https://docs.github.com/en/rest/reference/repos#create-or-update-file-contents -# example use: +# example usage: # shGithubFileUpload octocat/hello-world/master/hello.txt hello.txt shGithubTokenExport node --input-type=module --eval ' @@ -1272,7 +1272,7 @@ import modulePath from "path"; shGithubFileUpload() {(set -e # this function will upload file $2 to github repo/branch $1 # https://docs.github.com/en/rest/reference/repos#create-or-update-file-contents -# example use: +# example usage: # shGithubFileUpload octocat/hello-world/master/hello.txt hello.txt shGithubFileDownloadUpload upload "$1" "$2" )} @@ -1287,7 +1287,7 @@ shGithubTokenExport() { shGithubWorkflowDispatch() {(set -e # this function will trigger github-workflow on given $REPO and $BRANCH -# example use: +# example usage: # shGithubWorkflowDispatch octocat/hello-world master shGithubTokenExport REPO="$1" @@ -2068,7 +2068,7 @@ function replaceListReplace(replaceList, data) { if (dataUriType) { return; } - if (dateCommitted) { + if (dateCommitted && dateCommitted.toString()) { result += ( "\n\n\n/*\n" + "repo " + prefix.replace("/blob/", "/tree/") + "\n" @@ -3329,20 +3329,27 @@ function sentinel() {} } })); exitCode = await new Promise(function (resolve) { + let processArgv0 = processArgv[0]; + if (processArgv0 === "npm") { + processArgv0 = process.platform.replace( + "win32", + "npm.cmd" + ).replace( + process.platform, + "npm" + ); + } moduleChildProcess.spawn( - ( - processArgv[0] === "npm" - ? process.platform.replace("win32", "npm.cmd").replace( - process.platform, - "npm" - ) - : processArgv[0] - ), + processArgv0, processArgv.slice(1), { env: Object.assign({}, process.env, { NODE_V8_COVERAGE: coverageDir }), + shell: ( + processArgv0.endsWith(".bat") + || processArgv0.endsWith(".cmd") + ), stdio: ["ignore", 1, 2] } ).on("exit", resolve); diff --git a/package.json b/package.json index 27dc431ea..a1aed18f5 100644 --- a/package.json +++ b/package.json @@ -35,5 +35,5 @@ "shCiArtifactUpload": 1, "shCiPublishNpm": 1, "type": "module", - "version": "2024.3.26" + "version": "2024.6.1-beta" }