Commit Graph
8396 Commits
Author SHA1 Message Date
Feng Yu f36813c598 src: simplify enable_if logic of ToStringHelper::BaseConvert
PR-URL: https://github.com/nodejs/node/pull/44306
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
2022-09-01 05:42:34 +00:00
Juan José Arboleda 7ee8bfe1cd src: add error handling to uv_uptime call
PR-URL: https://github.com/nodejs/node/pull/44386
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-08-31 14:28:28 -05:00
Chengzhong Wu 81d9cdb8cd src: introduce node::Realm
To distinguish per-context values from the node::Environment, split
those values to a new node::Realm structure and consolidate
bootstrapping methods with it.

PR-URL: https://github.com/nodejs/node/pull/44179
Refs: https://github.com/nodejs/node/issues/42528
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-08-31 14:41:42 +00:00
Chengzhong Wu ad3c7bcb03 node-api: avoid calling virtual methods in base's dtor
Derived classes' fields are already destroyed if the virtual methods are
invoked in the base class's destructor. It is not safe to call virtual
methods in base's dtor.

PR-URL: https://github.com/nodejs/node/pull/44424
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
2022-08-31 13:47:10 +00:00
Tobias Nießen 6239aeb157 src: remove base64_select_table and base64_table
node::base64_encode() uses ::base64_encode() when the mode is
Base64Mode::NORMAL, so base64_select_table is only ever called for
Base64Mode::URL and thus only ever returns base64_table_url, but never
base64_table.

Also move base64_table_url into base64-inl.h.

PR-URL: https://github.com/nodejs/node/pull/44425
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
2022-08-31 08:20:33 +00:00
Tobias Nießen 9fc7b83738 crypto: use actual option name in error message
oaep_label is the name of the C++ variable. Use oaepLabel instead, which
is the name of the documented option.

PR-URL: https://github.com/nodejs/node/pull/44455
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: theanarkh <theratliter@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2022-08-31 08:20:24 +00:00
theanarkh 63aba5672c src: fix uv_err_name memory leak
PR-URL: https://github.com/nodejs/node/pull/44421
Refs: https://github.com/nodejs/node/pull/44401
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
2022-08-30 18:33:40 +00:00
Tobias Nießen 01c7a98bd6 src: make Endianness an enum class
PR-URL: https://github.com/nodejs/node/pull/44411
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
2022-08-30 14:36:32 +00:00
Tobias Nießen ad41c919df src: remove v8abbr.h
The definitions in v8abbr.h, except for NODE_OFF_EXTSTR_DATA, were only
used for dtrace, which has been removed.

Refs: https://github.com/nodejs/node/pull/43652
PR-URL: https://github.com/nodejs/node/pull/44402
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
2022-08-30 12:57:22 +00:00
Shohei YOSHIDA 4f4d39408f doc: fix spacing issue in --build-snapshot help text
PR-URL: https://github.com/nodejs/node/pull/44435
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2022-08-30 00:18:38 +02:00
Darshan Sen 72aafbdba7 src: fix ssize_t error from nghttp2.h
The "node_http2.h" include reordering enforced by clang-format broke
Electron's Node.js upgrade on Windows. ssize_t is a part of the POSIX
standard and it's not available on Windows, so the fix for this is to
include "node.h" which typedefs it on Windows in
https://github.com/nodejs/node/blob/bb4dff783ddb3b20c67041f7ccef796c335c2407/src/node.h#L212-L220.

Refs: https://github.com/electron/electron/pull/35350#discussion_r954890551
Signed-off-by: Darshan Sen <raisinten@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/44393
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Shelley Vohr <shelley.vohr@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-08-29 09:58:53 +00:00
theanarkh d40a622016 os: add machine method
PR-URL: https://github.com/nodejs/node/pull/44416
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-08-29 07:49:32 +00:00
theanarkh 60c3077d46 src: trace fs async api
PR-URL: https://github.com/nodejs/node/pull/44057
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-08-28 18:06:27 +00:00
Chengzhong Wu 3370e7c53a src: restore context default IsCodeGenerationFromStringsAllowed value
Context's default IsCodeGenerationFromStringsAllowed value can be
changed by v8 flag `--disallow-code-generation-from-strings`. Restore
the value at runtime when delegating the code generation validation to
`node::ModifyCodeGenerationFromStrings`.

The context's settings are serialized in the snapshot. Reset the setting
values to its default values before the serialization so that it can be
correctly re-initialized after deserialization at runtime.

PR-URL: https://github.com/nodejs/node/pull/44324
Fixes: https://github.com/nodejs/node/issues/44287
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-08-28 15:36:46 +00:00
Tobias Nießen d0172d1b55 src: simplify and optimize GetOpenSSLVersion()
The previous implementation was typically compiled to a fair amount of
code even though all inputs are available at compile time.

The fact that GetOpenSSLVersion() returns a std::string and used an
uninitialized buffer with snprintf made it impossible to make
GetOpenSSLVersion() a constexpr, and compilers would typically emit code
to dynamically construct the resulting string.

The simplified implementation usually boils down to a few mov
instructions.

(Ideally, this function could be a constexpr returning a
std::string_view, but that does not have any advantage in the current
design of node::Metadata::Versions which stores versions as
std::string instances.)

Also make the function static since it is not in an anonymous namespace
and change the argument types and the return type of search() to
types that are more appropriate, semantically. (The use of snprintf
previously made this difficult.) Lastly, make the n argument of search()
optional because the simplified implementation always sets it to 0
except during recursive calls within search() itself.

PR-URL: https://github.com/nodejs/node/pull/44395
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Shelley Vohr <shelley.vohr@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
2022-08-28 10:40:21 +00:00
Anna Henningsen ee75ad7a38 src: use if constexpr where appropriate
Doesn't change much but communicates to readers that these
are compile-time conditionals.

PR-URL: https://github.com/nodejs/node/pull/44291
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Feng Yu <F3n67u@outlook.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2022-08-27 09:51:35 +00:00
Tobias Nießen 5181600526 src: simplify ECDH::GetCurves()
There is no need to explicitly branch based on num_curves or on the
return value of the second call to EC_get_builtin_curves. Remove
unnecessary branches and replace the loop with a functional transform.

PR-URL: https://github.com/nodejs/node/pull/44309
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2022-08-26 19:59:51 +00:00
Tobias Nießen 15aa34b20a inspector: prevent integer overflow in open()
PR-URL: https://github.com/nodejs/node/pull/44367
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
2022-08-25 20:32:14 +00:00
Tobias Nießen 4d49d6507e crypto: simplify control flow in HKDF
Unify the implementation and perform the same OpenSSL calls regardless
of whether the key and/or salt are empty. This simplifies the code and
improves coverage.

Refs: https://github.com/nodejs/node/pull/44201
PR-URL: https://github.com/nodejs/node/pull/44272
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
2022-08-25 16:36:08 +00:00
Tobias Nießen ddc5da9353 src: make minor improvements to EnabledDebugList
Change the underlying type of DebugCategory to unsigned int so that it
can be safely cast to an unsigned type without having to worry about
negative values, removing the need for the DCHECK_GE statements.

To fully benefit from type safety, remove DebugCategory::CATEGORY_COUNT
and instead add a constexpr kDebugCategoryCount.

Remove the second argument from EnabledDebugList::set_enabled() and
EnabledDebugList::Parse() because it was always set to true.

PR-URL: https://github.com/nodejs/node/pull/44350
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
2022-08-25 00:28:46 +00:00
legendecas f33a038384 node-api: cleanup redundant static modifiers
Functions declared in anonymous namespaces are not necessarily to be
marked as static.

PR-URL: https://github.com/nodejs/node/pull/44301
Refs: https://github.com/nodejs/node/pull/44141
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michael Dawson <midawson@redhat.com>
2022-08-25 08:15:00 +08:00
Tobias Nießen 2f8bb705d9 src: remove KeyObjectData::symmetric_key_len_
symmetric_key_len_ is always equal to symmetric_key_.size(). Storing it
separately is redundant and has no significant benefit.

PR-URL: https://github.com/nodejs/node/pull/44346
Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
2022-08-24 19:05:10 +00:00
Chengzhong Wu cb15fc56d8 report: expose report public native apis
Allows APM vendors to generate a diagnostic report without calling into
JavaScript. Like, from their own message channels interrupting the
isolate and generating a report on demand.

PR-URL: https://github.com/nodejs/node/pull/44255
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
2022-08-24 17:02:26 +00:00
theanarkh d9b2d2c0dd report: add queue info for udp
PR-URL: https://github.com/nodejs/node/pull/44345
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2022-08-24 16:37:53 +00:00
Joyee Cheung 7900f6540e vm: avoid unnecessary property getter interceptor calls
Access to the global object from within a vm context is intercepted
so it's slow, therefore we should try to avoid unnecessary access
to it during the initialization of vm contexts.

- Remove the Atomics.wake deletion as V8 now does not install it
  anymore.
- Move the Intl.v8BreakIterator deletion into the snapshot.
- Do not query the Object prototype if --disable-proto is not set.

This should speed up the creation of vm contexts by about ~12%.

PR-URL: https://github.com/nodejs/node/pull/44252
Refs: https://github.com/nodejs/node/issues/44014
Refs: https://github.com/nodejs/node/issues/37476
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2022-08-24 00:04:56 +08:00
Joyee Cheung ec91776ee0 vm: include vm context in the embedded snapshot
Include a minimally initialized contextify context in the embedded
snapshot. This paves the way for user-land vm context snapshots.

PR-URL: https://github.com/nodejs/node/pull/44252
Refs: https://github.com/nodejs/node/issues/44014
Refs: https://github.com/nodejs/node/issues/37476
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2022-08-24 00:04:54 +08:00
Joyee Cheung cfd25e0c74 vm: make ContextifyContext template context-independent
Instead of creating an object template for every ContextifyContext,
we now create one object template that can be reused by all
contexts. The native pointer can be obtained through an embdder
pointer field in the creation context of the receiver in the
interceptors, because the interceptors are only meant to be invoked
on the global object of the contextified contexts. This makes
the ContextifyContext template context-independent and therefore
snapshotable.

PR-URL: https://github.com/nodejs/node/pull/44252
Refs: https://github.com/nodejs/node/issues/44014
Refs: https://github.com/nodejs/node/issues/37476
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2022-08-24 00:04:52 +08:00
Tobias Nießen fcd31c5110 src: fix multiple format string bugs
The THROW_ERR_* functions interpret the first argument as a printf-like
format string, which is problematic when it contains unsanitized user
input. This typically happens when a printf-like function is used to
produce the error message, which is then passed to a THROW_ERR_*
function, which again interprets the error message as a format string.

Fix such occurrences by properly formatting error messages using static
format strings only, and in a single step.

PR-URL: https://github.com/nodejs/node/pull/44314
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2022-08-22 22:03:36 +00:00
Tobias Nießen a5671e2662 crypto: improve RSA-PSS digest error messages
md and mgf1_md are internal variable names and should not appear in
JS error messages. Also include the invalid digest name in the error
message.

PR-URL: https://github.com/nodejs/node/pull/44307
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2022-08-22 15:18:30 +00:00
Tobias Nießen 4cf4c1f585 src: make minor improvements to SecureBuffer
Remove an unnecessary static_cast<char*>().

Use OPENSSL_secure_zalloc() instead of OPENSSL_secure_malloc() +
memset().

Update the comment describing the function which predates support for
OpenSSL's secure heap.

PR-URL: https://github.com/nodejs/node/pull/44302
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2022-08-22 13:58:52 +00:00
Tobias Nießen 66e4d7a097 tls: remove SecureContext setFreeListLength
This function was introduced in 2684c902c4
as an internal helper function. The C++ implementation became a no-op in
a57e2f2138 when building against OpenSSL
1.1.0 (instead of OpenSSL 1.0.2), and eventually became a no-op in all
supported OpenSSL versions in 970ce14f61.
Finally, eb20447407 removed the only call
site of setFreeListLength (which was already a no-op at that point).

Refs: https://github.com/nodejs/node/pull/1529
Refs: https://github.com/nodejs/node/pull/10859
Refs: https://github.com/nodejs/node/pull/19794
Refs: https://github.com/nodejs/node/pull/38116
PR-URL: https://github.com/nodejs/node/pull/44300
Reviewed-By: Feng Yu <F3n67u@outlook.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2022-08-22 13:45:58 +00:00
Tobias Nießen 1fa2277fb2 tls: use OpenSSL constant for client random size
Avoid magic numbers in the code and use an OpenSSL constant instead.

PR-URL: https://github.com/nodejs/node/pull/44305
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
2022-08-22 13:45:38 +00:00
Juan José 7aa3c384cf src: use imported namespaces in node_contextify.cc
PR-URL: https://github.com/nodejs/node/pull/44299
Reviewed-By: Feng Yu <F3n67u@outlook.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2022-08-21 08:53:42 +00:00
Tobias Nießen 705fefd30d src: refactor to avoid using a moved object
KeyPairGenTraits::EncodeKey should not use an object that it previously
moved. Make ManagedEVPPKey::ToEncoded(Public|Private)Key non-static
members of ManagedEVPPKey and call them on the key object instead.

PR-URL: https://github.com/nodejs/node/pull/44269
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Feng Yu <F3n67u@outlook.com>
2022-08-20 12:15:42 +00:00
legendecas 466710c298 report: print javascript stack on fatal error
Try to print JavaScript stack on fatal error. OOMError needs to be
distinguished from fatal error since no new handle can be created at
that time.

PR-URL: https://github.com/nodejs/node/pull/44242
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
2022-08-20 12:34:34 +08:00
Chengzhong Wu 5e57d24d32 src: extract common context embedder tag checks
Extract common context embedder tag checks to ContextEmbedderTag so
that verifying if a context is a node context doesn't need to access
private members of node::Environment.

PR-URL: https://github.com/nodejs/node/pull/44258
Refs: https://github.com/nodejs/node/pull/44179
Refs: https://github.com/nodejs/node/pull/44252
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
2022-08-19 14:44:28 +08:00
Joyee Cheung d70aab663c src: support WeakReference in snapshot
Move util::WeakReference to a separate header and implement
{de}serialization for it to be snapshotable.

PR-URL: https://github.com/nodejs/node/pull/44193
Refs: https://github.com/nodejs/node/issues/44014
Refs: https://github.com/nodejs/node/issues/37476
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2022-08-19 12:53:29 +08:00
Tobias Nießen a2dcc08a9c src: avoid copying BaseObjectPtrs in loop
While copying BaseObjectPtrs is cheap, it is not a no-op, so it is best
to iterate over references to BaseObjectPtrs only.

PR-URL: https://github.com/nodejs/node/pull/44270
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2022-08-18 19:22:47 +00:00
theanarkh 97e8bda5b2 dgram: add dgram send queue info
PR-URL: https://github.com/nodejs/node/pull/44149
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2022-08-17 16:08:58 +00:00
Chengzhong Wu 678551c294 report: skip report if uncaught exception is handled
If the exception is handled by the userland
process#uncaughtException handler, reports should not be generated
repetitively as the process may continue to run.

PR-URL: https://github.com/nodejs/node/pull/44208
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
2022-08-16 21:04:48 +08:00
Chengzhong Wu eefe553026 src: remove usage on ScriptCompiler::CompileFunctionInContext
V8 APIs like HostImportModuleDynamicallyCallback and
ScriptCompiler::CompileFunction is moving away from ScriptOrModule.

Replaces ScriptCompiler::CompileFunctionInContext with
ScriptCompiler::CompileFunction to remove the usages on the optional
out param ScriptOrModule.

PR-URL: https://github.com/nodejs/node/pull/44198
Fixes: https://github.com/nodejs/node-v8/issues/214
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2022-08-16 01:38:33 +08:00
Chengzhong Wu 76cdef15cd src: fix --heapsnapshot-near-heap-limit error hint
PR-URL: https://github.com/nodejs/node/pull/44216
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
2022-08-14 02:17:28 +00:00
Tobias Nießen 77def91bf9 tls,http2: send fatal alert on ALPN mismatch
To comply with RFC 7301, make TLS servers send a fatal alert during the
TLS handshake if both the client and the server are configured to use
ALPN and if the server does not support any of the protocols advertised
by the client.

This affects HTTP/2 servers. Until now, applications could intercept the
'unknownProtocol' event when the client either did not advertise any
protocols or if the list of protocols advertised by the client did not
include HTTP/2 (or HTTP/1.1 if allowHTTP1 was true). With this change,
only the first case can be handled, and the 'unknownProtocol' event will
not be emitted in the second case because the TLS handshake fails and no
secure connection is established.

PR-URL: https://github.com/nodejs/node/pull/44031
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2022-08-13 07:25:23 +00:00
Filip Skokan 159b4d7a94 crypto: allow zero-length IKM in HKDF and in webcrypto PBKDF2
PR-URL: https://github.com/nodejs/node/pull/44201
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2022-08-12 21:36:29 +02:00
Filip Skokan 85107bdd66 crypto: allow zero-length secret KeyObject
PR-URL: https://github.com/nodejs/node/pull/44201
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2022-08-12 21:36:27 +02:00
Joyee Cheung 4ca398a617 src: iterate over base objects to prepare for snapshot
Instead of iterating over the bindings, iterate over the base
objects that are snapshottable. This allows us to snapshot
base objects that are not bindings. In addition this refactors
the InternalFieldInfo class to eliminate potential undefined
behaviors, and renames it to InternalFieldInfoBase.
The {de}serialize callbacks now expect a InternalFieldInfo struct
nested in Snapshotable classes that can be used to carry
serialization data around. This allows us to create structs
inheriting from InternalFieldInfo for Snapshotable objects
that need custom fields.

PR-URL: https://github.com/nodejs/node/pull/44192
Refs: https://github.com/nodejs/node/issues/37476
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2022-08-12 07:39:39 +00:00
Moshe Atlow 8f9d1ab5ec assert: add assert.Snapshot
PR-URL: https://github.com/nodejs/node/pull/44095
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2022-08-11 13:07:52 +00:00
theanarkh eb7f22a6b4 perf_hooks: fix gc elapsed time
PR-URL: https://github.com/nodejs/node/pull/44058
Refs: https://github.com/nodejs/node/issues/44046
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2022-08-10 16:44:05 +00:00
Joyee Cheung 5291096ca2 bootstrap: check more metadata when loading the snapshot
This patch stores the metadata about the Node.js binary
into the SnapshotData and adds fields denoting how the
snapshot was generated, on what platform it was
generated as well as the V8 cached data version flag.
Instead of simply crashing when the metadata doesn't
match, Node.js now prints an error message and exit with
1 for the customized snapshot, or ignore the snapshot
and start from scratch if it's the default one.

PR-URL: https://github.com/nodejs/node/pull/44132
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2022-08-09 18:01:02 +00:00
Shelley VohrandJoyee Cheung 8b0e5b19bd src: fix cppgc incompatibility in v8
This patch updates the layout of the BaseObjects to make sure
that the first embedder field of them is a "type" pointer, the
first 16 bits of which are the Node.js embedder ID, so that
cppgc will always skip over them. In addition we now use this
field to determine if the native object should be interpreted
as a Node.js embedder object in the serialization and deserialization
callbacks for the startup snapshot to improve the reliability.

Co-authored-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/43521
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
2022-08-09 16:47:43 +08:00