Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion common/config/rush/.pnpmfile.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,13 @@ module.exports = {
if (pkg.dependencies['lodash']) {
pkg.dependencies['lodash'] = '4.17.23';
}
if (pkg.dependencies['bn.js']) {
pkg.dependencies['bn.js'] = pkg.dependencies['bn.js'].startsWith('^5')
? '5.2.3'
: '4.12.3';
}
Comment on lines +64 to +68
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Version-range detection via startsWith('^5') will silently cross-major-downgrade non-caret v5 consumers

The condition startsWith('^5') only matches the exact prefix ^5. Any upstream package that declares bn.js with a tilde range (~5.x.x), a bare exact version (5.2.2), or an inequality range (>=5.0.0) will fall through to the else branch and be silently pinned to 4.12.3 — a cross-major downgrade that could cause hard-to-debug runtime breakage.

Replace the heuristic with a regex that detects any semver expression resolving to major version 5:

🛡️ Proposed fix — robust major-version detection
-        if (pkg.dependencies['bn.js']) {
-          pkg.dependencies['bn.js'] = pkg.dependencies['bn.js'].startsWith('^5') 
-            ? '5.2.3' 
-            : '4.12.3';
-        }
+        if (pkg.dependencies['bn.js']) {
+          pkg.dependencies['bn.js'] = /(?:^|\s)[~^]?5\./.test(pkg.dependencies['bn.js'])
+            ? '5.2.3'
+            : '4.12.3';
+        }

Apply the same change symmetrically to the devDependencies block at lines 117-121.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@common/config/rush/.pnpmfile.cjs` around lines 64 - 68, The current check
uses pkg.dependencies['bn.js'].startsWith('^5') which misses tilde, exact, or
range specs and can wrongly pin v5 consumers to 4.x; update the detection in the
bn.js handling to test the version string with a semver-aware regex that matches
any expression resolving to major version 5 (e.g. /(^|[>=~^* ,])5(\\.|$)/ or
equivalent that detects ranges, tildes, carets, exacts and inequalities) and use
that result to select '5.2.3' vs '4.12.3'; apply the same robust detection
change to the symmetric devDependencies block that handles
pkg.devDependencies['bn.js'] so both dependency and devDependency cases behave
the same.

}

if (pkg.devDependencies) {
if (pkg.devDependencies['http-proxy']) {
pkg.devDependencies['http-proxy'] = '1.18.1';
Expand Down Expand Up @@ -109,6 +114,11 @@ module.exports = {
if (pkg.devDependencies['lodash']) {
pkg.devDependencies['lodash'] = '4.17.23';
}
if (pkg.devDependencies['bn.js']) {
pkg.devDependencies['bn.js'] = pkg.devDependencies['bn.js'].startsWith('^5')
? '5.2.3'
: '4.12.3';
}
}

return pkg;
Expand Down
36 changes: 18 additions & 18 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading