From 457483431818c34b0e216440869d2535bf012820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Iv=C3=A1n=20Vieitez=20Parra?= <3857362+corrideat@users.noreply.github.com> Date: Sat, 29 Jun 2024 15:43:07 +0000 Subject: [PATCH] Remove reliance on globalThis for Worker Other changes: * Update dependencies * Actions: Update Java from 11 to 21 * Node.js: Add globals required by new Undici --- .github/workflows/npm-publish.yml | 2 +- .github/workflows/pull-request.yml | 26 +-- package-lock.json | 191 +++++++++++------- package.json | 18 +- .../impl/nodejs/nodejsSandboxVm.inline.ts | 121 +++++++---- .../impl/worker/workerSandboxInit.inline.ts | 5 +- .../impl/worker/workerSandboxInner.ts | 25 +-- .../impl/worker/workerSandboxManager.ts | 7 +- src/untrusted/lib/errorModem.ts | 9 +- 9 files changed, 244 insertions(+), 160 deletions(-) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 7e775e6..d7a5247 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -20,7 +20,7 @@ jobs: - uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 with: distribution: 'temurin' - java-version: '11' + java-version: '21' - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 with: node-version: '20' diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 1b7c604..6cc421b 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -11,7 +11,7 @@ on: jobs: run-tests-macos-18: - name: 'macOS (Node 18, Deno 1.36, Java 11)' + name: 'macOS (Node 18, Deno 1.36, Java 21)' runs-on: macos-latest steps: - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 @@ -21,7 +21,7 @@ jobs: - uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 with: distribution: 'microsoft' - java-version: '11' + java-version: '21' - uses: denoland/setup-deno@041b854f97b325bd60e53e9dc2de9cb9f9ac0cba with: deno-version: '~1.36' @@ -33,7 +33,7 @@ jobs: DENO_NO_PACKAGE_JSON: 1 run-tests-windows-18: - name: 'Windows (Node 18, Deno 1.36, Java 11)' + name: 'Windows (Node 18, Deno 1.36, Java 21)' runs-on: windows-latest steps: - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 @@ -43,7 +43,7 @@ jobs: - uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 with: distribution: 'semeru' - java-version: '11' + java-version: '21' - uses: denoland/setup-deno@041b854f97b325bd60e53e9dc2de9cb9f9ac0cba with: deno-version: '~1.36' @@ -55,7 +55,7 @@ jobs: DENO_NO_PACKAGE_JSON: 1 run-tests-ubuntu-18: - name: 'Ubuntu (Node 18, Deno 1.36, Java 11)' + name: 'Ubuntu (Node 18, Deno 1.36, Java 21)' runs-on: ubuntu-latest steps: - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 @@ -64,8 +64,8 @@ jobs: node-version: '18' - uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 with: - distribution: 'dragonwell' - java-version: '11' + distribution: 'oracle' + java-version: '21' - uses: denoland/setup-deno@041b854f97b325bd60e53e9dc2de9cb9f9ac0cba with: deno-version: '~1.36' @@ -77,7 +77,7 @@ jobs: DENO_NO_PACKAGE_JSON: 1 run-tests-ubuntu-20: - name: 'Ubuntu (Node 20, Deno 1.40, Java 11)' + name: 'Ubuntu (Node 20, Deno 1.40, Java 21)' runs-on: ubuntu-latest steps: - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 @@ -86,8 +86,8 @@ jobs: node-version: '20' - uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 with: - distribution: 'dragonwell' - java-version: '11' + distribution: 'corretto' + java-version: '21' - uses: denoland/setup-deno@041b854f97b325bd60e53e9dc2de9cb9f9ac0cba with: deno-version: '~1.40' @@ -99,7 +99,7 @@ jobs: DENO_NO_PACKAGE_JSON: 1 run-tests-ubuntu-22: - name: 'Ubuntu (Node 22, Deno 1.44, Java 11)' + name: 'Ubuntu (Node 22, Deno 1.44, Java 21)' runs-on: ubuntu-latest steps: - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 @@ -108,8 +108,8 @@ jobs: node-version: '22' - uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 with: - distribution: 'dragonwell' - java-version: '11' + distribution: 'zulu' + java-version: '21' - uses: denoland/setup-deno@041b854f97b325bd60e53e9dc2de9cb9f9ac0cba with: deno-version: '~1.44' diff --git a/package-lock.json b/package-lock.json index f59fdb7..df6b46a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,30 +1,30 @@ { "name": "@exact-realty/lot", - "version": "0.0.26", + "version": "0.0.27", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@exact-realty/lot", - "version": "0.0.26", + "version": "0.0.27", "license": "ISC", "devDependencies": { - "@exact-realty/esbuild-plugin-closure-compiler": "^1.0.4", + "@exact-realty/esbuild-plugin-closure-compiler": "^1.0.5", "@exact-realty/esbuild-plugin-inline-js": "^1.1.7", - "@types/selenium-webdriver": "^4.1.23", - "@typescript-eslint/eslint-plugin": "^7.13.0", - "@typescript-eslint/parser": "^7.13.0", + "@types/selenium-webdriver": "^4.1.24", + "@typescript-eslint/eslint-plugin": "^7.14.1", + "@typescript-eslint/parser": "^7.14.1", "esbuild": "^0.21.5", "eslint": "^8.56.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.1.3", - "glob": "^10.4.1", + "glob": "^10.4.2", "google-closure-compiler": "^20240317.0.0", "prettier": "^3.3.2", - "selenium-webdriver": "^4.21.0", + "selenium-webdriver": "^4.22.0", "ts-node": "^10.9.2", - "ts-patch": "^3.2.0", - "typescript": "^5.4.5", + "ts-patch": "^3.2.1", + "typescript": "^5.5.2", "typescript-transform-paths": "^3.4.7" }, "engines": { @@ -478,10 +478,11 @@ } }, "node_modules/@exact-realty/esbuild-plugin-closure-compiler": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@exact-realty/esbuild-plugin-closure-compiler/-/esbuild-plugin-closure-compiler-1.0.4.tgz", - "integrity": "sha512-/bmE6MqMRAVa1KBvM1RXl/v4P+G4A2cUKmlAj0KvtRO2TDjEjaabbH6KbmC2sX43OC032g9KhLbz9PKGA7w4lg==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@exact-realty/esbuild-plugin-closure-compiler/-/esbuild-plugin-closure-compiler-1.0.5.tgz", + "integrity": "sha512-5OPvF3oQhYqD8qfjyBXeMshqeRK8Q9UMs1MYURv+BEBmaZ68ac1SutGzplMxDOHLcxUL3bSM3gtwGwRRsBUxGQ==", "dev": true, + "license": "Apache-2.0 WITH LLVM-exception", "peerDependencies": { "esbuild": "^0.17.0 || ^0.18.0 || ^0.19.0 || ^0.20.0 || ^0.21.0", "google-closure-compiler": "*" @@ -686,10 +687,11 @@ "dev": true }, "node_modules/@types/selenium-webdriver": { - "version": "4.1.23", - "resolved": "https://registry.npmjs.org/@types/selenium-webdriver/-/selenium-webdriver-4.1.23.tgz", - "integrity": "sha512-PgreEfCfafYLyTwvJTZvOspCq3JABnS51e+NSFFL5yoiMO7h04lWgLfr10NA7nl/yZbz4m76rBfOOdDfleb7pQ==", + "version": "4.1.24", + "resolved": "https://registry.npmjs.org/@types/selenium-webdriver/-/selenium-webdriver-4.1.24.tgz", + "integrity": "sha512-oR5MVATv+P2dmhceZJPDm99MmOC9yAK8YpIgJbHEFQ/MbSPC1lA6Ohw441WNUcQ6B1fMAOMu0u59fRKKj9AGGg==", "dev": true, + "license": "MIT", "dependencies": { "@types/node": "*", "@types/ws": "*" @@ -705,16 +707,17 @@ } }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "7.13.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.13.0.tgz", - "integrity": "sha512-FX1X6AF0w8MdVFLSdqwqN/me2hyhuQg4ykN6ZpVhh1ij/80pTvDKclX1sZB9iqex8SjQfVhwMKs3JtnnMLzG9w==", + "version": "7.14.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.14.1.tgz", + "integrity": "sha512-aAJd6bIf2vvQRjUG3ZkNXkmBpN+J7Wd0mfQiiVCJMu9Z5GcZZdcc0j8XwN/BM97Fl7e3SkTXODSk4VehUv7CGw==", "dev": true, + "license": "MIT", "dependencies": { "@eslint-community/regexpp": "^4.10.0", - "@typescript-eslint/scope-manager": "7.13.0", - "@typescript-eslint/type-utils": "7.13.0", - "@typescript-eslint/utils": "7.13.0", - "@typescript-eslint/visitor-keys": "7.13.0", + "@typescript-eslint/scope-manager": "7.14.1", + "@typescript-eslint/type-utils": "7.14.1", + "@typescript-eslint/utils": "7.14.1", + "@typescript-eslint/visitor-keys": "7.14.1", "graphemer": "^1.4.0", "ignore": "^5.3.1", "natural-compare": "^1.4.0", @@ -738,15 +741,16 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "7.13.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.13.0.tgz", - "integrity": "sha512-EjMfl69KOS9awXXe83iRN7oIEXy9yYdqWfqdrFAYAAr6syP8eLEFI7ZE4939antx2mNgPRW/o1ybm2SFYkbTVA==", + "version": "7.14.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.14.1.tgz", + "integrity": "sha512-8lKUOebNLcR0D7RvlcloOacTOWzOqemWEWkKSVpMZVF/XVcwjPR+3MD08QzbW9TCGJ+DwIc6zUSGZ9vd8cO1IA==", "dev": true, + "license": "BSD-2-Clause", "dependencies": { - "@typescript-eslint/scope-manager": "7.13.0", - "@typescript-eslint/types": "7.13.0", - "@typescript-eslint/typescript-estree": "7.13.0", - "@typescript-eslint/visitor-keys": "7.13.0", + "@typescript-eslint/scope-manager": "7.14.1", + "@typescript-eslint/types": "7.14.1", + "@typescript-eslint/typescript-estree": "7.14.1", + "@typescript-eslint/visitor-keys": "7.14.1", "debug": "^4.3.4" }, "engines": { @@ -766,13 +770,14 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "7.13.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.13.0.tgz", - "integrity": "sha512-ZrMCe1R6a01T94ilV13egvcnvVJ1pxShkE0+NDjDzH4nvG1wXpwsVI5bZCvE7AEDH1mXEx5tJSVR68bLgG7Dng==", + "version": "7.14.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.14.1.tgz", + "integrity": "sha512-gPrFSsoYcsffYXTOZ+hT7fyJr95rdVe4kGVX1ps/dJ+DfmlnjFN/GcMxXcVkeHDKqsq6uAcVaQaIi3cFffmAbA==", "dev": true, + "license": "MIT", "dependencies": { - "@typescript-eslint/types": "7.13.0", - "@typescript-eslint/visitor-keys": "7.13.0" + "@typescript-eslint/types": "7.14.1", + "@typescript-eslint/visitor-keys": "7.14.1" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -783,13 +788,14 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "7.13.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.13.0.tgz", - "integrity": "sha512-xMEtMzxq9eRkZy48XuxlBFzpVMDurUAfDu5Rz16GouAtXm0TaAoTFzqWUFPPuQYXI/CDaH/Bgx/fk/84t/Bc9A==", + "version": "7.14.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.14.1.tgz", + "integrity": "sha512-/MzmgNd3nnbDbOi3LfasXWWe292+iuo+umJ0bCCMCPc1jLO/z2BQmWUUUXvXLbrQey/JgzdF/OV+I5bzEGwJkQ==", "dev": true, + "license": "MIT", "dependencies": { - "@typescript-eslint/typescript-estree": "7.13.0", - "@typescript-eslint/utils": "7.13.0", + "@typescript-eslint/typescript-estree": "7.14.1", + "@typescript-eslint/utils": "7.14.1", "debug": "^4.3.4", "ts-api-utils": "^1.3.0" }, @@ -810,10 +816,11 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "7.13.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.13.0.tgz", - "integrity": "sha512-QWuwm9wcGMAuTsxP+qz6LBBd3Uq8I5Nv8xb0mk54jmNoCyDspnMvVsOxI6IsMmway5d1S9Su2+sCKv1st2l6eA==", + "version": "7.14.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.14.1.tgz", + "integrity": "sha512-mL7zNEOQybo5R3AavY+Am7KLv8BorIv7HCYS5rKoNZKQD9tsfGUpO4KdAn3sSUvTiS4PQkr2+K0KJbxj8H9NDg==", "dev": true, + "license": "MIT", "engines": { "node": "^18.18.0 || >=20.0.0" }, @@ -823,13 +830,14 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "7.13.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.13.0.tgz", - "integrity": "sha512-cAvBvUoobaoIcoqox1YatXOnSl3gx92rCZoMRPzMNisDiM12siGilSM4+dJAekuuHTibI2hVC2fYK79iSFvWjw==", + "version": "7.14.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.14.1.tgz", + "integrity": "sha512-k5d0VuxViE2ulIO6FbxxSZaxqDVUyMbXcidC8rHvii0I56XZPv8cq+EhMns+d/EVIL41sMXqRbK3D10Oza1bbA==", "dev": true, + "license": "BSD-2-Clause", "dependencies": { - "@typescript-eslint/types": "7.13.0", - "@typescript-eslint/visitor-keys": "7.13.0", + "@typescript-eslint/types": "7.14.1", + "@typescript-eslint/visitor-keys": "7.14.1", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -855,15 +863,17 @@ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", "dev": true, + "license": "MIT", "dependencies": { "balanced-match": "^1.0.0" } }, "node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": { - "version": "9.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.4.tgz", - "integrity": "sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==", + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", "dev": true, + "license": "ISC", "dependencies": { "brace-expansion": "^2.0.1" }, @@ -875,15 +885,16 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "7.13.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.13.0.tgz", - "integrity": "sha512-jceD8RgdKORVnB4Y6BqasfIkFhl4pajB1wVxrF4akxD2QPM8GNYjgGwEzYS+437ewlqqrg7Dw+6dhdpjMpeBFQ==", + "version": "7.14.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.14.1.tgz", + "integrity": "sha512-CMmVVELns3nak3cpJhZosDkm63n+DwBlDX8g0k4QUa9BMnF+lH2lr3d130M1Zt1xxmB3LLk3NV7KQCq86ZBBhQ==", "dev": true, + "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", - "@typescript-eslint/scope-manager": "7.13.0", - "@typescript-eslint/types": "7.13.0", - "@typescript-eslint/typescript-estree": "7.13.0" + "@typescript-eslint/scope-manager": "7.14.1", + "@typescript-eslint/types": "7.14.1", + "@typescript-eslint/typescript-estree": "7.14.1" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -897,12 +908,13 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "7.13.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.13.0.tgz", - "integrity": "sha512-nxn+dozQx+MK61nn/JP+M4eCkHDSxSLDpgE3WcQo0+fkjEolnaB5jswvIKC4K56By8MMgIho7f1PVxERHEo8rw==", + "version": "7.14.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.14.1.tgz", + "integrity": "sha512-Crb+F75U1JAEtBeQGxSKwI60hZmmzaqA3z9sYsVm8X7W5cwLEm5bRe0/uXS6+MR/y8CVpKSR/ontIAIEPFcEkA==", "dev": true, + "license": "MIT", "dependencies": { - "@typescript-eslint/types": "7.13.0", + "@typescript-eslint/types": "7.14.1", "eslint-visitor-keys": "^3.4.3" }, "engines": { @@ -1006,6 +1018,7 @@ "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } @@ -1031,6 +1044,7 @@ "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dev": true, + "license": "MIT", "dependencies": { "fill-range": "^7.1.1" }, @@ -1176,6 +1190,7 @@ "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", "dev": true, + "license": "MIT", "dependencies": { "path-type": "^4.0.0" }, @@ -1458,6 +1473,7 @@ "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", "dev": true, + "license": "MIT", "dependencies": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", @@ -1474,6 +1490,7 @@ "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", "dev": true, + "license": "ISC", "dependencies": { "is-glob": "^4.0.1" }, @@ -1519,6 +1536,7 @@ "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dev": true, + "license": "MIT", "dependencies": { "to-regex-range": "^5.0.1" }, @@ -1575,15 +1593,17 @@ "dev": true }, "node_modules/glob": { - "version": "10.4.1", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.1.tgz", - "integrity": "sha512-2jelhlq3E4ho74ZyVLN03oKdAZVUa6UDZzFLVH1H7dnoax+y9qyaq8zBkfDIggjniU19z0wU18y16jMB2eyVIw==", + "version": "10.4.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.2.tgz", + "integrity": "sha512-GwMlUF6PkPo3Gk21UxkCohOv0PLcIXVtKyLlpEI28R/cO/4eNOdmLk3CMW1wROV/WR/EsZOWAfBbBOqYvs88/w==", "dev": true, + "license": "ISC", "dependencies": { "foreground-child": "^3.1.0", "jackspeak": "^3.1.2", "minimatch": "^9.0.4", "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", "path-scurry": "^1.11.1" }, "bin": { @@ -1706,6 +1726,7 @@ "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", "dev": true, + "license": "MIT", "dependencies": { "array-union": "^2.1.0", "dir-glob": "^3.0.1", @@ -1931,6 +1952,7 @@ "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", "dev": true, + "license": "MIT", "engines": { "node": ">=0.12.0" } @@ -2097,6 +2119,7 @@ "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", "dev": true, + "license": "MIT", "engines": { "node": ">= 8" } @@ -2106,6 +2129,7 @@ "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.7.tgz", "integrity": "sha512-LPP/3KorzCwBxfeUuZmaR6bG2kdeHSbe0P2tY3FLRU4vYrjYz5hI4QZwV0njUx3jeuKe67YukQ1LSPZBKDqO/Q==", "dev": true, + "license": "MIT", "dependencies": { "braces": "^3.0.3", "picomatch": "^2.3.1" @@ -2212,6 +2236,13 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/package-json-from-dist": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.0.tgz", + "integrity": "sha512-dATvCeZN/8wQsGywez1mzHtTlP22H8OEfPrVMLNr4/eGa+ijtLn/6M5f0dY8UKNrC2O9UCU6SSoG3qRKnt7STw==", + "dev": true, + "license": "BlueOak-1.0.0" + }, "node_modules/pako": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz", @@ -2284,6 +2315,7 @@ "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } @@ -2293,6 +2325,7 @@ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", "dev": true, + "license": "MIT", "engines": { "node": ">=8.6" }, @@ -2504,10 +2537,11 @@ "dev": true }, "node_modules/selenium-webdriver": { - "version": "4.21.0", - "resolved": "https://registry.npmjs.org/selenium-webdriver/-/selenium-webdriver-4.21.0.tgz", - "integrity": "sha512-WaEJHZjOWNth1QG5FEpxpREER0qptZBMonFU6GtAqdCNLJVxbtC3E7oS/I/+Q1sf1W032Wg0Ebk+m46lANOXyQ==", + "version": "4.22.0", + "resolved": "https://registry.npmjs.org/selenium-webdriver/-/selenium-webdriver-4.22.0.tgz", + "integrity": "sha512-GNbrkCHmy249ai885wgXqTfqL2lZnclUH/P8pwTDIqzyFxU3YhDiN7p/c9tMFA4NhgRdEBO2QCG+CWmG7xr/Mw==", "dev": true, + "license": "Apache-2.0", "dependencies": { "jszip": "^3.10.1", "tmp": "^0.2.3", @@ -2561,6 +2595,7 @@ "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } @@ -2745,6 +2780,7 @@ "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", "dev": true, + "license": "MIT", "dependencies": { "is-number": "^7.0.0" }, @@ -2817,10 +2853,11 @@ } }, "node_modules/ts-patch": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/ts-patch/-/ts-patch-3.2.0.tgz", - "integrity": "sha512-fUGMkjGIlD4BFibDM+6pLYLXRguzCUY6fhP1KQzSnFJfAtTDT7DKyX0yHn3CJqfBv4mia/o3ZRte31UVf9Dl1A==", + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ts-patch/-/ts-patch-3.2.1.tgz", + "integrity": "sha512-hlR43v+GUIUy8/ZGFP1DquEqPh7PFKQdDMTAmYt671kCCA6AkDQMoeFaFmZ7ObPLYOmpMgyKUqL1C+coFMf30w==", "dev": true, + "license": "MIT", "dependencies": { "chalk": "^4.1.2", "global-prefix": "^3.0.0", @@ -2865,10 +2902,11 @@ } }, "node_modules/typescript": { - "version": "5.4.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", - "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", + "version": "5.5.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.2.tgz", + "integrity": "sha512-NcRtPEOsPFFWjobJEtfihkLCZCXZt/os3zf8nTxjVH3RvTSxjrCamJpbExGvYOF+tFHc3pA65qpdwPbzjohhew==", "dev": true, + "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -3052,10 +3090,11 @@ "dev": true }, "node_modules/ws": { - "version": "8.17.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.0.tgz", - "integrity": "sha512-uJq6108EgZMAl20KagGkzCKfMEjxmKvZHG7Tlq0Z6nOky7YF7aq4mOx6xK8TJ/i1LeK4Qus7INktacctDgY8Ow==", + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz", + "integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=10.0.0" }, diff --git a/package.json b/package.json index 767b538..c88d00a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@exact-realty/lot", - "version": "0.0.26", + "version": "0.0.27", "description": "Sandbox for isolating ECMAScript code", "main": "./dist/index.cjs", "types": "./dist/index.d.cts", @@ -133,22 +133,22 @@ "author": "Exact Realty Limited", "license": "ISC", "devDependencies": { - "@exact-realty/esbuild-plugin-closure-compiler": "^1.0.4", + "@exact-realty/esbuild-plugin-closure-compiler": "^1.0.5", "@exact-realty/esbuild-plugin-inline-js": "^1.1.7", - "@types/selenium-webdriver": "^4.1.23", - "@typescript-eslint/eslint-plugin": "^7.13.0", - "@typescript-eslint/parser": "^7.13.0", + "@types/selenium-webdriver": "^4.1.24", + "@typescript-eslint/eslint-plugin": "^7.14.1", + "@typescript-eslint/parser": "^7.14.1", "esbuild": "^0.21.5", "eslint": "^8.56.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.1.3", - "glob": "^10.4.1", + "glob": "^10.4.2", "google-closure-compiler": "^20240317.0.0", "prettier": "^3.3.2", - "selenium-webdriver": "^4.21.0", + "selenium-webdriver": "^4.22.0", "ts-node": "^10.9.2", - "ts-patch": "^3.2.0", - "typescript": "^5.4.5", + "ts-patch": "^3.2.1", + "typescript": "^5.5.2", "typescript-transform-paths": "^3.4.7" }, "engines": { diff --git a/src/untrusted/impl/nodejs/nodejsSandboxVm.inline.ts b/src/untrusted/impl/nodejs/nodejsSandboxVm.inline.ts index b5693b8..3a20c8b 100644 --- a/src/untrusted/impl/nodejs/nodejsSandboxVm.inline.ts +++ b/src/untrusted/impl/nodejs/nodejsSandboxVm.inline.ts @@ -368,47 +368,53 @@ const nodejsSandbox: TNodejsSandbox = ( // Remove properties from most built-in modules. This should somewhat // limit the access to system resources in case of an escape - (module.constructor as unknown as { builtinModules?: string[] })[ - 'builtinModules' - ]?.forEach((v) => { - if ( - [ - 'assert/strict', - 'async_hooks', - 'buffer', - 'events', - 'diagnostics_channel', - '_http_agent', - '_http_common', - '_http_outgoing', - '_http_server', - 'inspector', - 'module', - 'net', - 'path', - 'path/posix', - 'path/win32', - 'perf_hooks', - 'process', - 'stream', - 'readline', - 'trace_events', - 'v8', - 'vm', - ].includes(v) - ) - return; - // eslint-disable-next-line @typescript-eslint/no-var-requires - removeAllProperties(require('node:' + v)); - }); - // Prevent loading CJS modules - g_Object.defineProperty(global.module.constructor, '_load', { - ['set']: () => {}, - }); + if (typeof module === 'object') { + const _module = module; + (_module.constructor as unknown as { builtinModules?: string[] })[ + 'builtinModules' + ]?.forEach((v) => { + if ( + [ + 'assert/strict', + 'async_hooks', + 'buffer', + 'events', + 'diagnostics_channel', + '_http_agent', + '_http_common', + '_http_outgoing', + '_http_server', + 'inspector', + 'module', + 'net', + 'path', + 'path/posix', + 'path/win32', + 'perf_hooks', + 'process', + 'stream', + 'readline', + 'trace_events', + 'v8', + 'vm', + ].includes(v) + ) + return; + // eslint-disable-next-line @typescript-eslint/no-var-requires + removeAllProperties(require('node:' + v)); + }); + + // Prevent loading CJS modules + g_Object.defineProperty(_module.constructor, '_load', { + ['set']: () => {}, + }); + } + // Remove references in global and process to prevent calling require, etc. removeAllProperties(process, [ '_fatalException', 'debugPort', + 'env', 'exit', 'hrtime', 'nextTick', @@ -417,8 +423,47 @@ const nodejsSandbox: TNodejsSandbox = ( 'stderr', 'stdin', 'stdout', + // version & versions seems to be required by new Undici + 'version', + 'versions', + ]); + // The following seem to be required by 'node:internal/deps/undici/undici' + // Stack trace: + // at BuiltinModule.compileForInternalLoader (node:internal/bootstrap/realm:398:7) + // at requireBuiltin (node:internal/bootstrap/realm:429:14) + // at lazyMessageEvent (node:internal/worker/io:90:27) + // at MessagePort.value (node:internal/worker/io:131:19) + // at createEvent (node:internal/event_target:759:35) + removeAllProperties(global, [ + 'global', + 'globalThis', + 'performance', + 'AbortSignal', + 'Array', + 'Boolean', + 'Buffer', + 'Date', + 'Error', + 'Event', + 'EventTarget', + 'FinalizationRegistry', + 'FormData', + 'JSON', + 'Map', + 'Number', + 'Object', + 'ReadableStream', + 'Reflect', + 'Set', + 'String', + 'Symbol', + 'TextEncoder', + 'TextDecoder', + 'URLSearchParams', + 'WeakMap', + 'WeakRef', + 'WebAssembly', ]); - removeAllProperties(global); const wrapperFn = createWrapperFn(script, (s: string) => { return vm.compileFunction( diff --git a/src/untrusted/impl/worker/workerSandboxInit.inline.ts b/src/untrusted/impl/worker/workerSandboxInit.inline.ts index 22d4b35..e0a5500 100644 --- a/src/untrusted/impl/worker/workerSandboxInit.inline.ts +++ b/src/untrusted/impl/worker/workerSandboxInit.inline.ts @@ -16,6 +16,7 @@ import { aIsArray, aSlice, fnApply } from '~untrusted/lib/utils.js'; import * as Logger from '~untrusted/lib/Logger.js'; +import $global from '~untrusted/lib/global.js'; import workerSandboxInner from './workerSandboxInner.js'; const listener = (event: MessageEvent) => { @@ -27,11 +28,11 @@ const listener = (event: MessageEvent) => { return; Logger.info('Received SANDBOX_READY from parent. Creating sandbox.'); - globalThis.removeEventListener('message', listener, false); + $global.removeEventListener('message', listener, false); // Set allowUntrusted to false event.data[2] = false; fnApply(workerSandboxInner, null, aSlice(event.data, 1)); }; Logger.info('Worker started, registering event listener'); -globalThis.addEventListener('message', listener, false); +$global.addEventListener('message', listener, false); diff --git a/src/untrusted/impl/worker/workerSandboxInner.ts b/src/untrusted/impl/worker/workerSandboxInner.ts index 585aff7..1d74dd3 100644 --- a/src/untrusted/impl/worker/workerSandboxInner.ts +++ b/src/untrusted/impl/worker/workerSandboxInner.ts @@ -17,12 +17,13 @@ import singleUseFunctionConstructor from '~/untrusted/lib/singleUseFunctionConst import { aIsArray } from '~untrusted/lib/utils.js'; +import * as Logger from '~untrusted/lib/Logger.js'; import createSandboxedHandler from '~untrusted/lib/createSandboxedHandler.js'; import { extractErrorInformation } from '~untrusted/lib/errorModem.js'; +import $global from '~untrusted/lib/global.js'; import hardenGlobals, { disableURLStaticMethods, } from '~untrusted/lib/hardenGlobals.js'; -import * as Logger from '~untrusted/lib/Logger.js'; import recursivelyDeleteProperty from '~untrusted/lib/recursivelyDeleteProperty.js'; /** @@ -55,10 +56,10 @@ const createMessageEventListener = (() => { handler(event.data); }; - globalThis.addEventListener('message', eventListener); + $global.addEventListener('message', eventListener); return () => { - globalThis.removeEventListener('message', eventListener); + $global.removeEventListener('message', eventListener); }; }; })(); @@ -86,15 +87,15 @@ const workerSandboxInner = ( allowedGlobals: string[] | undefined | null, externalMethodsList: string[] | undefined | null, ) => { - const postMessage = globalThis['postMessage'].bind(globalThis); - const close = globalThis['close'].bind(globalThis); + const _postMessage = $global['postMessage'].bind($global); + const _close = $global['close'].bind($global); try { Logger.info('Setting up worker sandbox.'); // Remove methods from DedicatedWorkerGlobalScope - recursivelyDeleteProperty(globalThis, 'close'); - recursivelyDeleteProperty(globalThis, 'postMessage'); + recursivelyDeleteProperty($global, 'close'); + recursivelyDeleteProperty($global, 'postMessage'); hardenGlobals(); disableURLStaticMethods(); @@ -105,12 +106,12 @@ const workerSandboxInner = ( script, allowedGlobals, externalMethodsList, - postMessage, + _postMessage, Boolean, revocable ? () => { revokeRootMessageEventListener(); - close(); + _close(); } : undefined, ), @@ -120,14 +121,14 @@ const workerSandboxInner = ( Logger.info( 'Finished setting up worker sandbox. Sending SANDBOX_READY to parent.', ); - postMessage([EMessageTypes.SANDBOX_READY]); + _postMessage([EMessageTypes.SANDBOX_READY]); } catch (e) { Logger.warn( 'Error setting up worker sandbox. Sending GLOBAL_ERROR to parent.', ); - postMessage([EMessageTypes.GLOBAL_ERROR, extractErrorInformation(e)]); - close(); + _postMessage([EMessageTypes.GLOBAL_ERROR, extractErrorInformation(e)]); + _close(); } }; diff --git a/src/untrusted/impl/worker/workerSandboxManager.ts b/src/untrusted/impl/worker/workerSandboxManager.ts index c01b59b..0715818 100644 --- a/src/untrusted/impl/worker/workerSandboxManager.ts +++ b/src/untrusted/impl/worker/workerSandboxManager.ts @@ -48,7 +48,7 @@ const createWorker = ( const blob = new Blob([workerSandboxInit.default], { ['type']: 'text/javascript', }); - const workerSrcUrl = globalThis.URL.createObjectURL(blob); + const workerSrcUrl = URL.createObjectURL(blob); // Option name extracted as string constant to avoid name mangling const typeOptName = 'workerType'; const worker = new Worker( @@ -68,10 +68,7 @@ const createWorker = ( ...Parameters, ]); - const revokeWorkerSrcUrl = globalThis.URL.revokeObjectURL.bind( - null, - workerSrcUrl, - ); + const revokeWorkerSrcUrl = URL.revokeObjectURL.bind(null, workerSrcUrl); return [worker, revokeWorkerSrcUrl]; }; diff --git a/src/untrusted/lib/errorModem.ts b/src/untrusted/lib/errorModem.ts index eee308b..72311e6 100644 --- a/src/untrusted/lib/errorModem.ts +++ b/src/untrusted/lib/errorModem.ts @@ -13,6 +13,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ +import $global from '~untrusted/lib/global.js'; import { aForEach, aIncludes, @@ -124,10 +125,10 @@ const reconstructErrorInformation = (d: unknown, depth?: number) => { typeof d[2] === 'string' ) { const errorClass = - oHasOwnProperty(globalThis, d[0] as PropertyKey) && - typeof globalThis[d[0] as 'Error'] === 'function' && - globalThis[d[0] as 'Error'].prototype instanceof E - ? globalThis[d[0] as 'Error'] + oHasOwnProperty($global, d[0] as PropertyKey) && + typeof $global[d[0] as 'Error'] === 'function' && + $global[d[0] as 'Error'].prototype instanceof E + ? $global[d[0] as 'Error'] : E; const e = oCreate(errorClass.prototype);