-
Trying to understand
|
| inBundle | inDepBundle | Scripts run at install? | Visible in ls? | |
|---|---|---|---|---|
| Normal dep | false | false | yes | ✅ yes |
| Root bundle | true | false | yes | ❌ no — bug? |
| Dep bundle | true | true | no | ✅ no |
If the intent of the inBundle check is to exclude packages whose scripts
already ran at publish time (Case C only), then inDepBundle seems like the
right guard — it is already false for root-bundled packages. The inDepBundle
comment in node.js already notes this distinction:
"if a package is technically in a bundleDependencies list, but that list is
the root project, we still have to install it."
Questions
-
Is there a reason
inBundle(rather thaninDepBundle) is used here? Is
there a scenario I'm not thinking of where a root-bundled package's scripts
genuinely don't run at install time? -
If the intent is only to exclude packages pre-built inside a dep's tarball,
wouldinDepBundlebe the right check? -
Same question for the candidate list in
runPruneinallow-scripts-cmd.js
— it also usesinBundleto skip nodes, which I think would prevent stale
allowScriptsentries for root-bundled packages from ever being pruned.
Happy to be wrong here — I just wanted to make sure I wasn't misreading the
intent before assuming it's a gap.
References
inDepBundledefined:workspaces/arborist/lib/node.jslines 573–579isScriptAllowedguard:workspaces/arborist/lib/script-allowed.jscollectUnreviewedScripts:workspaces/arborist/lib/unreviewed-scripts.js- Related PRs: feat: namespace install-script approval commands under npm install-scripts npm/cli#9629 (install-scripts namespace), fix(allowScripts): close three enforcement gaps npm/cli#9652 (enforcement gaps)
- issue created [BUG] InBundle vs InDepBundle in approve scripts functionality npm/cli#9679
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
|
Your reasoning seems sound to me. The distinction appears to be that For Your smoke test is useful here because it demonstrates the behavioral difference rather than only arguing semantics. Curious whether the current behavior is intentional or just inherited from broader bundle handling. |
Beta Was this translation helpful? Give feedback.
-
|
Confirm the technical read is right (because [Likely] it is, based on the code excerpts and test output shown) — state plainly that inBundle conflates two cases with different security postures, and inDepBundle is the correct guard if the intent is "exclude packages whose scripts already ran at publish time." Rest!! |
Beta Was this translation helpful? Give feedback.
-
|
You've done excellent analysis here — this is definitely a bug. You're exactly right about the distinction: Case inBundle inDepBundle Scripts run? Current behavior The guard if (node.inBundle) return null is too broad — it treats root-bundled packages (where the root project lists something in bundleDependencies) the same as dependency-bundled packages (where a published tarball already ran scripts at publish time). The fix should be inDepBundle instead of inBundle — your test patch confirms this. The comment in node.js even says root-bundled packages "still have to install it," so the current behavior contradicts that. Some additional context: · In a root-bundled scenario, npm pack includes the dep, but npm install still fetches it from the registry during development — scripts run. |
Beta Was this translation helpful? Give feedback.
You've done excellent analysis here — this is definitely a bug.
You're exactly right about the distinction:
Case inBundle inDepBundle Scripts run? Current behavior
Normal dep false false ✅ Yes ✅ Visible
Root-bundled true false ✅ Yes ❌ Hidden (bug)
Dep-bundled true true ❌ No ✅ Hidden (correct)
The guard if (node.inBundle) return null is too broad — it treats root-bundled packages (where the root project lists something in bundleDependencies) the same as dependency-bundled packages (where a published tarball already ran scripts at publish time).
The fix should be inDepBundle instead of inBundle — your test patch confirms this. The comment in node.js even says root-bundled packages "still ha…