RafaelGSS
f7892c16be
lib: makeRequireFunction patch when experimental policy
...
Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com >
Backport-PR-URL: https://github.com/nodejs-private/node-private/pull/373
Refs: https://hackerone.com/bugs?subject=nodejs&report_id=1747642
CVE-ID: CVE-2023-23918
PR-URL: https://github.com/nodejs-private/node-private/pull/358
Reviewed-by: Bradley Farias <bradley.meck@gmail.com >
Reviewed-by: Michael Dawson <midawson@redhat.com >
2023-02-15 13:31:05 +00:00
RafaelGSS and Bradley Farias
83975b7fb4
policy: makeRequireFunction on mainModule.require
...
Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com >
Co-authored-by: Bradley Farias <bradley.meck@gmail.com >
Backport-PR-URL: https://github.com/nodejs-private/node-private/pull/373
Refs: https://hackerone.com/bugs?subject=nodejs&report_id=1747642
CVE-ID: CVE-2023-23918
PR-URL: https://github.com/nodejs-private/node-private/pull/358
Reviewed-by: Bradley Farias <bradley.meck@gmail.com >
Reviewed-by: Michael Dawson <midawson@redhat.com >
2023-02-15 13:31:05 +00:00
Antoine du Hamel
fa115ee8ac
module: protect against prototype mutation
...
Ensures that mutating the `Object` prototype does not influence the
parsing of `package.json` files.
Backport-PR-URL: https://github.com/nodejs-private/node-private/pull/373
PR-URL: https://github.com/nodejs/node/pull/44007
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
2023-02-15 13:31:05 +00:00
Dominic Elm
b050c65885
src: add option to disable loading native addons
...
Backport-PR-URL: https://github.com/nodejs/node/pull/40094
PR-URL: https://github.com/nodejs/node/pull/39977
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Michael Dawson <midawson@redhat.com >
2022-01-25 07:54:07 -05:00
Rich Trott
d56e8268f9
doc,lib: prepare for stricter multi-line array linting
...
We're about to turn on a requirement for dangling commas.
PR-URL: https://github.com/nodejs/node/pull/37088
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2021-09-04 12:24:57 +02:00
Antoine du Hamel
1ce81079df
lib: remove use of array destructuring
...
PR-URL: https://github.com/nodejs/node/pull/36818
Reviewed-By: Rich Trott <rtrott@gmail.com >
2021-09-01 23:24:52 +02:00
f9f9389d83
module: add support for node:‑prefixed require(…) calls
...
Fixes: https://github.com/nodejs/node/issues/36098
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com >
Co-authored-by: Guy Bedford <guybedford@gmail.com >
Co-authored-by: Darshan Sen <raisinten@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/37246
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Darshan Sen <raisinten@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2021-09-01 23:24:51 +02:00
Antoine du Hamel
d8cc2fffd6
lib: add primordials.SafeArrayIterator
...
PR-URL: https://github.com/nodejs/node/pull/36532
Backport-PR-URL: https://github.com/nodejs/node/pull/39446
Reviewed-By: Rich Trott <rtrott@gmail.com >
2021-07-22 12:06:15 -04:00
Antoine du Hamel
e3223edb89
lib: harden lint checks for globals
...
PR-URL: https://github.com/nodejs/node/pull/38419
Backport-PR-URL: https://github.com/nodejs/node/pull/39448
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Darshan Sen <raisinten@gmail.com >
2021-07-20 07:11:42 -04:00
bcoe
bb9a9adc2b
errors: don't rekey on primitive type
...
If an error is thrown before a module is loaded, we attempt to cache
source map against error object, rather than module object. We
can't do this if the error is a primitive type
Fixes #38945
PR-URL: https://github.com/nodejs/node/pull/39025
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2021-07-20 07:11:40 -04:00
bl-ue
b0a1984d4d
lib: fix typos
...
PR-URL: https://github.com/nodejs/node/pull/38846
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Darshan Sen <raisinten@gmail.com >
Reviewed-By: Richard Lau <rlau@redhat.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Khaidi Chu <i@2333.moe >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Michael Dawson <midawson@redhat.com >
2021-07-20 07:11:26 -04:00
Antoine du Hamel
8912caba64
lib: expose primordials object
...
Expose the internal `primordials` object to help with Node.js core
development.
```console
$ node --expose-internals -r internal/test/binding lib/fs.js
(node:5299) internal/test/binding: These APIs are for internal testing
only. Do not use them.
(Use `node --trace-warnings ...` to show where the warning was created)
```
PR-URL: https://github.com/nodejs/node/pull/36872
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-06-11 09:29:56 +02:00
Antoine du Hamel
1aae572220
module: refactor to use more primordials
...
PR-URL: https://github.com/nodejs/node/pull/36348
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2021-06-11 09:29:45 +02:00
Antoine du Hamel
9e7f166161
module: refactor to use more primordials
...
PR-URL: https://github.com/nodejs/node/pull/36024
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
2021-06-11 09:28:43 +02:00
Michaël Zasso
e2395b0f3b
lib: use Object static properties from primordials
...
PR-URL: https://github.com/nodejs/node/pull/35380
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de >
Reviewed-By: Ricky Zhou <0x19951125@gmail.com >
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com >
2021-05-16 15:10:11 +02:00
James M Snell
2413907a12
module: add isPreloading indicator
...
Adds a `module.isPreloading` property that is `true` only during the
preload (`-r`) phase of Node.js bootstrap. This provides modules an
easy, non-hacky way of knowing if they are being loaded during preload.
Signed-off-by: James M Snell <jasnell@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/36263
Backport-PR-URL: https://github.com/nodejs/node/pull/36988
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2021-04-25 08:22:12 +02:00
bcoe
3c37f896a4
errors: print original exception context
...
When --enable-source-maps is set, the error context displayed
above the stack trace now shows original source rather than
transpiled.
Backport-PR-URL: https://github.com/nodejs/node/pull/37700
PR-URL: https://github.com/nodejs/node/pull/33491
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
2021-04-06 15:53:41 -04:00
Guy Bedford
f23a0e250c
module: refine module type mismatch error cases
...
PR-URL: https://github.com/nodejs/node/pull/35426
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
Reviewed-By: Myles Borins <myles.borins@gmail.com >
2020-10-06 11:54:24 -04:00
Guy Bedford
f551f52f83
module: named exports for CJS via static analysis
...
PR-URL: https://github.com/nodejs/node/pull/35249
Reviewed-By: Mary Marchini <oss@mmarchini.me >
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Myles Borins <myles.borins@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Zeyu Yang <himself65@outlook.com >
Reviewed-By: Richard Lau <riclau@uk.ibm.com >
2020-09-29 11:54:34 -04:00
Antoine du HAMEL
76e24f9aa9
module: use isURLInstance instead of instanceof
...
PR-URL: https://github.com/nodejs/node/pull/34951
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Derek Lewis <DerekNonGeneric@inf.is >
2020-09-21 11:53:35 -04:00
Bradley Farias
18b04ab4c8
policy: implement scopes field
...
PR-URL: https://github.com/nodejs/node/pull/34552
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-09-01 11:15:46 -04:00
Derek Lewis and Guy Bedford
e4a0e5bc1a
module: fix check for package.json at volume root
...
This patch converts the "read package scope" algorithm's while loop
into a do-while loop enabling items at the filesystem root dir to
be considered within the scope of a sibling package.json also at the
filesystem root dir.
Fixes: https://github.com/nodejs/node/issues/33438
Co-authored-by: Guy Bedford <guybedford@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/34595
Reviewed-By: Jan Krems <jan.krems@gmail.com >
Reviewed-By: Mary Marchini <oss@mmarchini.me >
2020-08-20 15:05:17 +01:00
Bradley Farias
84031183bc
policy: support conditions for redirects
...
PR-URL: https://github.com/nodejs/node/pull/34414
Reviewed-By: Jan Krems <jan.krems@gmail.com >
Reviewed-By: Guy Bedford <guybedford@gmail.com >
2020-08-20 15:05:14 +01:00
Guy Bedford
698cae7625
module: share CJS/ESM resolver fns, refactoring
...
PR-URL: https://github.com/nodejs/node/pull/34744
Reviewed-By: Jan Krems <jan.krems@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-08-20 15:05:14 +01:00
Guy Bedford
6929649793
module: custom --conditions flag option
...
PR-URL: https://github.com/nodejs/node/pull/34637
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com >
Reviewed-By: Jan Krems <jan.krems@gmail.com >
2020-08-20 15:05:12 +01:00
Guy Bedford
9a7c87df37
module: use cjsCache over esm injection
...
PR-URL: https://github.com/nodejs/node/pull/34605
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-08-20 15:05:07 +01:00
Bradley Farias
3eabb7e5c7
policy: increase tests via permutation matrix
...
PR-URL: https://github.com/nodejs/node/pull/34404
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-08-10 21:21:49 -07:00
Daniele Belardi
e1199af50a
module: self referential modules in repl or -r
...
Load self referential modules from the repl and using the preload flag
`-r`. In both cases the base path used for resolution is the current
`process.cwd()`. Also fixes an internal cycle bug in the REPL exports
resolution.
PR-URL: https://github.com/nodejs/node/pull/32261
Fixes: https://github.com/nodejs/node/issues/31595
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Jan Krems <jan.krems@gmail.com >
2020-07-27 18:23:43 -04:00
Antoine du HAMEL
8d7330be0e
module: deprecate module.parent
...
This feature does not work when a module is imported using ECMAScript
modules specification, therefore it is deprecated.
Fixes: https://github.com/nodejs/modules/issues/469
Backport-PR-URL: https://github.com/nodejs/node/pull/33533
PR-URL: https://github.com/nodejs/node/pull/32217
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2020-07-16 17:09:13 -04:00
Guy Bedford
1ae76bd075
module: package "imports" field
...
PR-URL: https://github.com/nodejs/node/pull/34117
Reviewed-By: Jan Krems <jan.krems@gmail.com >
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
2020-07-16 17:09:07 -04:00
Brian White
bc7a251d33
lib: improve debuglog() performance
...
PR-URL: https://github.com/nodejs/node/pull/32260
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-06-30 09:34:24 -07:00
Kirill Shatskiy
3d2e7e74f0
esm: share package.json cache between ESM and CJS loaders
...
Refs: https://github.com/nodejs/node/issues/30674
PR-URL: https://github.com/nodejs/node/pull/33229
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com >
2020-06-30 09:33:43 -07:00
Matteo Collina
c2cf9782ab
Revert "vm: add importModuleDynamically option to compileFunction"
...
This reverts commit 74c393dd93 .
Fixes: https://github.com/nodejs/node/issues/33166
PR-URL: https://github.com/nodejs/node/pull/33364
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
2020-05-16 12:18:12 -07:00
Ruben Bridgewater
c2d2dfc09f
module: do not check circular dependencies for exported proxies
...
In case the exported module is a proxy that has the `getPrototypeOf`
or `setPrototypeOf` trap, skip the circular dependencies check.
It would otherwise be triggered by the check itself.
Fixes: https://github.com/nodejs/node/issues/33334
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/33338
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Zeyu Yang <himself65@outlook.com >
2020-05-16 12:18:07 -07:00
Ruben Bridgewater
69061dc73e
repl: replace hard coded core module list with actual list
...
This replaces the internally used hard coded Node.js core module
list with the actual internal existent modules. That way all modules
are automatically picked up instead of having to update the list
manually.
This currently only applies to the REPL and to the Node.js `eval`
functionality (User passed `-e` or `--eval` arguments to Node without
`-i` or `--interactive`).
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/33282
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
2020-05-16 12:17:52 -07:00
James M Snell
eab4be1b93
lib: cosmetic change to builtinLibs list for maintainability
...
This is a largely cosmetic change suggested for easier
maintainability of the builtinLibs list. While the
QUIC PR no longer modifies this list, the original version
of the PR did and the fact that all of the entries were
bundled up into the same lines meant that adding one
forced a larger change to all. With this PR, when we
want to add a new built-in, it won't impact any of the
others.
PR-URL: https://github.com/nodejs/node/pull/33106
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2020-05-04 14:23:25 +02:00
Anna Henningsen
4abc45a4b9
module: do not warn when accessing __esModule of unfinished exports
...
Since this property access is performed by generated code, and not
used for accessing the actual exports of a module (and because
transpilers generally define it as the first key of `module.exports`
when it *is* present), it should be okay to allow it.
Refs: https://github.com/nodejs/node/pull/29935
Fixes: https://github.com/nodejs/node/issues/33046
PR-URL: https://github.com/nodejs/node/pull/33048
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Zeyu Yang <himself65@outlook.com >
2020-04-28 23:00:41 +01:00
Gus Caplan
4143c747fc
vm: add importModuleDynamically option to compileFunction
...
Fixes: https://github.com/nodejs/node/issues/31860
PR-URL: https://github.com/nodejs/node/pull/32985
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
2020-04-28 16:28:32 +01:00
Guy Bedford
21d314e7fc
module: exports not exported for null resolutions
...
PR-URL: https://github.com/nodejs/node/pull/32838
Reviewed-By: Jan Krems <jan.krems@gmail.com >
2020-04-27 20:40:47 +01:00
Qinhui Chen
fe1bda9aeb
module: fix memory leak when require error occurs
...
Delete useless module in parent module: parent.children array
when error occurs, so that it can be garbage collected.
Fixes: https://github.com/nodejs/node/issues/32836
PR-URL: https://github.com/nodejs/node/pull/32837
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Andrey Pechkurov <apechkurov@gmail.com >
2020-04-17 13:43:41 -04:00
Guy Bedford
b2e77003c5
module: path-only CJS exports extension searching
...
PR-URL: https://github.com/nodejs/node/pull/32351
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com >
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
Reviewed-By: Jan Krems <jan.krems@gmail.com >
Reviewed-By: Myles Borins <myles.borins@gmail.com >
2020-04-07 16:25:09 +01:00
Guy Bedford
49ad16104f
module: disable conditional exports, self resolve warnings
...
PR-URL: https://github.com/nodejs/node/pull/31845
Reviewed-By: Jan Krems <jan.krems@gmail.com >
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com >
2020-02-26 23:21:56 +02:00
Guy Bedford
58de9b46b8
module: package "exports" error refinements
...
PR-URL: https://github.com/nodejs/node/pull/31625
Reviewed-By: Jan Krems <jan.krems@gmail.com >
2020-02-18 13:34:40 +02:00
Rich Trott
8c18e91c8a
process: remove undocumented now argument from emitWarning()
...
process.emitWarning() "now" option is undocumented and a Boolean trap.
Remove it before people start adopting it.
We only need it in one place internally. Replace it with an
internal-only emitWarningSync() function.
PR-URL: https://github.com/nodejs/node/pull/31643
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Myles Borins <myles.borins@gmail.com >
2020-02-07 15:37:36 -10:00
Guy Bedford
c2c3274631
module: fix check exports issue in cjs module loading
...
Refs: https://github.com/nodejs/node/pull/31001#issuecomment-576353389
PR-URL: https://github.com/nodejs/node/pull/31427
Reviewed-By: Richard Lau <riclau@uk.ibm.com >
Reviewed-By: Shelley Vohr <codebytere@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-01-20 21:32:52 -08:00
Guy Bedford
fc4e413554
module: unflag conditional exports
...
PR-URL: https://github.com/nodejs/node/pull/31001
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Myles Borins <myles.borins@gmail.com >
2020-01-15 20:48:52 -05:00
Guy Bedford
405e7b4557
module: logical conditional exports ordering
...
PR-URL: https://github.com/nodejs/node/pull/31008
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
Reviewed-By: Jan Krems <jan.krems@gmail.com >
2020-01-07 06:14:19 +02:00
Sebastien Ahkrin
9085c03806
lib: replace Map global by the primordials
...
PR-URL: https://github.com/nodejs/node/pull/31155
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
2020-01-04 14:56:52 -08:00
Sebastien Ahkrin
c9b93e2344
lib: replace use of Error with primordials
...
PR-URL: https://github.com/nodejs/node/pull/31163
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
2020-01-04 14:50:18 -08:00
Guy Bedford
c7f328f0df
module: unflag resolve self
...
PR-URL: https://github.com/nodejs/node/pull/31002
Reviewed-By: Myles Borins <myles.borins@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Jan Krems <jan.krems@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2020-01-02 17:53:47 +01:00