Skip to content

Commit 40b304f

Browse files
committed
test(cua-driver): verify live Windows executable grants
1 parent 8765dc3 commit 40b304f

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

libs/cua-driver/rust/crates/platform-windows/src/browser_platform.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1966,6 +1966,43 @@ mod tests {
19661966
assert_eq!(executable.as_deref(), Some(expected.as_str()));
19671967
}
19681968

1969+
#[tokio::test]
1970+
async fn live_executable_grant_matches_without_installed_app_identity() {
1971+
use cua_driver_core::session_manifest::load_manifest;
1972+
use std::io::Write;
1973+
1974+
let pid = i64::from(std::process::id());
1975+
let fingerprint = WindowsBrowserPlatform::default()
1976+
.process_fingerprint(pid)
1977+
.await
1978+
.expect("live Windows process identity");
1979+
let directory = tempfile::tempdir().unwrap();
1980+
for (executable, allowed) in [
1981+
(std::env::current_exe().unwrap(), true),
1982+
(directory.path().join("ungranted-application.exe"), false),
1983+
] {
1984+
let mut file = tempfile::NamedTempFile::new().unwrap();
1985+
write!(file, "version: 3\nallow:\n tools: [get_window_state, click]\nresources:\n apps:\n - executable: {}\n windows: all\n",
1986+
serde_json::to_string(&executable).unwrap()).unwrap();
1987+
let manifest = load_manifest(file.path()).unwrap();
1988+
for (adapter, kind) in [
1989+
("private_observation", "window"),
1990+
("desktop_input", "window_input"),
1991+
] {
1992+
let resource = serde_json::json!({
1993+
"kind": kind,
1994+
"pid": pid,
1995+
"window_id": 7,
1996+
"fingerprint": fingerprint,
1997+
"bundle_id": null,
1998+
"launch_path": null,
1999+
});
2000+
assert_eq!(manifest.authorize_protected_resource(adapter, &resource).is_ok(), allowed,
2001+
"{adapter} must use the live executable fingerprint even without an installed-app match");
2002+
}
2003+
}
2004+
}
2005+
19692006
#[test]
19702007
fn isolated_browser_candidates_are_vendor_attested_protected_installs() {
19712008
let candidates = isolated_browser_candidates_from_roots(

0 commit comments

Comments
 (0)