Skip to content
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

glob follows symlinks recursively #281

Open
sffc opened this issue Oct 21, 2022 · 3 comments
Open

glob follows symlinks recursively #281

sffc opened this issue Oct 21, 2022 · 3 comments
Assignees

Comments

@sffc
Copy link

sffc commented Oct 21, 2022

Describe The Bug

In a directory that has a recursive symbolic link, the duckscript glob_array command performs a cyclic recursion.

To Reproduce

  1. Create a symbolic link that points at its parent directory
  2. Use glob_array

Commentary

This is a bug in glob, not duckscript, but duckscript isn't completely off the hook because the glob crate has had an issue open since 2017 (rust-lang/glob#62), and a PR to fix it, but the crate hasn't been updated in several years. There are other glob-like crates in the ecosystem now with better options, including ones to ignore symlinks. It might be worthwhile migrating to one of them.

@sagiegurari
Copy link
Owner

sagiegurari commented Oct 22, 2022

thanks for reporting. which glob crate do you recommend?
also do you plan to PR this?

@sffc
Copy link
Author

sffc commented Nov 3, 2022

We no longer have the symlink, so this isn't a pressing need any more. But it would still be nice lower-priority cleanup.

I've used globset before, maintained by @BurntSushi. It is more featureful than glob, but I'm not sure if it fixes the cyclic symlink issue.

@BurntSushi
Copy link

BurntSushi commented Nov 4, 2022

globset unfortunately only provides glob matching. It does not also provide directory traversal, which glob does. The ignore crate does directory traversal and has a very complicated API, but does support glob matching too (and relies on globset). There is also globwalk, which is built on top of ignore and has a simpler API.

The glob situation in Rust is not so great. I built globset specifically to be able to efficiently handle gitignore files, but kind of just stopped there and I haven't gotten a chance to revisit the situation. (Which I still hope to do.)

Anything that's built on walkdir (or ignore) should not have the cyclic symlink problem. It has specific logic for detecting loops.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants