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

Don't generate warnings on missing formatters for symlinks to directories #495

Open
Mic92 opened this issue Dec 10, 2024 · 2 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@Mic92
Copy link
Member

Mic92 commented Dec 10, 2024

Treefmt seems to use lstat instead of stat to figure out a filetype?
It leads to some odd behavior when symlinks to directories are used.
Treefmt should not generate warnings for directories.

~/.homesick/repos/dotfiles test-foo* ⇡
nix-shell-env % nix fmt
2024/12/10 06:14:01 INFO using config file: /nix/store/9skqqjkkajkf44rg1ani1l0bcyr75cq1-treefmt.toml
WARN no formatter for path: home/.config/nixpkgs
WARN no formatter for path: home/.fast-syntax-highlighting
WARN no formatter for path: home/.gef-extras
WARN no formatter for path: home/.gef-mic92
traversed 999 files
emitted 346 files for processing
formatted 1 files (0 changed) in 31ms
~/.homesick/repos/dotfiles test-foo* ⇡
nix-shell-env % ls -la home/.gef-*
lrwxrwxrwx joerg users 17 B 5 months ago  home/.gef-extras@ ⇒ ../gdb/gef-extras
lrwxrwxrwx joerg users 16 B 5 months ago  home/.gef-mic92@ ⇒ ../gdb/gef-mic92
nix-shell-env % stat home/.gef-extras
  File: home/.gef-extras -> ../gdb/gef-extras
  Size: 17              Blocks: 1          IO Block: 512    symbolic link
Device: 0,53    Inode: 6577745     Links: 1
Access: (0777/lrwxrwxrwx)  Uid: ( 1000/   joerg)   Gid: (  100/   users)
Access: 2024-12-09 09:00:15.636895706 +0100
Modify: 2024-07-01 16:23:33.678525570 +0200
Change: 2024-07-01 16:23:45.254346582 +0200
 Birth: 2024-07-01 16:23:33.678525570 +0200
stat ./gdb/gef-extras
  File: ./gdb/gef-extras
  Size: 19              Blocks: 17         IO Block: 1536   directory
Device: 0,53    Inode: 132444      Links: 9
Access: (0755/drwxr-xr-x)  Uid: ( 1000/   joerg)   Gid: (  100/   users)
Access: 2024-12-09 08:42:23.294971942 +0100
Modify: 2024-10-31 10:32:46.812263967 +0100
Change: 2024-10-31 10:32:46.812263967 +0100
 Birth: 2024-07-01 16:23:33.494528414 +0200
@Mic92 Mic92 added the bug Something isn't working label Dec 10, 2024
@brianmcgee brianmcgee self-assigned this Dec 10, 2024
@zimbatm
Copy link
Member

zimbatm commented Dec 10, 2024

It should probably skip symlink directories entirely. There is potentially an attack/bug if the symlink points outside of the directory as well.

@Mic92
Copy link
Member Author

Mic92 commented Dec 10, 2024

The directory is still within the repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants