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

esm: fix loader hooks accepting too many arguments #44109

Conversation

JakobJingleheimer
Copy link
Contributor

@JakobJingleheimer JakobJingleheimer commented Aug 2, 2022

When a user supplies too many arguments, those beyond the 2nd arg are currently blindly passed to the next<HookName> function. Now, those extra args are ignored. It assumes both resolve and load share the same number of args—which they currently do; if that changes, this will need to be updated.

Fixes #44108

@JakobJingleheimer JakobJingleheimer added the loaders Issues and PRs related to ES module loaders label Aug 2, 2022
@nodejs-github-bot
Copy link
Collaborator

nodejs-github-bot commented Aug 2, 2022

Review requested:

cc @targos

@nodejs-github-bot nodejs-github-bot added esm Issues and PRs related to the ECMAScript Modules implementation. needs-ci PRs that need a full CI run. labels Aug 2, 2022
Copy link

@cspotcode cspotcode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Github won't let me mark this review as "Approve" so I submitted it as "Comment" instead. I asked a question but it's not a blocker.

lib/internal/modules/esm/loader.js Outdated Show resolved Hide resolved
@cspotcode
Copy link

It assumes both resolve and load share the same number of args—which they currently do; if that changes, this will need to be updated.

Noting for completeness: the code before this pull request also assumed 2 args, so this PR is not introducing an additional limitation or restriction; it was already like that. The switch-case did not check if args.length >= 2; it checked args.length === 2

lib/internal/modules/esm/loader.js Outdated Show resolved Hide resolved
lib/internal/modules/esm/loader.js Outdated Show resolved Hide resolved
account for prototype pollution in Array & Object
lib/internal/modules/esm/loader.js Outdated Show resolved Hide resolved
lib/internal/modules/esm/loader.js Outdated Show resolved Hide resolved
lib/internal/modules/esm/loader.js Outdated Show resolved Hide resolved
@aduh95 aduh95 added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels Aug 3, 2022
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 3, 2022
@nodejs-github-bot
Copy link
Collaborator

@JakobJingleheimer JakobJingleheimer added the request-ci Add this label to start a Jenkins CI on a PR. label Aug 3, 2022
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 3, 2022
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@JakobJingleheimer JakobJingleheimer added the commit-queue Add this label to land a pull request using GitHub Actions. label Aug 4, 2022
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Aug 4, 2022
@nodejs-github-bot
Copy link
Collaborator

Commit Queue failed
- Loading data for nodejs/node/pull/44109
✔  Done loading data for nodejs/node/pull/44109
----------------------------------- PR info ------------------------------------
Title      esm: fix loader hooks accepting too many arguments (#44109)
   ⚠  Could not retrieve the email or name of the PR author's from user's GitHub profile!
Branch     JakobJingleheimer:fix/esm-loader-accepts-too-many-args -> nodejs:main
Labels     esm, needs-ci, loaders, commit-queue-squash
Commits    7
 - esm: fix loader hooks accepting too many arguments
 - fixup! esm: fix loader hooks accepting too many arguments
 - fixup! fixup! esm: fix loader hooks accepting too many arguments
 - fixup! fixup! fixup! esm: fix loader hooks accepting too many arguments
 - fixup! fixup! fixup! fixup! esm: fix loader hooks accepting too many …
 - improve substring match
 - correct context arg passed to nextHook fn
Committers 1
 - Jacob Smith <[email protected]>
PR-URL: https://github.com/nodejs/node/pull/44109
Reviewed-By: Geoffrey Booth 
Reviewed-By: Guy Bedford 
Reviewed-By: Antoine du Hamel 
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/44109
Reviewed-By: Geoffrey Booth 
Reviewed-By: Guy Bedford 
Reviewed-By: Antoine du Hamel 
--------------------------------------------------------------------------------
   ℹ  This PR was created on Tue, 02 Aug 2022 20:24:18 GMT
   ✔  Approvals: 3
   ✔  - Geoffrey Booth (@GeoffreyBooth) (TSC): https://github.com/nodejs/node/pull/44109#pullrequestreview-1061107695
   ✔  - Guy Bedford (@guybedford): https://github.com/nodejs/node/pull/44109#pullrequestreview-1059598743
   ✔  - Antoine du Hamel (@aduh95) (TSC): https://github.com/nodejs/node/pull/44109#pullrequestreview-1060885869
   ✖  This PR needs to wait 11 more hours to land
   ✔  Last GitHub CI successful
   ℹ  Last Full PR CI on 2022-08-04T05:28:44Z: https://ci.nodejs.org/job/node-test-pull-request/45830/
- Querying data for job/node-test-pull-request/45830/
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  Aborted `git node land` session in /home/runner/work/node/node/.ncu
https://github.com/nodejs/node/actions/runs/2795302869

@nodejs-github-bot nodejs-github-bot added the commit-queue-failed An error occurred while landing this pull request using GitHub Actions. label Aug 4, 2022
@JakobJingleheimer
Copy link
Contributor Author

✖ This PR needs to wait 11 more hours to land

Grr

@MoLow MoLow added commit-queue Add this label to land a pull request using GitHub Actions. and removed commit-queue-failed An error occurred while landing this pull request using GitHub Actions. labels Aug 4, 2022
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Aug 4, 2022
@nodejs-github-bot nodejs-github-bot merged commit e0b440a into nodejs:main Aug 4, 2022
@nodejs-github-bot
Copy link
Collaborator

Landed in e0b440a

targos pushed a commit that referenced this pull request Aug 6, 2022
PR-URL: #44109
Reviewed-By: Geoffrey Booth <[email protected]>
Reviewed-By: Guy Bedford <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
danielleadams pushed a commit that referenced this pull request Aug 16, 2022
PR-URL: #44109
Reviewed-By: Geoffrey Booth <[email protected]>
Reviewed-By: Guy Bedford <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
ruyadorno pushed a commit that referenced this pull request Aug 23, 2022
PR-URL: #44109
Reviewed-By: Geoffrey Booth <[email protected]>
Reviewed-By: Guy Bedford <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Fyko pushed a commit to Fyko/node that referenced this pull request Sep 15, 2022
PR-URL: nodejs#44109
Reviewed-By: Geoffrey Booth <[email protected]>
Reviewed-By: Guy Bedford <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
guangwong pushed a commit to noslate-project/node that referenced this pull request Oct 10, 2022
PR-URL: nodejs/node#44109
Reviewed-By: Geoffrey Booth <[email protected]>
Reviewed-By: Guy Bedford <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. esm Issues and PRs related to the ECMAScript Modules implementation. loaders Issues and PRs related to ES module loaders needs-ci PRs that need a full CI run.
Projects
None yet
7 participants