Tobias Nießen
eaf9083cf1
module: fix code injection through export names
...
createDynamicModule() properly escapes import names, but not export
names. In WebAssembly, any string is a valid export name. Importing a
WebAssembly module that uses a non-identifier export name leads to
either a syntax error in createDynamicModule() or to code injection,
that is, to the evaluation of almost arbitrary JavaScript code outside
of the WebAssembly module.
To address this issue, adopt the same mechanism in createExport() that
createImport() already uses. Add tests for both exports and imports.
PR-URL: https://github.com/nodejs-private/node-private/pull/461
Backport-PR-URL: https://github.com/nodejs-private/node-private/pull/490
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com >
CVE-ID: CVE-2023-39333
2023-10-13 07:33:52 -04:00
Antoine du Hamel
d9a800ee5c
esm: fix emit deprecation on legacy main resolve
...
PR-URL: https://github.com/nodejs/node/pull/48664
Refs: https://github.com/nodejs/node/pull/48325
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com >
2023-09-16 15:39:16 -04:00
Moshe Atlow
c39b7c240e
esm: add --import flag
...
PR-URL: https://github.com/nodejs/node/pull/43942
Backport-PR-URL: https://github.com/nodejs/node/pull/49539
Fixes: https://github.com/nodejs/node/issues/40110
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2023-09-12 10:58:09 -04:00
Zack Newsham
a00464ee06
esm: fix specifier resolution and symlinks
...
Ensure `--experimental-specifier-resolution=node` works when combined
with `--preserve-symlinks`.
PR-URL: https://github.com/nodejs/node/pull/47674
Refs: https://github.com/nodejs/node/issues/47649
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2023-08-17 17:51:33 -04:00
Gil Tayar
c5af5a4f4f
module: change default resolver to not throw on unknown scheme
...
Fixes https://github.com/nodejs/loaders/issues/138
PR-URL: https://github.com/nodejs/node/pull/47824
Reviewed-By: Moshe Atlow <moshe@atlow.co.il >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2023-07-07 00:06:15 +03:00
Tobias Nießen
a3f0504556
test: mark test-esm-loader-http-imports as flaky
...
This test has been failing occasionally for weeks.
Refs: https://github.com/nodejs/node/issues/47836
Refs: https://github.com/nodejs/reliability/issues/564
PR-URL: https://github.com/nodejs/node/pull/47987
Reviewed-By: Filip Skokan <panva.ip@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2023-07-07 00:06:14 +03:00
Antoine du Hamel
e5e385d2b2
esm: increase test coverage of edge cases
...
PR-URL: https://github.com/nodejs/node/pull/47033
Backport-PR-URL: https://github.com/nodejs/node/pull/47433
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Jacob Smith <jacob@frende.me >
2023-06-20 17:23:50 -03:00
Antoine du Hamel
5b94e2bcdb
esm: fix import assertion warning
...
Refs: https://github.com/nodejs/node/pull/46901#discussion_r1122242913
PR-URL: https://github.com/nodejs/node/pull/46971
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com >
Reviewed-By: Moshe Atlow <moshe@atlow.co.il >
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2023-04-10 20:55:10 -04:00
Moshe Atlow
e52b169ef4
test_runner: align behavior of it and test
...
PR-URL: https://github.com/nodejs/node/pull/46889
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2023-04-10 20:55:08 -04:00
Antoine du Hamel
96a39d1a99
esm: add a runtime warning when using import assertions
...
PR-URL: https://github.com/nodejs/node/pull/46901
Refs: https://github.com/nodejs/node/issues/46830
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com >
Reviewed-By: Jacob Smith <jacob@frende.me >
2023-04-10 20:55:07 -04:00
Geoffrey Booth
320a8adb45
esm: misc test refactors
...
- add test specific to the event loop
- move parallel tests into es-module folder
- refactor fixture to add braces for if blocks
- use 'os' instead of 'fs' as placeholder
- spelling
PR-URL: https://github.com/nodejs/node/pull/46631
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
2023-04-03 07:49:40 -04:00
MURAKAMI Masahiko
5fdf374c74
test_runner: avoid swallowing of asynchronously thrown errors
...
Fixes: https://github.com/nodejs/node/issues/44612
PR-URL: https://github.com/nodejs/node/pull/45264
Backport-PR-URL: https://github.com/nodejs/node/pull/46839
Reviewed-By: Moshe Atlow <moshe@atlow.co.il >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
2023-03-04 23:03:32 -05:00
Geoffrey Booth
4e88c7c813
esm: delete preload mock test
...
PR-URL: https://github.com/nodejs/node/pull/46402
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
2023-03-04 23:03:32 -05:00
Michaël Zasso and Geoffrey Booth
a3056f4125
test: refactor to avoid mutation of global by a loader
...
This makes the test compatible with off-thread loaders.
Co-Authored-By: Geoffrey Booth <webadmin@geoffreybooth.com >
PR-URL: https://github.com/nodejs/node/pull/46220
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
2023-01-31 08:04:21 -05:00
Antoine du Hamel
3269423032
test,esm: validate more edge cases for dynamic imports
...
PR-URL: https://github.com/nodejs/node/pull/46059
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com >
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com >
2023-01-31 08:04:14 -05:00
Geoffrey Booth
0bdf2db079
esm: rewrite loader hooks test
...
Rewrite the test that validates that custom loader hooks are called from
being a test that depends on internals to one that spawns a child
process and checks its output to confirm expected behavior.
PR-URL: https://github.com/nodejs/node/pull/46016
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Jacob Smith <jacob@frende.me >
2023-01-31 08:04:12 -05:00
Daeyeon Jeong
204757719c
errors: refactor to use a method that formats a list string
...
Signed-off-by: Daeyeon Jeong <daeyeon.dev@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/45793
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2023-01-31 08:04:10 -05:00
Antoine du Hamel
2f27d058c2
esm: protect ESM loader from prototype pollution
...
In a previous commit, the loader implementation was modified to be
protected against most prototype pollution, but was kept vulnerable to
`Array.prototype` pollution. This commit fixes that, the tradeoff is
that it modifies the `ESMLoader.prototype.import` return type from an
`Array` to an array-like object.
Refs: https://github.com/nodejs/node/pull/45044
PR-URL: https://github.com/nodejs/node/pull/45175
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
2023-01-03 08:38:26 -05:00
Antoine du Hamel
46ded6b96e
esm: protect ESM loader from prototype pollution
...
Fixes: https://github.com/nodejs/node/issues/45035
PR-URL: https://github.com/nodejs/node/pull/45044
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Moshe Atlow <moshe@atlow.co.il >
Reviewed-By: Darshan Sen <raisinten@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2023-01-03 08:38:15 -05:00
Guy Bedford
2c0f7d47e4
module: fix segment deprecation for imports field
...
PR-URL: https://github.com/nodejs/node/pull/44883
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2023-01-03 08:38:08 -05:00
Geoffrey Booth
910fbd0ece
esm: fix duplicated test
...
PR-URL: https://github.com/nodejs/node/pull/44779
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
2022-10-05 11:52:58 +01:00
Jacob Smith
9b3b7d6978
esm,loader: tidy ESMLoader internals
...
PR-URL: https://github.com/nodejs/node/pull/44701
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2022-09-26 19:07:45 -03:00
Guy Bedford
f8ec946c82
module: exports & imports map invalid slash deprecation
...
PR-URL: https://github.com/nodejs/node/pull/44477
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Jacob Smith <jacob@frende.me >
2022-09-26 19:07:41 -03:00
Jacob Smith
5e9c197d85
esm: fix loader hooks accepting too many arguments
...
PR-URL: https://github.com/nodejs/node/pull/44109
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2022-08-22 19:37:16 -04:00
SADIK KUZU
1dabdbf05c
src,test: fix typos
...
* src: fix typo in `src/node_messaging.h` (`postMesssage` ->
`postMessage`).
* test/es-module: fix typo in `test-cjs-exports.js` (`eror` -> `error`).
PR-URL: https://github.com/nodejs/node/pull/44110
Reviewed-By: Feng Yu <F3n67u@outlook.com >
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Mestery <mestery@protonmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2022-08-22 19:37:14 -04:00
Jacob Smith
b19564b9d2
test: refactor ESM tests to improve performance
...
PR-URL: https://github.com/nodejs/node/pull/43784
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2022-08-22 19:37:11 -04:00
Antoine du Hamel
e502c50a90
test: refactor test/es-module/test-esm-resolve-type
...
Using TLA to avoid undetected never-settling promises, and avoid running
parallel calls to `process.chdir`.
PR-URL: https://github.com/nodejs/node/pull/43178
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2022-07-25 21:43:43 -04:00
Jacob Smith
0d2921f396
esm: fix erroneous re-initialization of ESMLoader
...
PR-URL: https://github.com/nodejs/node/pull/43763
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com >
Reviewed-By: Guy Bedford <guybedford@gmail.com >
2022-07-25 21:43:38 -04:00
Jacob Smith
953fefe77b
esm: restore next<HookName>'s context as optional arg
...
PR-URL: https://github.com/nodejs/node/pull/43553
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2022-07-12 07:41:46 +02:00
Ray
3ad4d37b3c
module: also enable subpath imports in REPL
...
PR-URL: https://github.com/nodejs/node/pull/43450
Fixes: https://github.com/nodejs/node/issues/43410
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2022-07-12 07:41:44 +02:00
Antoine du Hamel
48ae00c0b1
test: improve coverage for load hooks
...
Refs: https://github.com/nodejs/node/pull/43363#discussion_r894366025
PR-URL: https://github.com/nodejs/node/pull/43374
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com >
2022-07-12 07:41:31 +02:00
Jacob Smith
10bcad5c6e
esm: fix chain advances when loader calls next<HookName> multiple times
...
PR-URL: https://github.com/nodejs/node/pull/43303
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2022-07-12 07:41:01 +02:00
Jacob Smith
254efd9e3b
esm: fix http(s) import via custom loader
...
PR-URL: https://github.com/nodejs/node/pull/43130
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2022-07-12 07:40:45 +02:00
Jacob Smith
da61e2330f
esm: add chaining to loaders
...
PR-URL: https://github.com/nodejs/node/pull/42623
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2022-07-12 07:40:38 +02:00
Antoine du Hamel
0bb84b09a5
dns: accept 'IPv4' and 'IPv6' for family
...
Refs: https://github.com/nodejs/node/issues/43014
PR-URL: https://github.com/nodejs/node/pull/43054
Fixes: https://github.com/nodejs/node/issues/43014
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Darshan Sen <raisinten@gmail.com >
Reviewed-By: Beth Griggs <bgriggs@redhat.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Michael Dawson <midawson@redhat.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2022-06-15 21:28:47 -04:00
Antoine du Hamel
a0638a23b0
esm: fix imports from non-file module
...
Fixes: https://github.com/nodejs/node/issues/42860
PR-URL: https://github.com/nodejs/node/pull/42881
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: Guy Bedford <guybedford@gmail.com >
2022-05-02 14:39:32 +02:00
Antoine du Hamel
3a26db9697
net: make server.address() return an integer for family
...
`dns.lookup` options only accepts integer for `family` options,
having a string doesn't really make sense here.
PR-URL: https://github.com/nodejs/node/pull/41431
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2022-04-12 05:50:09 +02:00
Daeyeon Jeong
1600869eb7
test: fix comments in test files
...
This commit fixes typos found in test files.
PR-URL: https://github.com/nodejs/node/pull/42536
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2022-03-31 08:48:03 +02:00
Jacob Smith
5a927ef0c2
esm: emit experimental warnings in common place
...
PR-URL: https://github.com/nodejs/node/pull/42314
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
2022-03-28 22:43:15 +01:00
Bradley Farias
a01302b8df
esm: make extension-less errors in type:module actionable
...
PR-URL: https://github.com/nodejs/node/pull/42301
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2022-03-15 00:59:32 +00:00
Bradley Farias
68626dc451
esm: improve typings and code coverage
...
PR-URL: https://github.com/nodejs/node/pull/42305
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Mestery <mestery@protonmail.com >
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com >
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: Darshan Sen <raisinten@gmail.com >
2022-03-14 16:30:26 +01:00
Geoffrey Booth
a30e0de005
esm: add runtime warning for specifier resolution flag
...
PR-URL: https://github.com/nodejs/node/pull/42252
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2022-03-10 12:43:47 +01:00
Xuguang Mei
02d326fff5
loader: fix esm resolve for symlink file
...
Fix: https://github.com/nodejs/node/issues/42195
PR-URL: https://github.com/nodejs/node/pull/42197
Fixes: https://github.com/nodejs/node/issues/42195
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
2022-03-06 04:11:44 +00:00
Bradley Farias
acc11c9873
esm: fix base URL for network imports
...
PR-URL: https://github.com/nodejs/node/pull/42131
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
2022-03-04 15:40:38 -06:00
Bradley Farias
f860b3810f
esm: fix relative imports for https
...
PR-URL: https://github.com/nodejs/node/pull/42119
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com >
Reviewed-By: Ricky Zhou <0x19951125@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
2022-02-27 09:20:42 +00:00
Benjamin Gruenbaum
7efef74585
module: prefer async/await in https imports
...
PR-URL: https://github.com/nodejs/node/pull/41950
Fixes: https://github.com/nodejs/node/issues/41950
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2022-02-23 23:59:52 +02:00
madflow
60c71f35ee
process: fix named report export
...
PR-URL: https://github.com/nodejs/node/pull/41861
Fixes: https://github.com/nodejs/node/issues/41774
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2022-02-23 18:37:55 +02:00
Antoine du Hamel
3a1a440802
esm: improve fetch_module test coverage and remove hack
...
PR-URL: https://github.com/nodejs/node/pull/41947
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
2022-02-19 16:35:46 +00:00
Jacob Smith
8843381d9f
esm: remove erroneous context.parentURL property passed to load hook
...
PR-URL: https://github.com/nodejs/node/pull/41975
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2022-02-18 18:55:58 +00:00
ceadb473e6
esm: support https remotely and http locally under flag
...
Co-authored-by: Jacob Smith <3012099+JakobJingleheimer@users.noreply.github.com >
Co-authored-by: James M Snell <jasnell@gmail.com >
Co-authored-by: Jordan Harband <ljharb@gmail.com >
Co-authored-by: James Sumners <james@sumners.email >
PR-URL: https://github.com/nodejs/node/pull/36328
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
2022-02-09 19:47:12 -08:00