child_process: validate strings in exec and spawn#56148
Conversation
358bd79 to
40a0a9f
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #56148 +/- ##
==========================================
+ Coverage 87.99% 90.16% +2.17%
==========================================
Files 656 630 -26
Lines 188999 186467 -2532
Branches 35981 36616 +635
==========================================
+ Hits 166301 168131 +1830
+ Misses 15865 11125 -4740
- Partials 6833 7211 +378
🚀 New features to boost your workflow:
|
aduh95
left a comment
There was a problem hiding this comment.
Can you please remove all the unrelated changes? It makes the PR hard to review. Please only include changes that are necessary to make the added test pass, and all the other changes should be made in a separate PR.
40a0a9f to
18ddc47
Compare
18ddc47 to
6d02bc8
Compare
6d02bc8 to
0a84382
Compare
aduh95
left a comment
There was a problem hiding this comment.
It looks like the added test pass on main, meaning either the change in lib/ is only a refactor, or we are not adding sufficient coverage to avoid regression.
it was mainly refactoring because, for example, when calling |
I don't think it's the right approach, we should optimize for the happy path, where there are no error thrown. IIUC, with this change we would be checking twice if the arguments are valid, so in order to save some cycles we should not land this. |
0a84382 to
a3b5b1a
Compare
gotcha. I went in that direction because I noticed that was the case already. With the latest push all the validation is done down the line and only once |
|
The added tests are passing on latest |
a3b5b1a to
80fcad1
Compare
|
The commit message of 80fcad1 should say it's a refactor, e.g. The commit message of 2f43432 should be using IMO the order of commits should be reversed, tests should land first. |
2f43432 to
c07b9d8
Compare
c07b9d8 to
52c7bb1
Compare
|
Is anything else needed here? |
This comment was marked as outdated.
This comment was marked as outdated.
|
can I please request a rerun of the pipeline? |
|
anything else needed here? |
BridgeAR
left a comment
There was a problem hiding this comment.
LGTM with the only the two obsolete validations removed.
| function validateStringParam(param, paramName) { | ||
| validateString(param, paramName); | ||
| validateArgumentNullCheck(param, paramName); | ||
|
|
||
| if (param.length === 0) { | ||
| throw new ERR_INVALID_ARG_VALUE(paramName, param, 'cannot be empty'); | ||
| } | ||
| } | ||
|
|
||
| if (file.length === 0) | ||
| throw new ERR_INVALID_ARG_VALUE('file', file, 'cannot be empty'); | ||
| function normalizeSpawnArguments(file, args, options) { | ||
| validateStringParam(file, 'file'); |
There was a problem hiding this comment.
If we keep the changes as before, the compiler has to do less inlining.
| function validateStringParam(param, paramName) { | |
| validateString(param, paramName); | |
| validateArgumentNullCheck(param, paramName); | |
| if (param.length === 0) { | |
| throw new ERR_INVALID_ARG_VALUE(paramName, param, 'cannot be empty'); | |
| } | |
| } | |
| if (file.length === 0) | |
| throw new ERR_INVALID_ARG_VALUE('file', file, 'cannot be empty'); | |
| function normalizeSpawnArguments(file, args, options) { | |
| validateStringParam(file, 'file'); | |
| function normalizeSpawnArguments(file, args, options) { | |
| validateString(file, 'file'); | |
| validateArgumentNullCheck(file, 'file'); | |
| if (file.length === 0) { | |
| throw new ERR_INVALID_ARG_VALUE(file, 'file', 'cannot be empty'); | |
| } |
446cf6a to
b6fcf31
Compare
| if (file.length === 0) | ||
| throw new ERR_INVALID_ARG_VALUE('file', file, 'cannot be empty'); | ||
| if (file.length === 0) { | ||
| throw new ERR_INVALID_ARG_VALUE(file, 'file', 'cannot be empty'); |
There was a problem hiding this comment.
| throw new ERR_INVALID_ARG_VALUE(file, 'file', 'cannot be empty'); | |
| throw new ERR_INVALID_ARG_VALUE('file', file, 'cannot be empty'); |
b6fcf31 to
e67638f
Compare
Failed to start CI- Validating Jenkins credentials ✔ Jenkins credentials valid - Querying data for job/node-test-pull-request/64998/ [SyntaxError: Unexpected token '<', ..." https://github.com/nodejs/node/actions/runs/26104004427 |
I went through the
exec,execFile,spawn,execSync,execFileSyncandspawnSyncfunctions inchild_processand edited all the functions to properly validate their string parameters