Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

fix(cua-driver): match canonical Windows executable paths (#3299)

简律纯a6828955187f
diff --git a/libs/cua-driver/rust/crates/platform-windows/src/browser_platform.rs b/libs/cua-driver/rust/crates/platform-windows/src/browser_platform.rs
index 7f8fd9c120..b1ecbfc7ff 100644
--- a/libs/cua-driver/rust/crates/platform-windows/src/browser_platform.rs
+++ b/libs/cua-driver/rust/crates/platform-windows/src/browser_platform.rs
@@ -698,7 +698,8 @@ fn process_identity(pid: u32) -> Result<(u64, Option<String>), BrowserRefusal> {
}
.ok()
.filter(|_| path_len > 0)
- .map(|_| String::from_utf16_lossy(&path_buf[..path_len as usize]));
+ .map(|_| String::from_utf16_lossy(&path_buf[..path_len as usize]))
+ .map(canonical_process_executable);
let _ = unsafe { CloseHandle(handle) };
times.map_err(|error| {
refusal(
@@ -710,6 +711,14 @@ fn process_identity(pid: u32) -> Result<(u64, Option<String>), BrowserRefusal> {
Ok((started, path))
}
+fn canonical_process_executable(path: String) -> String {
+ // Manifest executable grants use `canonicalize` too. Normalize the Windows
+ // process evidence at collection time so shared authorization stays exact.
+ std::fs::canonicalize(&path)
+ .map(|canonical| canonical.to_string_lossy().into_owned())
+ .unwrap_or(path)
+}
+
fn cdp_comparable_window_bounds(window_id: u64) -> Result<Rect, BrowserRefusal> {
let hwnd = HWND(window_id as *mut _);
let mut outer = RECT::default();
@@ -1920,6 +1929,18 @@ impl BrowserPlatform for WindowsBrowserPlatform {
mod tests {
use super::*;
+ #[test]
+ fn process_fingerprint_uses_manifest_canonical_executable_path() {
+ let (_started, executable) =
+ process_identity(std::process::id()).expect("current process fingerprint");
+ let expected = std::fs::canonicalize(std::env::current_exe().expect("current executable"))
+ .expect("canonical current executable")
+ .to_string_lossy()
+ .into_owned();
+
+ assert_eq!(executable.as_deref(), Some(expected.as_str()));
+ }
+
#[test]
fn isolated_browser_candidates_are_vendor_attested_protected_installs() {
let candidates = isolated_browser_candidates_from_roots(