Skip to content

Commit 7fccd4b

Browse files
authored
chore: Add approvedGitRepositories to Yarn config (#8672)
## Explanation Yarn recently added an `approvedGitRepositories` setting which is an allowlist for allowed Git repositories that can be installed as dependencies. Git repositories have some security risks, and we don't typically use them, so we can set it to an empty array to disallow Git repositories. ## References MetaMask/metamask-module-template#310. ## Checklist - [ ] I've updated the test suite for new or updated code as appropriate - [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [ ] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md) - [ ] I've introduced [breaking changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md) in this PR and have prepared draft pull requests for clients and consumer packages to resolve them <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Low risk: config-only changes that tighten dependency policy and bump the Yarn toolchain; main impact is potential install/CI breakage if any Git-based deps were relied on implicitly. > > **Overview** > **Hardens Yarn dependency sourcing** by adding `approvedGitRepositories: []` to `.yarnrc.yml`, explicitly disallowing Git-based dependencies. > > Bumps the required Yarn version from `4.10.3` to `4.14.1` (root `packageManager` and matching `yarn constraints` check), and updates `yarn.lock` metadata accordingly. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit f0bd7f1. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent f667736 commit 7fccd4b

4 files changed

Lines changed: 12 additions & 7 deletions

File tree

.yarnrc.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Allowlist for Git repositories that can be used as dependencies. We set it to
2+
# an empty array to disallow all Git dependencies, as we don't use any and they
3+
# can be a security risk.
4+
approvedGitRepositories: []
5+
16
compressionLevel: mixed
27

38
enableGlobalCache: false
@@ -12,10 +17,6 @@ logFilters:
1217

1318
nodeLinker: node-modules
1419

15-
plugins:
16-
- path: .yarn/plugins/@yarnpkg/plugin-allow-scripts.cjs
17-
spec: "https://raw.githubusercontent.com/LavaMoat/LavaMoat/main/packages/yarn-plugin-allow-scripts/bundles/@yarnpkg/plugin-allow-scripts.js"
18-
1920
# Configure the NPM minimal age gate to 3 days, meaning packages must be at
2021
# least 3 days old to be installed.
2122
npmMinimalAgeGate: 4320 # 3 days (in minutes)
@@ -27,3 +28,7 @@ npmPreapprovedPackages:
2728
- "@metamask-previews/*"
2829
- "@lavamoat/*"
2930
- "@ts-bridge/*"
31+
32+
plugins:
33+
- path: .yarn/plugins/@yarnpkg/plugin-allow-scripts.cjs
34+
spec: "https://raw.githubusercontent.com/LavaMoat/LavaMoat/main/packages/yarn-plugin-allow-scripts/bundles/@yarnpkg/plugin-allow-scripts.js"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
"engines": {
106106
"node": "^18.18 || >=20"
107107
},
108-
"packageManager": "yarn@4.10.3",
108+
"packageManager": "yarn@4.14.1",
109109
"lavamoat": {
110110
"allowScripts": {
111111
"@lavamoat/preinstall-always-fail": false,

yarn.config.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ module.exports = defineConfig({
240240
if (isChildWorkspace) {
241241
workspace.unset('packageManager');
242242
} else {
243-
expectWorkspaceField(workspace, 'packageManager', 'yarn@4.10.3');
243+
expectWorkspaceField(workspace, 'packageManager', 'yarn@4.14.1');
244244
}
245245

246246
// All packages must specify a minimum Node.js version of 18.18.

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Manual changes might be lost - proceed with caution!
33

44
__metadata:
5-
version: 8
5+
version: 9
66
cacheKey: 10
77

88
"@adraffy/ens-normalize@npm:1.10.1":

0 commit comments

Comments
 (0)