-
Notifications
You must be signed in to change notification settings - Fork 30.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
src: check process wrap type emptiness in ParseStdioOptions #56625
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Jake Yuesong Li <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #56625 +/- ##
==========================================
+ Coverage 89.17% 89.20% +0.03%
==========================================
Files 662 662
Lines 191761 191896 +135
Branches 36905 36935 +30
==========================================
+ Hits 171006 171185 +179
+ Misses 13620 13559 -61
- Partials 7135 7152 +17
|
@@ -427,6 +427,9 @@ ChildProcess.prototype.spawn = function(options) { | |||
|
|||
for (i = 0; i < stdio.length; i++) { | |||
const stream = stdio[i]; | |||
if (stream == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a lot of input validation in lib/child_process.js
already. Can that be updated to handle this case instead of handling it here and in the binding layer?
@@ -122,8 +122,12 @@ class ProcessWrap : public HandleWrap { | |||
for (uint32_t i = 0; i < len; i++) { | |||
Local<Object> stdio = | |||
stdios->Get(context, i).ToLocalChecked().As<Object>(); | |||
Local<Value> type = | |||
stdio->Get(context, env->type_string()).ToLocalChecked(); | |||
v8::MaybeLocal<Value> maybe_type = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that we need to change the binding layer to fix this. If we do, it's good to get rid of ToLocalChecked()
usage, but can you add using v8::MaybeLocal
to the top of the file and drop the v8::
here.
v8::MaybeLocal<Value> maybe_type = | ||
stdio->Get(context, env->type_string()); | ||
if (maybe_type.IsEmpty()) { | ||
return env->ThrowTypeError("Not a valid JS type"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we would want to use one of the errors from https://nodejs.org/api/errors.html here.
Fixes: #56531