-
Notifications
You must be signed in to change notification settings - Fork 11.9k
feat(@angular-devkit/schematics): disable package script execution by default in NodePackageInstallTask
#23059
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
Conversation
bd01053
to
1a75404
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: nice-napi
in the commit message.
Is there anything we should consider doing to make sure future changes to transitive dependencies don't introduce something which requires a postinstall?
packages/angular_devkit/schematics/tasks/package-manager/install-task.ts
Outdated
Show resolved
Hide resolved
@twerske / @MarkTechson - I wonder if this would be worth mentioning the v14 blog post / release announcement as one way we're improving security for Angular applications? |
1a75404
to
da61a2b
Compare
… default in `NodePackageInstallTask` In an effort to improve supply chain security, the `NodePackageInstallTask` will now use the package manager's `--ignore-scripts` option by default. Without the option, all direct and transitive dependencies would have their scripts executed during the task's package manager installation operation. The change only affects the package manager behavior controlled by the Schematics `NodePackageInstallTask`. First-party Angular schematics do not currently require any direct or transitive dependency `install`/`postinstall` scripts to execute. Only two dependencies within a v14.0 new project would potentially be affected by this: `nice-napi` (transitive from `piscina`) and `esbuild`. The `nice-napi` functionality of `piscina` is unused within the Angular CLI with no plans to use it in the future. Even if it was used, the `install` script runs `node-gyp-build` which would only have an effect (based on the current version 1.0.2) on platforms that are not Windows, darwin-x64, or linux-x64. In the event this functionality is eventually used, the Angular CLI could be setup to automatically execute this particular script for unsupported platforms. For `esbuild`, the `postinstall` functionality performs an optional native binary bootstrap optimization but would only be performed if not using Windows or Yarn. As such, it would not be performed for many users regardless of the change in this commit. If noticeable performance regressions on platforms where the optimization was previously performed are reported, the script could also be setup to be automatically run by the Angular CLI during project creation and/or first build. BREAKING CHANGE: Schematics `NodePackageInstallTask` will not execute package scripts by default The `NodePackageInstallTask` will now use the package manager's `--ignore-scripts` option by default. The `--ignore-scripts` option will prevent package scripts from executing automatically during an install. If a schematic installs packages that need their `install`/`postinstall` scripts to be executed, the `NodePackageInstallTask` now contains an `allowScripts` boolean option which can be enabled to provide the previous behavior for that individual task. As with previous behavior, the `allowScripts` option will prevent the individual task's usage of the `--ignore-scripts` option but will not override the package manager's existing configuration.
da61a2b
to
3378942
Compare
Added a new E2E test that checks for install scripts within a new project's dependencies and fails if any unexpected packages are detected. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
In an effort to improve supply chain security, the
NodePackageInstallTask
will now use the packagemanager's
--ignore-scripts
option by default. Without the option, all direct and transitivedependencies would have their scripts executed during the task's package manager installation operation.
The change only affects the package manager behavior controlled by the Schematics
NodePackageInstallTask
.First-party Angular schematics do not currently require any direct or transitive dependency
install
/postinstall
scripts to execute. Only two dependencies within a v14.0 new project wouldpotentially be affected by this:
nice-napi
(transitive frompiscina
) andesbuild
. Thenice-napi
functionality of
piscina
is unused within the Angular CLI with no plans to use it in the future.Even if it was used, the
install
script runsnode-gyp-build
which would only have an effect(based on the current version 1.0.2) on platforms that are not Windows, darwin-x64, or linux-x64.
In the event this functionality is eventually used, the Angular CLI could be setup to automatically execute
this particular script for unsupported platforms. For
esbuild
, thepostinstall
functionalityperforms an optional native binary bootstrap optimization but would only be performed if not
using Windows or Yarn. As such, it would not be performed for many users regardless of the change in
this commit. If noticeable performance regressions on platforms where the optimization was previously
performed are reported, the script could also be setup to be automatically run by the Angular CLI during
project creation and/or first build.
BREAKING CHANGE: Schematics
NodePackageInstallTask
will not execute package scripts by defaultThe
NodePackageInstallTask
will now use the package manager's--ignore-scripts
option by default.The
--ignore-scripts
option will prevent package scripts from executing automatically during an install.If a schematic installs packages that need their
install
/postinstall
scripts to be executed, theNodePackageInstallTask
now contains anallowScripts
boolean option which can be enabled to provide theprevious behavior for that individual task. As with previous behavior, the
allowScripts
option willprevent the individual task's usage of the
--ignore-scripts
option but will not override the packagemanager's existing configuration.