-
Notifications
You must be signed in to change notification settings - Fork 5
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
fix(sync): avoid symlink loops #2
base: master
Are you sure you want to change the base?
Conversation
Check the chain of directories that led to the current directory before reading its contents. Avoid reading the same directory twice when crawling deeper. The `realpathSync` result is never passed to the callback, so all file paths are still inside the root directory.
Thank you(!) but this is breaking and cannot be accepted as is. This is because In general cases, it won't matter, but there are (unfortunately) still a huge number of popular npm packages that force/require Node 6 support. I'll come up with another way to solve this within this PR |
Hey @aleclarson if you could check out the changes, would appreciate it! This module has to have identical behavior between sync & async, so I added support there as well. |
Looks good, though there's one difference from my original PR. Your changes will skip a directory that has already been crawled even if crawling it again would not lead to infinite recursion. For example, if both |
Actually, three more issues.
|
Gonna need to call
The |
Thanks @aleclarson – I applied your fixes, which means that it's basically back to your initial state 😅 My only hesitation with the PR right now is that it's now twice as slow as it was previously. This is because it has to "double-check" what its absolute path is on every invocation, which is something I was trying to avoid in my first pass. |
I guess it's time for you to learn Rust. :P |
Haha, I've done a couple things with it :D When you get a chance, do you think you could add some test cases for the points you raised earlier? In case you couldn't already tell, I'm not very familiar with symlinks. Am currently reworking this (in a separate branch) and it'd be good to make sure all your concerns/points are still respected. |
Also, you invite me to your fork? I want to push a branch and PR into |
Done 👍
Don't think I can, as I'm busy with getting a product ready for launch. But I'll point out if you missed anything in the PR. |
Thank you! PR opened on your fork. And totally understand, good luck! No rush either way – just appreciate your help on this :) |
Thanks for the awesome package @lukeed, Wouldnt it suffice to just change the |
I agree with @vigneshshanmugam. This library shouldn't be following symlinks at all. |
Ok, does that mean this PR is replaced by another that just does This would be a breaking change (which I think I'm okay with) since it would mean that any symlink'd directories are no longer followed at all. Currently they are, which exposes the possible infinite loop this PR addresses. |
That was my proposal. Not sure if caching would be useful, but yeah if we can also add have that on top, sound good. |
I can't use uvu with libraries that depend on local dependencies via |
Check the chain of directories that led to the current directory before reading its contents. Avoid reading the same directory twice when crawling deeper.
The
realpathSync
result is never passed to the callback, so all file paths are still inside the root directory.Note: Only the sync version is fixed by this PR. The async version is not used by
sirv
, so I can't justify helping there.