-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
package_managers: yarn: Refuse projects using zero-install workflow
The concept of zero installs, i.e. no install needed (git clone is sufficient), is inherently flawed for a number of reasons: - taking over maintenance (by the means of manual updates) of a project's dependencies by baking their sources in to the given project's repository - creating unnecessary bloat (often in form of binary formats) in the repository - moving the trust in package contents from the official packaging tooling and official public registries to a given project which doesn't really solve the biggest security problem of many public packaging repositories - unvetted contents just to mention a few. In context of Yarn what the above would mean is checking in dependencies' ZIP files into the repository. While that may sound like an acceptable use case since Yarn can verify integrity of the ZIP archives, some dependencies (due to e.g. post-install scripts) may end up being unpacked into a .yarn/unplugged directory, effectively creating an exploded node_modules/ dependency tree hierarchy inside the repository which would be needed for the zero install use case to work. However, we would have to employ a complex methodology (still preventing arbitrary code execution) of reliably verifying such dependencies in order to produce an accurate SBOM. Since we already reject projects containing 'node_modules' directory inside the repository for NPM, we can use it as a precedent here. The whole situation would be different if Yarn provided a mechanism to verify integrity of 'unplugged' contents the same way it does it for ZIP files, but unfortunately it doesn't [1]. As a result of this patch some test variants involving the zero-install use case which no longer applies have been adjusted accordingly and dedicated test cases dealing with zero installs were added. [1] Even if one sets the 'immutablePatterns' [2] YarnRc configuration option to something like '**/.yarn/unplugged/**' Yarn doesn't seem to care about the glob pattern unless the whole .yarn/unplugged/<unzipped_package>/node_modules/<package> subdirectory of a given unplugged package tree would end up being removed in which case Yarn finally notices and throws a immutable cache error: The checksum for **/.yarn/unplugged/**/* has been modified by this install, which is explicitly forbidden [2] https://v3.yarnpkg.com/configuration/yarnrc#immutablePatterns Signed-off-by: Erik Skultety <[email protected]>
- Loading branch information
Showing
3 changed files
with
69 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters