We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 23a4400 commit a978db9Copy full SHA for a978db9
1 file changed
src/utils/path-resolve.mts
@@ -54,8 +54,16 @@ export function findBinPathDetailsSync(binName: string): {
54
55
export function findNpmDirPathSync(npmBinPath: string): string | undefined {
56
const { WIN32 } = constants
57
+ const MAX_ITERATIONS = 100
58
let thePath = npmBinPath
59
+ let iterations = 0
60
while (true) {
61
+ if (iterations >= MAX_ITERATIONS) {
62
+ throw new Error(
63
+ `path traversal exceeded maximum iterations of ${MAX_ITERATIONS}`,
64
+ )
65
+ }
66
+ iterations += 1
67
const libNmNpmPath = path.join(thePath, `lib/${NODE_MODULES}/${NPM}`)
68
// mise, which uses opaque binaries, puts its npm bin in a path like:
69
// /Users/SomeUsername/.local/share/mise/installs/node/vX.X.X/bin/npm.
0 commit comments