Skip to content

Commit d9f7047

Browse files
authored
fix(cli): skip traversing fifo or socket files (biomejs#2392)
1 parent 17641a1 commit d9f7047

6 files changed

Lines changed: 47 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b
1616
#### Bug fixes
1717

1818
- Now Biome can detect the script language in Svelte and Vue script blocks more reliably ([#2245](https://github.com/biomejs/biome/issues/2245)). Contributed by @Sec-ant
19+
1920
- `useExhaustiveDependencies` no longer reports recursive calls as missing
2021
dependencies ([#2361](https://github.com/biomejs/biome/issues/2361)).
2122
Contributed by @arendjr
23+
2224
- `useExhaustiveDependencies` correctly reports missing dependencies declared
2325
using function declarations ([#2362](https://github.com/biomejs/biome/issues/2362)).
2426
Contributed by @arendjr
27+
2528
- Biome now can handle `.svelte` and `.vue` files with `CRLF` as the end-of-line sequence. Contributed by @Sec-ant
2629

2730
#### Enhancements
@@ -131,6 +134,8 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b
131134

132135
- Biome now correctly filters out files that are not present in the current directory when using the `--changed` flag [#1996](https://github.com/biomejs/biome/issues/1996). Contributed by @castarco
133136

137+
- Biome now skips traversing `fifo` or `socket` files ([#2311](https://github.com/biomejs/biome/issues/2311)). Contributed by @Sec-ant
138+
134139
### Configuration
135140

136141
#### Bug fixes

crates/biome_cli/src/execute/traverse.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,8 @@ impl<'ctx, 'app> TraversalContext for TraversalOptions<'ctx, 'app> {
499499
}
500500

501501
fn can_handle(&self, biome_path: &BiomePath) -> bool {
502-
if !self.fs.path_is_file(biome_path.as_path()) {
502+
let path = biome_path.as_path();
503+
if self.fs.path_is_dir(path) || self.fs.path_is_symlink(path) {
503504
// handle:
504505
// - directories
505506
// - symlinks
@@ -519,6 +520,11 @@ impl<'ctx, 'app> TraversalContext for TraversalOptions<'ctx, 'app> {
519520
return can_handle;
520521
}
521522

523+
// bail on fifo and socket files
524+
if !self.fs.path_is_file(path) {
525+
return false;
526+
}
527+
522528
let file_features = self.workspace.file_features(SupportsFeatureParams {
523529
path: biome_path.clone(),
524530
features: self.execution.to_features(),

crates/biome_fs/src/fs.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ pub trait FileSystem: Send + Sync + RefUnwindSafe {
6262
/// Checks if the given path is a regular file
6363
fn path_is_file(&self, path: &Path) -> bool;
6464

65+
/// Checks if the given path is a directory
66+
fn path_is_dir(&self, path: &Path) -> bool;
67+
68+
/// Checks if the given path is a symlink
69+
fn path_is_symlink(&self, path: &Path) -> bool;
70+
6571
/// Method that takes a path to a folder `file_path`, and a `file_name`. It attempts to find
6672
/// and read the file from that folder and if not found, it reads the parent directories recursively
6773
/// until:
@@ -343,6 +349,14 @@ where
343349
T::path_is_file(self, path)
344350
}
345351

352+
fn path_is_dir(&self, path: &Path) -> bool {
353+
T::path_is_dir(self, path)
354+
}
355+
356+
fn path_is_symlink(&self, path: &Path) -> bool {
357+
T::path_is_symlink(self, path)
358+
}
359+
346360
fn get_changed_files(&self, base: &str) -> io::Result<Vec<String>> {
347361
T::get_changed_files(self, base)
348362
}

crates/biome_fs/src/fs/memory.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,14 @@ impl FileSystem for MemoryFileSystem {
191191
files.get(path).is_some()
192192
}
193193

194+
fn path_is_dir(&self, path: &Path) -> bool {
195+
!self.path_is_file(path)
196+
}
197+
198+
fn path_is_symlink(&self, _path: &Path) -> bool {
199+
false
200+
}
201+
194202
fn get_changed_files(&self, _base: &str) -> io::Result<Vec<String>> {
195203
let cb_arc = self.on_get_changed_files.as_ref().unwrap().clone();
196204

crates/biome_fs/src/fs/os.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ impl FileSystem for OsFileSystem {
8383
path.is_file()
8484
}
8585

86+
fn path_is_dir(&self, path: &Path) -> bool {
87+
path.is_dir()
88+
}
89+
90+
fn path_is_symlink(&self, path: &Path) -> bool {
91+
path.is_symlink()
92+
}
93+
8694
fn resolve_configuration(
8795
&self,
8896
specifier: &str,

website/src/content/docs/internals/changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,15 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b
2222
#### Bug fixes
2323

2424
- Now Biome can detect the script language in Svelte and Vue script blocks more reliably ([#2245](https://github.com/biomejs/biome/issues/2245)). Contributed by @Sec-ant
25+
2526
- `useExhaustiveDependencies` no longer reports recursive calls as missing
2627
dependencies ([#2361](https://github.com/biomejs/biome/issues/2361)).
2728
Contributed by @arendjr
29+
2830
- `useExhaustiveDependencies` correctly reports missing dependencies declared
2931
using function declarations ([#2362](https://github.com/biomejs/biome/issues/2362)).
3032
Contributed by @arendjr
33+
3134
- Biome now can handle `.svelte` and `.vue` files with `CRLF` as the end-of-line sequence. Contributed by @Sec-ant
3235

3336
#### Enhancements
@@ -137,6 +140,8 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b
137140

138141
- Biome now correctly filters out files that are not present in the current directory when using the `--changed` flag [#1996](https://github.com/biomejs/biome/issues/1996). Contributed by @castarco
139142

143+
- Biome now skips traversing `fifo` or `socket` files ([#2311](https://github.com/biomejs/biome/issues/2311)). Contributed by @Sec-ant
144+
140145
### Configuration
141146

142147
#### Bug fixes

0 commit comments

Comments
 (0)