-
Notifications
You must be signed in to change notification settings - Fork 659
[rush] Fix disallowInsecureSha1 exemptPackageVersions not working with pnpm v9 #5525
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
Merged
iclanton
merged 5 commits into
microsoft:main
from
LPegasus:fix/disallow-sha1-error-with-pnpm9
Dec 29, 2025
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b01c6e5
Fix disallowInsecureSha1 exemptPackageVersions not working with pnpm v9
LPegasus 4d7ffcd
Add a test for a non-exempted package.
iclanton 2bfe45c
fixup! Fix disallowInsecureSha1 exemptPackageVersions not working wit…
iclanton a13a44b
Clean up _parseDependencyPath.
iclanton f598180
Rush change.
iclanton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
common/changes/@microsoft/rush/fix-disallow-sha1-error-with-pnpm9_2025-12-29-09-14.json
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "changes": [ | ||
| { | ||
| "packageName": "@microsoft/rush", | ||
| "comment": "Fix an issue where packages listed in the `pnpmLockfilePolicies.disallowInsecureSha1.exemptPackageVersions` `common/config/rush/pnpm-config.json` config file are not exempted in PNPM 9.", | ||
| "type": "none" | ||
| } | ||
| ], | ||
| "packageName": "@microsoft/rush" | ||
| } |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -605,13 +605,30 @@ export class PnpmShrinkwrapFile extends BaseShrinkwrapFile { | |
| * Example: "/@typescript-eslint/experimental-utils/[email protected][email protected]" --> "/@typescript-eslint/experimental-utils/5.9.1" | ||
| */ | ||
| private _parseDependencyPath(packagePath: string): string { | ||
| let depPath: string = packagePath; | ||
| if (this.shrinkwrapFileMajorVersion >= ShrinkwrapFileMajorVersion.V6) { | ||
| depPath = this._convertLockfileV6DepPathToV5DepPath(packagePath); | ||
| let name: string | undefined; | ||
| let version: string | undefined; | ||
|
|
||
| /** | ||
| * For PNPM lockfile version 9 and above, use pnpmKitV9 to parse the dependency path. | ||
| * Example: "@some/[email protected]" --> "@some/[email protected]" | ||
| * Example: "@some/[email protected]([email protected])" --> "@some/[email protected]" | ||
| * Example: "[email protected](patch_hash)" --> "[email protected]" | ||
| */ | ||
| if (this.shrinkwrapFileMajorVersion >= ShrinkwrapFileMajorVersion.V9) { | ||
| ({ name, version } = pnpmKitV9.dependencyPath.parse(packagePath)); | ||
| } else { | ||
| if (this.shrinkwrapFileMajorVersion >= ShrinkwrapFileMajorVersion.V6) { | ||
| packagePath = this._convertLockfileV6DepPathToV5DepPath(packagePath); | ||
| } | ||
|
|
||
| ({ name, version } = pnpmKitV8.dependencyPath.parse(packagePath)); | ||
| } | ||
| const pkgInfo: ReturnType<typeof pnpmKitV8.dependencyPath.parse> = | ||
| pnpmKitV8.dependencyPath.parse(depPath); | ||
| return this._getPackageId(pkgInfo.name as string, pkgInfo.version as string); | ||
|
|
||
| if (!name || !version) { | ||
| throw new InternalError(`Unable to parse package path: ${packagePath}`); | ||
| } | ||
|
|
||
| return this._getPackageId(name, version); | ||
| } | ||
|
|
||
| /** @override */ | ||
|
|
||
This file contains hidden or 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
11 changes: 11 additions & 0 deletions
11
libraries/rush-lib/src/logic/pnpm/test/__snapshots__/PnpmShrinkwrapFile.test.ts.snap
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`PnpmShrinkwrapFile Check is workspace project modified pnpm lockfile major version 9 sha1 integrity can be handled when disallowInsecureSha1 1`] = ` | ||
| Object { | ||
| "debug": "", | ||
| "error": "Error: An integrity field with \\"sha1\\" was detected in the pnpm-lock.yaml file located in subspace default; this conflicts with the \\"disallowInsecureSha1\\" policy from pnpm-config.json.[n][n]", | ||
| "log": "", | ||
| "verbose": "", | ||
| "warning": "", | ||
| } | ||
| `; |
14 changes: 14 additions & 0 deletions
14
libraries/rush-lib/src/logic/pnpm/test/jsonFiles/pnpm-config-disallow-sha1.json
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| { | ||
| "pnpmLockfilePolicies": { | ||
| "disallowInsecureSha1": { | ||
| "enabled": true, | ||
| "exemptPackageVersions": { | ||
| "@some/sha1-pkg": ["1.4.3"], | ||
| "other-sha1-pkg": ["2.0.0"], | ||
| "fake-with-patch": ["1.0.0"], | ||
| "fake-with-peer": ["1.0.0"], | ||
| "fake": ["7.8.1"] | ||
| } | ||
| } | ||
| } | ||
| } |
66 changes: 66 additions & 0 deletions
66
...h-lib/src/logic/pnpm/test/yamlFiles/pnpm-lock-v9/sha1-integrity-non-exempted-package.yaml
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| lockfileVersion: '9.0' | ||
|
|
||
| settings: | ||
| autoInstallPeers: true | ||
| excludeLinksFromLockfile: false | ||
|
|
||
| patchedDependencies: | ||
| [email protected]: | ||
| hash: tta6uuavpnftppsegagihriayy | ||
| path: patches/[email protected] | ||
|
|
||
| importers: | ||
| .: | ||
| dependencies: | ||
| '@some/sha1-pkg': | ||
| specifier: ^1.0.0 | ||
| version: 1.4.3 | ||
| other-sha1-pkg: | ||
| specifier: ~2.0.0 | ||
| version: 2.0.0 | ||
| fake-with-patch: | ||
| specifier: 1.0.0 | ||
| version: 1.0.0 | ||
| fake-with-peer: | ||
| specifier: 1.0.0 | ||
| version: 1.0.0 | ||
| fake-with-npm: | ||
| specifier: npm:[email protected] | ||
| version: [email protected] | ||
| fake-non-exempted: | ||
| specifier: 1.0.0 | ||
| version: 1.0.0 | ||
|
|
||
| packages: | ||
| '@some/[email protected]': | ||
| resolution: { integrity: sha1-KQzv7h3EqVCA2u7BOFut5Vqbl5o= } | ||
|
|
||
| [email protected]: | ||
| resolution: { integrity: sha1-+5v5y5gkJ6x2+X1K3pZ5p8W7m4o= } | ||
|
|
||
| [email protected]: | ||
| resolution: { integrity: sha1-FAKEPATCHINTEGRITY1234567890= } | ||
|
|
||
| [email protected]: | ||
| resolution: { integrity: sha1-FAKEPEERINTEGRITY0987654321= } | ||
|
|
||
| [email protected]: | ||
| resolution: { integrity: sha1-FAKEPEERINTEGRITY0987654321= } | ||
|
|
||
| [email protected]: | ||
| resolution: { integrity: sha1-FAKEPEERINTEGRITY0987654321= } | ||
|
|
||
| snapshots: | ||
| '@some/[email protected]': {} | ||
|
|
||
| [email protected]: {} | ||
|
|
||
| [email protected](patch_hash=tta6uuavpnftppsegagihriayy): {} | ||
|
|
||
| [email protected](@some/[email protected]): | ||
| transitivePeerDependencies: | ||
| - '@some/sha1-pkg' | ||
|
|
||
| [email protected]: {} | ||
|
|
||
| [email protected]: {} |
58 changes: 58 additions & 0 deletions
58
libraries/rush-lib/src/logic/pnpm/test/yamlFiles/pnpm-lock-v9/sha1-integrity.yaml
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| lockfileVersion: '9.0' | ||
|
|
||
| settings: | ||
| autoInstallPeers: true | ||
| excludeLinksFromLockfile: false | ||
|
|
||
| patchedDependencies: | ||
| [email protected]: | ||
| hash: tta6uuavpnftppsegagihriayy | ||
| path: patches/[email protected] | ||
|
|
||
| importers: | ||
| .: | ||
| dependencies: | ||
| '@some/sha1-pkg': | ||
| specifier: ^1.0.0 | ||
| version: 1.4.3 | ||
| other-sha1-pkg: | ||
| specifier: ~2.0.0 | ||
| version: 2.0.0 | ||
| fake-with-patch: | ||
| specifier: 1.0.0 | ||
| version: 1.0.0 | ||
| fake-with-peer: | ||
| specifier: 1.0.0 | ||
| version: 1.0.0 | ||
| fake-with-npm: | ||
| specifier: npm:[email protected] | ||
| version: [email protected] | ||
|
|
||
| packages: | ||
| '@some/[email protected]': | ||
| resolution: { integrity: sha1-KQzv7h3EqVCA2u7BOFut5Vqbl5o= } | ||
|
|
||
| [email protected]: | ||
| resolution: { integrity: sha1-+5v5y5gkJ6x2+X1K3pZ5p8W7m4o= } | ||
|
|
||
| [email protected]: | ||
| resolution: { integrity: sha1-FAKEPATCHINTEGRITY1234567890= } | ||
|
|
||
| [email protected]: | ||
| resolution: { integrity: sha1-FAKEPEERINTEGRITY0987654321= } | ||
|
|
||
| [email protected]: | ||
| resolution: { integrity: sha1-FAKEPEERINTEGRITY0987654321= } | ||
|
|
||
| snapshots: | ||
| '@some/[email protected]': {} | ||
|
|
||
| [email protected]: {} | ||
|
|
||
| [email protected](patch_hash=tta6uuavpnftppsegagihriayy): {} | ||
|
|
||
| [email protected](@some/[email protected]): | ||
| transitivePeerDependencies: | ||
| - '@some/sha1-pkg' | ||
|
|
||
| [email protected]: {} | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.