Skip to content

Commit c73b740

Browse files
authored
chore(fspy): remove ignoring Chromium processes (#249)
Chromium processes can now be successfully tracked after #234, and we have it monitored since #235.
1 parent 861e518 commit c73b740

2 files changed

Lines changed: 13 additions & 38 deletions

File tree

crates/fspy_shared_unix/src/spawn/linux/mod.rs

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -24,36 +24,19 @@ pub fn handle_exec(
2424
command: &mut Exec,
2525
encoded_payload: &EncodedPayload,
2626
) -> nix::Result<Option<PreExec>> {
27-
// Check if the program is Chrome or Chromium
28-
let program_path = Path::new(OsStr::from_bytes(&command.program));
29-
let skip_injection = if let Some(file_name) = program_path.file_name() {
30-
let file_name_bytes = file_name.as_bytes();
31-
// Check for Chrome or Chromium in the filename (case-insensitive)
32-
file_name_bytes.windows(6).any(|w| w == b"Chrome" || w == b"chrome")
33-
|| file_name_bytes.windows(8).any(|w| w == b"Chromium" || w == b"chromium")
34-
} else {
35-
false
36-
};
37-
38-
if skip_injection {
39-
command.envs.retain(|(name, _)| name != LD_PRELOAD && name != PAYLOAD_ENV_NAME);
27+
let executable_fd = open_executable(Path::new(OsStr::from_bytes(&command.program)))?;
28+
let executable_mmap = unsafe { Mmap::map(&executable_fd) }
29+
.map_err(|io_error| nix::Error::try_from(io_error).unwrap_or(nix::Error::UnknownErrno))?;
30+
if elf::is_dynamically_linked_to_libc(executable_mmap)? {
31+
ensure_env(
32+
&mut command.envs,
33+
LD_PRELOAD,
34+
encoded_payload.payload.preload_path.as_os_str().as_bytes(),
35+
)?;
36+
ensure_env(&mut command.envs, PAYLOAD_ENV_NAME, &encoded_payload.encoded_string)?;
4037
Ok(None)
4138
} else {
42-
let executable_fd = open_executable(Path::new(OsStr::from_bytes(&command.program)))?;
43-
let executable_mmap = unsafe { Mmap::map(&executable_fd) }.map_err(|io_error| {
44-
nix::Error::try_from(io_error).unwrap_or(nix::Error::UnknownErrno)
45-
})?;
46-
if elf::is_dynamically_linked_to_libc(executable_mmap)? {
47-
ensure_env(
48-
&mut command.envs,
49-
LD_PRELOAD,
50-
encoded_payload.payload.preload_path.as_os_str().as_bytes(),
51-
)?;
52-
ensure_env(&mut command.envs, PAYLOAD_ENV_NAME, &encoded_payload.encoded_string)?;
53-
Ok(None)
54-
} else {
55-
command.envs.retain(|(name, _)| name != LD_PRELOAD && name != PAYLOAD_ENV_NAME);
56-
Ok(Some(PreExec(encoded_payload.payload.seccomp_payload.clone())))
57-
}
39+
command.envs.retain(|(name, _)| name != LD_PRELOAD && name != PAYLOAD_ENV_NAME);
40+
Ok(Some(PreExec(encoded_payload.payload.seccomp_payload.clone())))
5841
}
5942
}

crates/fspy_shared_unix/src/spawn/macos.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use std::{
55
path::{Path, absolute},
66
};
77

8-
use bstr::ByteSlice;
98
use phf::{Set, phf_set};
109

1110
use crate::{
@@ -42,14 +41,7 @@ pub fn handle_exec(
4241
let injectable = if let (Some(parent), Some(file_name)) =
4342
(program_path.parent(), program_path.file_name())
4443
{
45-
// Exclude Chrome and Chromium-based browsers
46-
if file_name.as_bytes().windows(6).any(|w| w == b"Chrome" || w == b"chrome")
47-
|| file_name.as_bytes().windows(8).any(|w| w == b"Chromium" || w == b"chromium")
48-
|| command.program.contains_str("Google Chrome")
49-
|| command.program.contains_str("Chromium")
50-
{
51-
false
52-
} else if matches!(parent.as_os_str().as_bytes(), b"/bin" | b"/usr/bin") {
44+
if matches!(parent.as_os_str().as_bytes(), b"/bin" | b"/usr/bin") {
5345
let fixtures = &encoded_payload.payload.fixtures;
5446
if matches!(file_name.as_bytes(), b"sh" | b"bash") {
5547
command.program = fixtures.bash_path.as_os_str().as_bytes().into();

0 commit comments

Comments
 (0)