Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 54 additions & 19 deletions crates/detect/src/list/macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,25 +84,10 @@ fn resolve_via_nsrunningapp(pid: i32) -> Option<InstalledApp> {
fn resolve_via_nsrunningapp_inner(pid: i32) -> Option<InstalledApp> {
let app = NSRunningApplication::runningApplicationWithProcessIdentifier(pid)?;

if let Some(bundle_url) = app.bundleURL() {
if let Some(path_ns) = bundle_url.path() {
let path_str = path_ns.to_string();
if let Some(resolved) = find_outermost_app(Path::new(&path_str)) {
return Some(resolved);
}
}
}

let bundle_id = app.bundleIdentifier()?.to_string();
let name = app
.localizedName()
.map(|s| s.to_string())
.unwrap_or_else(|| bundle_id.clone());

Some(InstalledApp {
id: bundle_id,
name,
})
let bundle_url = app.bundleURL()?;
let path_ns = bundle_url.path()?;
let path_str = path_ns.to_string();
find_outermost_app(Path::new(&path_str))
}

fn resolve_via_sysinfo(pid: i32) -> Option<InstalledApp> {
Expand Down Expand Up @@ -157,4 +142,54 @@ mod tests {
println!("- {} ({})", app.name, app.id);
}
}

#[test]
fn test_find_outermost_app_system_daemon_path() {
let result = find_outermost_app(Path::new("/usr/libexec/avconferenced"));
assert!(
result.is_none(),
"system daemon should not resolve to an app"
);
}

#[test]
fn test_find_outermost_app_system_library_path() {
let result =
find_outermost_app(Path::new("/System/Library/PrivateFrameworks/SomeFramework"));
assert!(
result.is_none(),
"system framework should not resolve to an app"
);
}

// cargo test -p detect --features list,mic,app test_resolve_to_app_filters_system_daemons -- --ignored --nocapture
#[test]
#[ignore]
fn test_resolve_to_app_filters_system_daemons() {
let result = resolve_to_app(1);
println!("launchd (pid 1) resolved to: {:?}", result);
assert!(
result.is_none(),
"launchd (pid 1) is a system daemon and should not resolve to an app"
);
}

// cargo test -p detect --features list,mic,app test_mic_using_apps_no_system_daemons -- --ignored --nocapture
#[test]
#[ignore]
fn test_mic_using_apps_no_system_daemons() {
let apps = list_mic_using_apps();
println!("Mic-using apps:");
for app in &apps {
println!("- {} ({})", app.name, app.id);
}
for app in &apps {
assert!(
!app.name.ends_with('d') || app.name.contains('.'),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Test heuristic falsely flags legitimate apps like "Discord" as system daemons

The test_mic_using_apps_no_system_daemons test uses the heuristic !app.name.ends_with('d') || app.name.contains('.') to detect system daemons. This assertion fails for any legitimate app whose display name ends with 'd' and doesn't contain '.', such as "Discord", "Rewind", or "Alfred".

Detailed Explanation

The assertion at line 188:

!app.name.ends_with('d') || app.name.contains('.')

is logically equivalent to: "if the name ends with 'd', it must contain '.'". System daemons like avconferenced end with 'd' and don't contain '.', but so do many legitimate apps.

For example, if Discord is using the mic, read_bundle_info at crates/bundle/src/bundle.rs:24-27 would return name: "Discord" from CFBundleDisplayName or CFBundleName. This name ends with 'd' and doesn't contain '.', so the assertion would fire:

detected app 'Discord' (com.hnc.Discord) looks like a system daemon

While this test is #[ignore] and only run manually, its stated purpose is to verify that the daemon filtering works correctly during a meeting. A false failure when a legitimate app like Discord is using the mic defeats the test's purpose and could confuse developers running the manual verification.

Impact: Manual verification test produces false positives for legitimate apps, undermining confidence in the test results.

Prompt for agents
Replace the heuristic at line 188 in crates/detect/src/list/macos.rs with a more reliable check. Instead of checking if the app name ends with 'd' and doesn't contain '.', consider checking against a known list of system daemon paths or bundle IDs. For example, you could check that the app's bundle ID doesn't match known system daemon patterns like 'com.apple.avconferenced', or verify that the resolved app path starts with '/Applications' rather than '/usr/libexec' or '/System/Library'. Alternatively, simply remove the assertion and rely on the println output for manual inspection, since the test is already marked as #[ignore] for manual verification.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

"detected app '{}' ({}) looks like a system daemon",
app.name,
app.id,
);
}
}
}
Loading