Commit Graph

8903 Commits

Author SHA1 Message Date
Joyee Cheung
7db6e189d6 src: set ModuleWrap internal fields only once
There is no need to initialize the internal fields to undefined
and then initialize them to something else in the caller. Simply
pass the internal fields into the constructor to initialize
them just once.

PR-URL: https://github.com/nodejs/node/pull/49391
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2023-09-08 11:08:09 +00:00
Phil Nash
015e27bd08 src: don't overwrite environment from .env file
This commit adds a check to see if an environment variable that is
found in the .env file is already set in the environment. If it is,
then the value from the .env file is not used.

PR-URL: https://github.com/nodejs/node/pull/49424
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
2023-09-08 06:44:36 +00:00
Mustafa Ateş Uzun
0bce573bd4 src: fix fs_type_to_name default value
PR-URL: https://github.com/nodejs/node/pull/49239
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: theanarkh <theratliter@gmail.com>
2023-09-07 19:14:33 +00:00
rogertyang
c86e700b3e src: fix comment on StreamResource
PR-URL: https://github.com/nodejs/node/pull/49193
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2023-09-07 11:11:35 +02:00
Joyee Cheung
941ad8b843 src: do not rely on the internal field being default to undefined
It's an undocumented V8 behavior that is subject to change. Instead
just check if the internal field is set to a promise. There is also
no need to check IsEmpty() since the object is guaranteed to be
constructed by the FileHandle constructor with enough internal
fields.

PR-URL: https://github.com/nodejs/node/pull/49413
Refs: https://chromium-review.googlesource.com/c/v8/v8/+/4707972/comment/be9285cc_a49aad88/
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2023-09-07 08:59:38 +00:00
Joyee Cheung
0028fd12b7 build: add --write-snapshot-as-array-literals to configure.py
This makes it easier to locate indeterminism in the snapshot, with
the following command:

$ ./configure --write-snapshot-as-array-literals
$ make V=
$ mv out/Release/obj/gen/node_snapshot.cc ./node_snapshot.cc
$ make V=
$ diff out/Release/obj/gen/node_snapshot.cc ./node_snapshot.cc

PR-URL: https://github.com/nodejs/node/pull/49312
Refs: https://github.com/nodejs/build/issues/3043
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2023-09-04 23:44:23 +02:00
Joyee Cheung
4d0f930183 bootstrap: only use the isolate snapshot when compiling code cache
We do not actually need to deserialize the context and the whole
environment to compile the code cache, since code cache are not
context-dependent anyway, deserializing just the isolate snapshot is
enough.

PR-URL: https://github.com/nodejs/node/pull/49288
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2023-09-04 23:35:27 +02:00
pluris
ce11e00dbc src: modify code for empty string
PR-URL: https://github.com/nodejs/node/pull/49336
Refs: https://github.com/nodejs/node/pull/49097
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
2023-09-01 23:52:36 +05:30
Joyee Cheung
295572ec67 src: remove unused PromiseWrap-related code
PromiseWrap has been removed in
https://github.com/nodejs/node/pull/39135 and we do not have any
internal object setting the internal field at 0 as a promise
(we always set the first field as an aligned pointer to
the embedder ID). As result GetAssignedPromiseWrapAsyncId()
always just returns AsyncWrap::kInvalidAsyncId and turn
the removed block into noops. So the block just can be removed.

PR-URL: https://github.com/nodejs/node/pull/49335
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
2023-09-01 12:26:32 +00:00
Yagiz Nizipli
f863117ba3 url: handle unicode hostname if empty
PR-URL: https://github.com/nodejs/node/pull/49396
Fixes: https://github.com/nodejs/node/issues/48759
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2023-08-31 10:25:31 +00:00
Michael Graeb
9848352974 node-api: fix compiler warning in node_api.h
Fix "-Wstrict-prototypes" warning from AppleClang 14.0.3.14030022,
compiling C, targeting arch arm64 (on x86_64 host). I build my C
addon with -Werror and recent changes to node_api.h broke our build.

PR-URL: https://github.com/nodejs/node/pull/49103
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Gabriel Schulhof <gabrielschulhof@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2023-08-30 02:42:31 +00:00
Tobias Nießen
43704dd230 src: rename IsAnyByteSource to IsAnyBufferSource
The current name is somewhat confusing. There is an internal ByteSource
class, which is entirely unrelated to what IsAnyByteSource() does, even
though both exist in the crypto subsystem of the C++ code. ByteSource
objects can also be constructed from strings, for example, for which
IsAnyByteSource() returns false.

Web IDL calls the types for which this function returns true
BufferSource. This type is commonly used across Web Crypto, for example.
Thus, rename the function to match the Web IDL naming.

Because the function also appears to accept BufferSource objects backed
by SharedArrayBuffer instances, the exact Web IDL name would be
AllowSharedBufferSource, but that seems unnecessarily long, so I decided
to stick with "any".

PR-URL: https://github.com/nodejs/node/pull/49346
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
2023-08-29 18:52:54 +00:00
Node.js GitHub Bot
0ebd0882a8 crypto: update root certificates to NSS 3.93
This is the certdata.txt[0] from NSS 3.93, released on 2023-06-29.

This is the version of NSS that shipped in Firefox 116 on
2023-08-01.

Certificates added:
- Sectigo Public Server Authentication Root E46
- Sectigo Public Server Authentication Root R46
- SSL.com TLS RSA Root CA 2022
- SSL.com TLS ECC Root CA 2022
- Atos TrustedRoot Root CA ECC TLS 2021
- Atos TrustedRoot Root CA RSA TLS 2021

Certificates removed:
- Hongkong Post Root CA 1
- E-Tugra Certification Authority
- E-Tugra Global Root CA RSA v3
- E-Tugra Global Root CA ECC v3

[0] https://hg.mozilla.org/projects/nss/raw-file/NSS_3_93_RTM/lib/ckfw/builtins/certdata.txt

PR-URL: https://github.com/nodejs/node/pull/49341
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
2023-08-29 15:44:57 +00:00
Joyee Cheung
5c9daf4583 sea: generate code cache with deserialized isolate
V8 now requires code cache to be compiled from an isolate with the
same RO space layout as the one that's going to deserialize the
cache, so for a binary built with snapshot, we need to compile
the code cache using a deserialized isolate.

Drive-by: ignore "useCodeCache" when "useSnapshot" is true because
the compilation would've been done during build time anyway in
that case, and print a warning for it.

PR-URL: https://github.com/nodejs/node/pull/49226
Refs: https://github.com/nodejs/node-v8/issues/252
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2023-08-22 16:56:04 +00:00
Joyee Cheung
f6f1131096 src: support snapshot deserialization in RAIIIsolate
PR-URL: https://github.com/nodejs/node/pull/49226
Refs: https://github.com/nodejs/node-v8/issues/252
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2023-08-22 16:56:03 +00:00
Jungku Lee
a16b610e86 src: remove unused function GetName() in node_perf
PR-URL: https://github.com/nodejs/node/pull/49244
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Deokjin Kim <deokjin81.kim@gmail.com>
2023-08-21 16:42:12 +00:00
Jungku Lee
982e7a65cc src: use ARES_SUCCESS instead of 0
PR-URL: https://github.com/nodejs/node/pull/49048
Refs: https://github.com/nodejs/node/pull/48834
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: Deokjin Kim <deokjin81.kim@gmail.com>
2023-08-20 10:04:34 +00:00
Jungku Lee
45e5ec89a6 src: add a condition if the argument of DomainToUnicode is empty
PR-URL: https://github.com/nodejs/node/pull/49097
Refs: https://github.com/nodejs/node/pull/46410
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Deokjin Kim <deokjin81.kim@gmail.com>
2023-08-20 09:55:44 +00:00
Joyee Cheung
7b7a68b1fe bootstrap: build code cache from deserialized isolate
V8 now requires the code cache to be compiled with a finalized
read-only space, so we need to serialize the snapshot to get
a finalized read-only space first, then deserialize it to compile
the code cache.

PR-URL: https://github.com/nodejs/node/pull/49099
Refs: https://github.com/nodejs/node/issues/47636
Refs: https://bugs.chromium.org/p/v8/issues/detail?id=13789
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2023-08-18 11:17:13 +00:00
Carlos Espa
413c16e490 src,permission: add multiple allow-fs-* flags
Support for a single comma separates list for allow-fs-* flags is
removed. Instead now multiple flags can be passed to allow multiple
paths.

Fixes: https://github.com/nodejs/security-wg/issues/1039
PR-URL: https://github.com/nodejs/node/pull/49047
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
2023-08-17 18:39:04 +00:00
Joyee Cheung
fe219e0438 bootstrap: do not generate code cache in an unfinalized isolate
V8 now no longer supports serializing code cache in an isolate
with unfinalized read-only space. So guard the code cache regeneration
with the `is_building_snapshot()` flag. When the isolate is created
for snapshot generation, the code cache is going to be serialized
separately anyway, so there is no need to do it in the builtin loader.

PR-URL: https://github.com/nodejs/node/pull/49108
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2023-08-17 17:24:46 +00:00
Yagiz Nizipli
769823e57c src: add built-in .env file support
PR-URL: https://github.com/nodejs/node/pull/48890
Refs: https://github.com/orgs/nodejs/discussions/44975
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
2023-08-17 14:08:05 +00:00
Joyee Cheung
b4a2be457c vm: store MicrotaskQueue in ContextifyContext directly
Previously the ContextifyContext holds a MicrotaskQueueWrap which in
turns holds a MicrotaskQueue in a shared pointer. The indirection is
actually unnecessary, we can directly hold the MicrotaskQueue via
a unique pointer in ContextifyContext, the lifetime would still
remain the same but the graph would be simpler, and this removes
the additional JS -> C++ to create the wrapper object.

PR-URL: https://github.com/nodejs/node/pull/48982
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
2023-08-16 20:18:46 +00:00
Joyee Cheung
a49bc4bcda src: remove C++ WeakReference implementation
PR-URL: https://github.com/nodejs/node/pull/49053
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2023-08-16 18:45:08 +02:00
Joyee Cheung
6391b3b95d src: use per-realm GetBindingData() wherever applicable
This reduce the number of embedder slot accesses and also removes
the assumption in a few binding methods that the current realm is
the principal realm of the current environment (which is not true
for shadow realms).

PR-URL: https://github.com/nodejs/node/pull/49007
Refs: https://github.com/nodejs/node/pull/48836
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2023-08-16 02:32:50 +00:00
Joyee Cheung
3578bee3e1 src: add per-realm GetBindingData() method
This version avoids the additional access to the embedder slot
when we already have a reference to the realm.

PR-URL: https://github.com/nodejs/node/pull/49007
Refs: https://github.com/nodejs/node/pull/48836
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2023-08-16 02:32:49 +00:00
Michael Dawson
3d5e7cd8f0 report: fix recent coverity warning
Fix warning about dereferencing null env

Signed-off-by: Michael Dawson <mdawson@devrus.com>

PR-URL: https://github.com/nodejs/node/pull/48954
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2023-08-15 15:32:25 -04:00
Joyee Cheung
89dd09310e src: serialize both BaseObject slots
We previously only return startup data for the first slot for
BaseObjects because we can already serialize all the necessary
information in one go, but slots that do not get special startup
data would be serialized verbatim which means that the pointer
addresses are going to be part of the snapshot blob, resulting
in indeterminism.

This patch updates the serialization routines and capture information
for both of the two slots - the first slot with type information
and memory management type (which we can use in the future for
cppgc-managed objects) and the second slot with data about the
object itself. This way the embeedder slots can be serialized
in a reproducible manner in the snapshot.

PR-URL: https://github.com/nodejs/node/pull/48996
Refs: https://github.com/nodejs/build/issues/3043
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
2023-08-15 18:32:14 +00:00
Jungku Lee
6476c99ddc src: remove duplicated code in GenerateSingleExecutableBlob()
PR-URL: https://github.com/nodejs/node/pull/49119
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Deokjin Kim <deokjin81.kim@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
2023-08-14 17:33:33 +00:00
Joyee Cheung
634eb505a4 src: refactor vector writing in snapshot builder
- Build a static table of octal strings and use it instead of
  building octal strings repeatedly during printing.
- Print a newline and an offset for every 64 bytes in the case
  of printing array literals so it's easier to locate
  variation in snapshot blobs.
- Rework the printing routines so that the differences are only
  made in a WriteByteVectorLiteral routine. We can update this
  for compression support in the future.
- Rename Snapshot::Generate() that write the data as C++ source
  instead of a blob as Snaphost::GenerateAsSource() for clarity,
  and move the file stream operations into it to streamline
  error handling.

PR-URL: https://github.com/nodejs/node/pull/48851
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
2023-08-14 12:53:02 +00:00
Guy Bedford
ee8b7f1f18 esm: unflag import.meta.resolve
PR-URL: https://github.com/nodejs/node/pull/49028
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
2023-08-13 05:42:25 +00:00
Yagiz Nizipli
607a545904 url: overload canParse V8 fast api method
PR-URL: https://github.com/nodejs/node/pull/48993
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2023-08-12 22:34:46 +00:00
Yagiz Nizipli
4cf30df026 src: add ability to overload fast api functions
PR-URL: https://github.com/nodejs/node/pull/48993
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2023-08-12 22:34:45 +00:00
Jungku Lee
82e4ca109e src: remove redundant code for uv_handle_type
PR-URL: https://github.com/nodejs/node/pull/49061
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Reviewed-By: Deokjin Kim <deokjin81.kim@gmail.com>
2023-08-12 22:16:35 +00:00
Node.js GitHub Bot
8358ce4486 deps: update undici to 5.23.0
PR-URL: https://github.com/nodejs/node/pull/49021
Reviewed-By: Matthew Aitken <maitken033380023@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2023-08-12 18:28:48 +00:00
Jason
f426cc0c3f src: modernize use-equals-default
PR-URL: https://github.com/nodejs/node/pull/48735
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2023-08-11 17:58:04 +00:00
Yagiz Nizipli
7ffa5d7f0d src: avoid string copy in BuiltinLoader::GetBuiltinIds
PR-URL: https://github.com/nodejs/node/pull/48721
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
2023-08-11 15:31:58 +00:00
cjihrig
4e61c22699 test_runner: expose location of tests
This commit adds each test's line and column number to the reporter
output. This will aid in debugging test suite failures when error
stacks are not helpful, test suites are large, or tests have the
same name. This data is also exposed on the spec reporter.

This commit also replaces the filename that was previously being
reported, with the filename where the test actually exists. These
are normally correct, but could be wrong if tests were run from
a file other than the user's entrypoint.

PR-URL: https://github.com/nodejs/node/pull/48975
Fixes: https://github.com/nodejs/node/issues/48457
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
2023-08-11 09:12:49 -04:00
Daryl Haresign
7f2c810814 src,tools: initialize cppgc
This patch:

- Initializes cppgc in InitializeOncePerProcess() when
  kNoInitializeCppgc is not set
- Create a CppHeap and attach it to the Isolate when
  there isn't one already during IsolateData initialization.
  The CppHeap is detached and terminated when IsolateData
  is freed.
- Publishes the cppgc headers in the tarball.

This allows C++ addons to start using cppgc to manage objects.

A helper node::SetCppgcReference() is also added to help addons
enable cppgc tracing in a user-defined object.

Co-authored-by: Joyee Cheung <joyeec9h3@gmail.com>
Refs: https://github.com/nodejs/node/issues/40786
PR-URL: https://github.com/nodejs/node/pull/45704
Refs: https://docs.google.com/document/d/1ny2Qz_EsUnXGKJRGxoA-FXIE2xpLgaMAN6jD7eAkqFQ/edit
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
2023-08-11 00:43:51 +00:00
Jason
54e4f1f5e6 src: fix callback_queue.h missing header
PR-URL: https://github.com/nodejs/node/pull/48733
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
2023-08-10 23:07:09 +00:00
Rafael Gonzaga
23d65e7281 src: revert IS_RELEASE to 0
PR-URL: https://github.com/nodejs/node/pull/49084
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2023-08-10 12:17:41 +02:00
RafaelGSS
7e97e908c7 permission: handle fstatfs and add pm supported list
PR-URL: https://github.com/nodejs-private/node-private/pull/441
CVE-ID: CVE-2023-32005
2023-08-09 14:28:48 -03:00
RafaelGSS
ae25da20fa 2023-08-09, Version 20.5.1 (Current)
This is a security release.

Notable changes:

* CVE-2023-32002: Policies can be bypassed via Module.\_load (High)
* CVE-2023-32558: process.binding() can bypass the permission model through path traversal (High)
* CVE-2023-32004: Permission model can be bypassed by specifying a path traversal sequence in a Buffer (High)
* CVE-2023-32006: Policies can be bypassed by module.constructor.createRequire (Medium)
* CVE-2023-32559: Policies can be bypassed via process.binding (Medium)
* CVE-2023-32005: fs.statfs can bypass the permission model (Low)
* CVE-2023-32003: fs.mkdtemp() and fs.mkdtempSync() can bypass the permission model (Low)
* OpenSSL Security Releases
  * https://mta.openssl.org/pipermail/openssl-announce/2023-July/000264.html
  * https://mta.openssl.org/pipermail/openssl-announce/2023-July/000265.html
  * https://mta.openssl.org/pipermail/openssl-announce/2023-July/000267.html

PR-URL: https://github.com/nodejs-private/node-private/pull/465
2023-08-09 14:24:18 -03:00
rogertyang
556b1ca900 tls: fix bugs of double TLS
Fixs two issues in `TLSWrap`, one of them is reported in
https://github.com/nodejs/node/issues/30896.

1. `TLSWrap` has exactly one `StreamListener`, however,
that `StreamListener` can be replaced. We have not been
rigorous enough here: if an active write has not been
finished before the transition, the finish callback of it
will be wrongly fired the successor `StreamListener`.

2. A `TLSWrap` does not allow more than one active write,
as checked in the assertion about current_write in
`TLSWrap::DoWrite()`.

However, when users make use of an existing `tls.TLSSocket`
to establish double TLS, by
either
  tls.connect({socket: tlssock})
or
  tlsServer.emit('connection', tlssock)
we have both of the user provided `tls.TLSSocket`, tlssock and
a brand new created `TLSWrap` writing to the `TLSWrap` bound to
tlssock, which easily violates the constranint because two writers
have no idea of each other.

The design of the fix is:
when a `TLSWrap` is created on top of a user provided socket,
do not send any data to the socket until all existing writes
of the socket are done and ensure registered callbacks of
those writes can be fired.

PR-URL: https://github.com/nodejs/node/pull/48969
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
2023-08-04 10:14:18 -04:00
Joyee Cheung
5f2539cd9a src: cast v8::Object::GetInternalField() return value to v8::Value
In preparation of https://chromium-review.googlesource.com/c/v8/v8/+/4707972
which changes the return value to v8::Data.

PR-URL: https://github.com/nodejs/node/pull/48943
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
2023-08-02 02:14:35 +00:00
Antoine du Hamel
af4cdcde15 src: do not pass user input to format string
PR-URL: https://github.com/nodejs/node/pull/48973
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2023-08-01 20:05:51 +00:00
Rafael Gonzaga
14e7bd84f1 src,permission: restrict by default when pm enabled
PR-URL: https://github.com/nodejs/node/pull/48907
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
2023-07-26 18:32:03 +00:00
Joyee Cheung
faefe560ef src: remove ContextEmbedderIndex::kBindingDataStoreIndex
We can now get the binding data through the reference to the
realm directly, so remove it from the context embedder data
slot.

PR-URL: https://github.com/nodejs/node/pull/48836
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2023-07-26 13:26:08 +00:00
Darshan Sen
6cd678965f sea: add support for V8 bytecode-only caching
Refs: https://github.com/nodejs/single-executable/issues/73
Signed-off-by: Darshan Sen <raisinten@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/48191
Fixes: https://github.com/nodejs/single-executable/issues/73
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2023-07-26 10:10:35 +00:00
Tobias Nießen
1ceb8c113d node-api: avoid macro redefinition
Even though the redefinition complies with the C standard because the
second definition is "effectively the same" as the first definition,
it's best to avoid any redefinition.

Refs: https://github.com/nodejs/node/pull/28237
Refs: https://github.com/nodejs/node/pull/30006
PR-URL: https://github.com/nodejs/node/pull/48879
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Vladimir Morozov <vmorozov@microsoft.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2023-07-23 19:51:38 +00:00