-
Notifications
You must be signed in to change notification settings - Fork 49
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
Prevent path explosion in file traversal with complex symlinks #354
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Rez Moss <[email protected]>
Signed-off-by: Rez Moss <[email protected]>
Thanks for the contribution @rezmoss! Is there a way to add a test illustrating the problem on a small scale and how this change fixes it? |
@kzantow Sure! I'll work on that to reproduce the issue with a new Docker image and share it here soon |
@kzantow Building a similar structure to a real docker image was really hard, but I finally built a dockerfile that reproduces almost the same behavior, my real docker image would get stuck for hours, but this one took 26 mins and 35 secs on my machine After the patch, the same process took just 1 min and 32 secs here’s the dockerfile you can build and test
|
Hey @kzantow just following up on this, have you had a chance to look at the Dockerfile I shared? Let me know if you need any more details |
Problem
When processing Node.js packages with complex symlink structures (particularly .pnpm or turf packages), the
_pathsToNode
function would enter an exponential path growth pattern:Root Cause
The issue stems from how parent paths are processed. The combination of:
p.ConstituentPaths()
creates a compounding effect where each level of symlink traversal multiplies the paths to process
Solution
The fix modifies
_pathsToNode
to:This prevents the path explosion while preserving the expected file traversal behavior