Aviv Keller
6e3e99c81e
lib: prefer logical assignment
...
PR-URL: https://github.com/nodejs/node/pull/55044
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Chemi Atlow <chemi@atlow.co.il >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
Reviewed-By: LiviaMedeiros <livia@cirno.name >
2024-11-27 11:03:39 -05:00
Yagiz Nizipli
03902ebb74
lib: replace createDeferredPromise util with Promise.withResolvers
...
PR-URL: https://github.com/nodejs/node/pull/54836
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Chemi Atlow <chemi@atlow.co.il >
Reviewed-By: Moshe Atlow <moshe@atlow.co.il >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Robert Nagy <ronagy@icloud.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
2024-11-27 11:03:39 -05:00
Aviv Keller
d803355d92
lib: prefer optional chaining
...
PR-URL: https://github.com/nodejs/node/pull/55045
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Chemi Atlow <chemi@atlow.co.il >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
Reviewed-By: Paolo Insogna <paolo@cowtech.it >
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com >
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com >
2024-10-04 10:20:24 +02:00
Antoine du Hamel
5f02e1b850
lib: move Symbol[Async]Dispose polyfills to internal/util
...
PR-URL: https://github.com/nodejs/node/pull/54853
Reviewed-By: Moshe Atlow <moshe@atlow.co.il >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2024-09-14 00:20:34 +02:00
Liran Tal
057bd44f9f
child_process: fix incomplete prototype pollution hardening
...
Prior pull request (#48726 ) hardened against prototype pollution
vulnerabilities but effectively missed some use-cases which
opened a window for prototype pollution for some child_process
functions such as spawn(), spawnSync(), and execFileSync().
PR-URL: https://github.com/nodejs/node/pull/53781
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com >
2024-08-05 11:15:41 -03:00
Antoine du Hamel
d1adc9b140
lib: enforce ASCII order in error code imports
...
PR-URL: https://github.com/nodejs/node/pull/52625
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Chemi Atlow <chemi@atlow.co.il >
2024-04-29 22:46:29 +02:00
Antoine du Hamel
f9ddd77ff3
tools: add lint rule to keep primordials in ASCII order
...
PR-URL: https://github.com/nodejs/node/pull/52592
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io >
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: Moshe Atlow <moshe@atlow.co.il >
2024-04-29 22:46:28 +02:00
atlowChemi
562369f348
child_process: use internal addAbortListener
...
PR-URL: https://github.com/nodejs/node/pull/52081
Refs: https://github.com/nodejs/node/pull/48596
Reviewed-By: Moshe Atlow <moshe@atlow.co.il >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2024-03-16 09:08:56 +00:00
LiviaMedeiros
aed2b21ac0
typings: update JSDoc for cwd in child_process
...
PR-URL: https://github.com/nodejs/node/pull/49029
Refs: https://github.com/nodejs/node/pull/38862
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2023-08-08 15:32:31 +08:00
Livia Medeiros
6a889261c8
child_process: harden against prototype pollution
...
PR-URL: https://github.com/nodejs/node/pull/48726
Reviewed-By: Matthew Aitken <maitken033380023@gmail.com >
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2023-07-14 09:37:37 +00:00
atlowChemi
b239b06eb8
child_process: use addAbortListener
...
PR-URL: https://github.com/nodejs/node/pull/48550
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2023-07-11 19:50:27 +03:00
Debadree Chatterjee
2dc4290662
child_process: use signal.reason in child process abort
...
Fixes: https://github.com/nodejs/node/issues/47814
PR-URL: https://github.com/nodejs/node/pull/47817
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Darshan Sen <raisinten@gmail.com >
2023-05-08 08:17:03 +00:00
Antoine du Hamel
351d7fd20d
child_process: add trailing commas in source files
...
PR-URL: https://github.com/nodejs/node/pull/46758
Reviewed-By: Deokjin Kim <deokjin81.kim@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Moshe Atlow <moshe@atlow.co.il >
Reviewed-By: James M Snell <jasnell@gmail.com >
2023-02-24 09:44:18 +01:00
Antoine du Hamel
fe514bf960
lib: enforce use of trailing commas for functions
...
PR-URL: https://github.com/nodejs/node/pull/46629
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com >
2023-02-14 18:45:16 +01:00
Darshan Sen
91dbd8bb1c
child_process: validate arguments for null bytes
...
This change adds validation to reject an edge case where the
child_process API argument strings might contain null bytes
somewhere in between. Such strings were being silently truncated
before, so throwing an error should prevent misuses of this API.
Fixes: https://github.com/nodejs/node/issues/44768
Signed-off-by: Darshan Sen <raisinten@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/44782
Reviewed-By: James M Snell <jasnell@gmail.com >
2022-10-14 13:02:57 +00:00
cjihrig
df92b3c64b
child_process: remove lookup of undefined property
...
execSync() passes opts.args to checkExecSyncError(). There are
two problems:
1. opts.args appears to always be undefined.
2. Even if it was defined, checkExecSyncError() would not use
it since the command input is guaranteed to be defined.
This commit updates the code to pass undefined instead.
PR-URL: https://github.com/nodejs/node/pull/44766
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2022-09-28 20:00:37 -04:00
alexcfyung
02aa8c22c2
lib: pass env variables to child process on z/OS
...
PR-URL: https://github.com/nodejs/node/pull/42255
Reviewed-By: Michael Dawson <midawson@redhat.com >
2022-08-04 18:52:43 -04:00
theanarkh
04840223ee
child_process: do not need to count length when maxBuffer is Infinity
...
PR-URL: https://github.com/nodejs/node/pull/43822
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
2022-07-21 18:28:19 +01:00
木杉
c030f88fcf
child_process: avoid repeated calls to normalizeSpawnArguments
...
PR-URL: https://github.com/nodejs/node/pull/43345
Fixes: https://github.com/nodejs/node/issues/43333
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: LiviaMedeiros <livia@cirno.name >
2022-07-18 10:20:57 +01:00
Antoine du Hamel
a055337a02
lib: refactor to avoid unsafe regex primordials
...
PR-URL: https://github.com/nodejs/node/pull/43475
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com >
2022-06-27 17:16:06 +02:00
LiviaMedeiros
20b0df1d1e
child_process: use kEmptyObject
...
PR-URL: https://github.com/nodejs/node/pull/43159
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2022-06-11 12:18:11 +02:00
Antoine du Hamel
06d8606960
lib: use null-prototype objects for property descriptors
...
Refs: https://github.com/nodejs/node/pull/42921
PR-URL: https://github.com/nodejs/node/pull/43270
Reviewed-By: Paolo Insogna <paolo@cowtech.it >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com >
2022-06-03 09:23:58 +01:00
Rich Trott
f8ca5dfea4
child_process: add env contents types in JSDoc
...
Use JSDoc to indicate that the `env` object keys and values must be
strings.
Refs: https://github.com/nodejs/node/pull/42489#discussion_r835867932
PR-URL: https://github.com/nodejs/node/pull/42494
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2022-03-30 15:03:48 +01:00
Rich Trott
3c97583a0d
lib: update JSDoc for linting
...
Fix issue that will be flagged when we update ESLint and dependencies.
PR-URL: https://github.com/nodejs/node/pull/42489
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Mestery <mestery@protonmail.com >
Reviewed-By: Darshan Sen <raisinten@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2022-03-27 08:35:14 -07:00
Rich Trott
bd86e5186a
lib: add internal genericNodeError() function
...
There are a few places in lib where `new Error()` is called and then
additional properties are attached in various ways. This creates a
utility function to generate the errors.
PR-URL: https://github.com/nodejs/node/pull/41879
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2022-02-09 01:56:15 +00:00
Rich Trott
26c973d4b3
child_process: improve argument validation
...
For execFile() and fork(), use INVALID_ARG_TYPE as appropriate instead
of INVALID_ARG_VALUE. Use validator functions where sensible.
PR-URL: https://github.com/nodejs/node/pull/41305
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2021-12-29 16:41:45 -08:00
Rich Trott
4069e7eddb
child_process: revise argument processing
...
execFile() and fork() have complicated argument processing. Clarify code
and avoid using `arguments`.
PR-URL: https://github.com/nodejs/node/pull/41280
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2021-12-24 14:53:05 +00:00
Antoine du Hamel
81812bad7b
child_process: add support for URL to cp.fork
...
PR-URL: https://github.com/nodejs/node/pull/41225
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-12-19 22:40:53 +00:00
Voltrex
9d3a592fff
lib: add JSDoc typings for child_process
...
Added JSDoc typings for the `child_process` lib module.
PR-URL: https://github.com/nodejs/node/pull/38222
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Michael Dawson <midawson@redhat.com >
2021-06-17 11:40:32 -04:00
Qingyu Deng
e0238c4352
child_process: refactor to use validateBoolean
...
PR-URL: https://github.com/nodejs/node/pull/38927
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Darshan Sen <raisinten@gmail.com >
Reviewed-By: Khaidi Chu <i@2333.moe >
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-06-07 07:29:07 -07:00
XadillaX
fc4b9c1d07
child_process: allow options.cwd receive a URL
...
PR-URL: https://github.com/nodejs/node/pull/38862
Fixes: https://github.com/nodejs/node/issues/38861
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2021-06-04 14:33:59 +08:00
Rich Trott
db7df59933
child_process: remove unused argument
...
The internal validateTimeout() takes a single parameter, so do not pass
a second value.
PR-URL: https://github.com/nodejs/node/pull/37923
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com >
Reviewed-By: Darshan Sen <raisinten@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2021-03-28 07:55:57 -07:00
Nitzan Uziely
6ea652d6ec
child_process: cleanup AbortSignal duplication
...
cleanup AbortSignal child_process code duplication
PR-URL: https://github.com/nodejs/node/pull/37823
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-03-22 08:15:13 -07:00
Nitzan Uziely
d8fb5c2f1c
child_process: add timeout to spawn and fork
...
Add support for timeout to spawn and fork.
Fixes: https://github.com/nodejs/node/issues/27639
PR-URL: https://github.com/nodejs/node/pull/37256
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
2021-03-19 12:12:41 +01:00
Nitzan Uziely
9f56bc8b4c
child_process: fix spawn and fork abort behavior
...
Fix AbortSignal in Spawn which doesn't actually abort
the process, and fork can emit an AbortError even if
the process was already exited. Add documentation
For killSignal.
Fixes: https://github.com/nodejs/node/issues/37273
PR-URL: https://github.com/nodejs/node/pull/37325
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
2021-02-27 14:38:50 +02:00
Darshan Sen
549a11c7b2
lib: simplify check in child_process
...
PR-URL: https://github.com/nodejs/node/pull/37367
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2021-02-16 20:45:33 +05:30
Nitzan Uziely
2272713df0
child_process: fix bad abort signal leak
...
Move abort signal validation to before spawn is executed
so that the file is not leaked.
PR-URL: https://github.com/nodejs/node/pull/37257
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2021-02-12 23:38:25 +02:00
cjihrig
17467d15f8
util: add internal createDeferredPromise()
...
The pattern of resolving/rejecting a Promise from outside of its
executor happens numerous times throughout the codebase (more than
what is updated here in fact). This commit abstracts that logic
into an internal utility function.
PR-URL: https://github.com/nodejs/node/pull/37095
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-01-29 09:50:34 -05:00
029d1fd797
lib: refactor to use validateObject
...
Co-authored-by: ExE Boss <3889017+ExE-Boss@users.noreply.github.com >
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/37028
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Darshan Sen <raisinten@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-01-28 12:53:50 +01:00
Carlos Fuentes
2242cbb253
child_process: allow promisified exec to be cancel
...
Using new AbortController, add support for promisified
exec to be cancelled.
PR-URL: https://github.com/nodejs/node/pull/34249
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-01-22 20:03:09 -08:00
ZiJian Liu
08dd4b1723
lib: refactor to use validateString
...
PR-URL: https://github.com/nodejs/node/pull/37006
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-01-22 19:56:34 -08:00
Rich Trott
36394b6782
child_process: reduce abort handler code duplication
...
Move duplicate abort handler logic into a separate function.
PR-URL: https://github.com/nodejs/node/pull/36644
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com >
2020-12-30 07:54:04 -08:00
Rich Trott
a71061a9dc
child_process: treat already-aborted controller as aborting
...
If an AbortController passed to execfile() is already aborted, use the
same behavior as if the controller was aborted after calling execfile().
This mimics the behavior of fetch in the browser.
PR-URL: https://github.com/nodejs/node/pull/36644
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com >
2020-12-30 07:54:03 -08:00
Benjamin Gruenbaum
73a21e4c06
child_process: support AbortSignal in fork
...
PR-URL: https://github.com/nodejs/node/pull/36603
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2020-12-24 20:33:15 +00:00
Benjamin Gruenbaum
f0a0e3c6b3
child_process: clean event listener correctly
...
I was working on AbortSignal for spawn and noticed there is a leak in
the current code for AbortSignal support in child_process since it
removes the wrong listener. I used the new signal as argument feature
to make removing the listener easier and added a test.
PR-URL: https://github.com/nodejs/node/pull/36424
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-12-22 17:53:00 +02:00
Benjamin Gruenbaum
738cd60418
child_process: add signal support to spawn
...
PR-URL: https://github.com/nodejs/node/pull/36432
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-12-12 16:46:24 +00:00
Benjamin Gruenbaum
20de5f7efc
child_process: add AbortSignal support
...
PR-URL: https://github.com/nodejs/node/pull/36308
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-12-06 12:23:19 +02:00
Zijian Liu
f7dd330ba0
child_process: refactor to use more primordials
...
PR-URL: https://github.com/nodejs/node/pull/36269
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2020-12-03 21:57:17 +00:00
Bartosz Sosnowski
abd8cdfc4e
win, child_process: sanitize env variables
...
On Windows environment variables are case-insensitive. When spawning
child process certain apps can get confused if some of the variables are
duplicated.
This adds a step on Windows to normalizeSpawnArguments that removes such
duplicates, keeping only the first (in lexicographic order) entry in the
env key of options. This is partly already done for the PATH entry.
Fixes: https://github.com/nodejs/node/issues/35129
PR-URL: https://github.com/nodejs/node/pull/35210
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Denys Otrishko <shishugi@gmail.com >
2020-09-24 18:25:18 +02:00
Brian White
c24b74a7ab
lib: improve debuglog() performance
...
PR-URL: https://github.com/nodejs/node/pull/32260
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-05-30 17:24:43 -04:00