Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jazelly
Copy link
Member

@jazelly jazelly commented Jan 16, 2025

Fixes: #56531

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. child_process Issues and PRs related to the child_process subsystem. needs-ci PRs that need a full CI run. labels Jan 16, 2025
Copy link

codecov bot commented Jan 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.20%. Comparing base (9230f22) to head (8e27135).
Report is 39 commits behind head on main.

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     
Files with missing lines Coverage Δ
lib/internal/child_process.js 94.99% <100.00%> (+0.01%) ⬆️
src/process_wrap.cc 84.57% <100.00%> (+0.25%) ⬆️

... and 70 files with indirect coverage changes

@@ -427,6 +427,9 @@ ChildProcess.prototype.spawn = function(options) {

for (i = 0; i < stdio.length; i++) {
const stream = stdio[i];
if (stream == null) {
Copy link
Contributor

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 =
Copy link
Contributor

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");
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. child_process Issues and PRs related to the child_process subsystem. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FATAL ERROR: v8::ToLocalChecked Empty MaybeLocal
3 participants