Repository navigation
Honor install-script policy in custom component commands - #2572
Conversation
Apply npm's ignore-scripts configuration to custom component install commands when scripts are disallowed, and let install_node_modules pass its explicit policy through the shared argument builder without changing its historical default. Co-Authored-By: GPT-5 Codex <noreply@openai.com>
Release cherry-pick
|
There was a problem hiding this comment.
Code Review
This pull request implements a lifecycle-script policy (install_allow_scripts / allowInstallScripts) to control the execution of package lifecycle scripts during automatic installations and custom install commands. When disabled, it appends --ignore-scripts or sets the npm_config_ignore_scripts=true environment variable. Feedback is provided to extract the environment manipulation logic in the application install tests into a helper function, consistent with the helper already defined in the utility tests, to reduce code duplication.
|
Reviewed; no blockers found. |
Keep v5.2's automatic install paths and legacy npm arguments while applying #2572's custom-command and deprecated-operation lifecycle script policy. Consume converted policy values locally, adapt the copied tests to release semantics, and keep the design record in the release branch's root document. Co-Authored-By: GPT-5 Codex <noreply@openai.com> Dispatch-Task: cherry-resolve-kriszyp_harper_2572-910d0d15
Custom component install commands now pass Harper's lifecycle-script policy into their spawn, and the deprecated
install_node_modulesoperation now passes its validated policy through the shared npm argument builder instead of bypassing it. Custom commands preserve their exact command line, whileinstall_node_modulesretains its historical scripts-enabled default unless the caller opts out.For the human reviewer
Secure default for existing custom commands. Omitted
install_allow_scriptsnow suppresses lifecycle hooks immediately, matching the existing automatic-install policy; the alternative was to preserve legacy custom-command behavior until an explicitfalse. This can break a cold install that previously relied on native-module or generation scripts, so the implementation emits a server warning naming both opt-in spellings; the warning is not streamed to the deploy caller. A “no” means changing the condition to enforce only explicitfalseand staging the secure default for a later release.Best-effort enforcement for arbitrary commands. The child-scoped
npm_config_ignore_scripts=trueapproach was chosen after planning review rejected appending--ignore-scripts, which fails for shell chains and corrupts non-npm argv. It reaches npm anywhere in the configured shell command, but npm 10 can still run a git dependency'sprepare, and other package managers vary in whether they consume npm-style configuration; this is the boundary to inspect most closely. A “no” requires a broader design that restricts or parses arbitrary commands; that is outside this issue's instruction to leave the already-equivalent automatic paths unchanged.Host policy remains authoritative. Explicit
trueremoves Harper's restriction but does not clear an inheritednpm_config_ignore_scripts=true, matching the existing automatic paths and preserving current infrastructure hardening. The alternative is to force scripts on whenever an application opts in; changing this later is mechanically small but reverses configuration precedence.Deprecated-operation compatibility.
install_node_moduleskeeps its historical scripts-enabled default, as required by the acceptance criteria, rather than inheriting each component's safer deploy default. The new validation switch accepts camelCase to match the root configuration vocabulary and snake_case to match the operations API; a request carrying both is rejected rather than resolved ambiguously.Changes
components/Application.tsthreads a dedicated lifecycle-policy flag throughnonInteractiveSpawn, scrubs case variants before setting the child-only npm configuration, and warns when a custom command relies on the new secure default.utility/npmUtilities.tsreads the converted request field and passes it through the shared npm argument builder instead of hard-coding scripts on.DESIGN.mdrecords the operation spellings and compatibility default plus the environment propagation, package-manager caveats and migration warning.Verification
installApplication()andinstallModules()paths spawn real npm against localfile:dependencies whose lifecycle scripts write filesystem markers.npx mocha unitTests/components/applicationInstall.test.js unitTests/utility/npmUtilities.test.jsreports 18 passing; the custom-command suite proves unchanged argv plus undefined/false/true marker and warning behavior, while the deprecated-operation suite proves omitted/true behavior, false suppression, both spellings and conflict rejection.npm run buildpasses, changed-file Prettier and oxlint checks pass, andgit diff --checkis clean.npm run test:unit:windowspasses all 9 groups and 3,732 tests.npm run test:unit:resourcesreports 2,358 passing / 32 pending.npm run test:unit:mainreports 5,468 passing / 196 pending plus two unrelated environment failures: ambient fleet git variables ingitCredentials.test.jsand a worktree-depth Unix-socket path inconfigValidator.test.js.npm run test:integration:allreaches 2,081 passing, 0 assertion failures, 20 skipped and 6 cancelled; the runner exits nonzero on Node 26's existing missing JSON import attribute inollama-backend.test.ts. The component lifecycle integration suite passes.npm run lintremains red on 13 warnings in unrelated files; targeted lint over every changed source and test file passes.Refs #1978
Complexity: medium
Generated by GPT-5 Codex.
Review-Coverage: authored=codex; ran=gemini,claude; adjudicated=domain; declined=cursor-grok,cursor-composer; rounds=4 @ 7f0d5a0
Human-Review-Need: 4 (decisions: default-deny-existing-custom-installs, host-policy-precedence, arbitrary-command-enforcement, deprecated-operation-default) @ 7f0d5a0