Skip to content

Visual Studio Code, rebuilt in Rust

Rust

feat(windows): ask before opening a path on a UNC host not allowed

rokartur907c6c89aaf6
diff --git a/native/crates/app/src/anything_quick_access.rs b/native/crates/app/src/anything_quick_access.rs
index 183308a9622..01e675bc705 100644
--- a/native/crates/app/src/anything_quick_access.rs
+++ b/native/crates/app/src/anything_quick_access.rs
@@ -204,7 +204,7 @@ pub fn absolute_path_result(query: &PreparedQuery, home: &str) -> Option<PathBuf
return None;
}
let path = PathBuf::from(untildify(&query.piece.original, home));
- (path.is_absolute() && path.is_file()).then(|| match_filename_casing(&path))
+ (path.is_absolute() && files::unc::is_unc_access_allowed(&path) && path.is_file()).then(|| match_filename_casing(&path))
}
/// `getRelativePathFileResults`: a query naming an existing file relative to a workspace folder finds it even
diff --git a/native/crates/app/src/anything_quick_access/tests.rs b/native/crates/app/src/anything_quick_access/tests.rs
index e0b53a5c4a5..24b0b3b57ce 100644
--- a/native/crates/app/src/anything_quick_access/tests.rs
+++ b/native/crates/app/src/anything_quick_access/tests.rs
@@ -63,6 +63,23 @@ fn a_trailing_separator_opens_the_file_at_its_start() {
assert_eq!(extract_range_from_filter("main.ts:", &[]), Some(("main.ts".into(), range(1, 1, 1, 1))));
}
+/// `//var/...` is `/var/...` on macOS and Linux, and a path on UNC host `var` to the check.
+#[cfg(unix)]
+#[test]
+fn an_absolute_path_on_a_refused_unc_host_is_not_probed() {
+ let dir = std::env::temp_dir().join(format!("quick-access-unc-{}", std::process::id()));
+ std::fs::create_dir_all(&dir).unwrap();
+ std::fs::write(dir.join("a.ts"), "").unwrap();
+ let query = prepare_query(&format!("/{}", dir.join("a.ts").display()));
+ let host = dir.components().nth(1).unwrap().as_os_str().to_str().unwrap().to_owned();
+ files::unc::restrict_unc_access_on_this_thread(Some(&[]));
+ assert_eq!(absolute_path_result(&query, "/home"), None);
+ files::unc::restrict_unc_access_on_this_thread(Some(&[&host]));
+ assert!(absolute_path_result(&query, "/home").is_some());
+ files::unc::restrict_unc_access_on_this_thread(None);
+ std::fs::remove_dir_all(&dir).unwrap();
+}
+
fn entries(root: &str, relative: &[&str]) -> Vec<FileEntry> {
relative.iter().map(|path| FileEntry { relative_path: path.to_string(), path: Path::new(root).join(path) }).collect()
}
diff --git a/native/crates/app/src/tasks/problem_matcher.rs b/native/crates/app/src/tasks/problem_matcher.rs
index 9611f24d25c..710b464a02f 100644
--- a/native/crates/app/src/tasks/problem_matcher.rs
+++ b/native/crates/app/src/tasks/problem_matcher.rs
@@ -672,7 +672,7 @@ pub fn resource(file: &str, matcher: &ProblemMatcher) -> PathBuf {
let path = match matcher.file_location {
FileLocation::Absolute => PathBuf::from(file),
FileLocation::Relative => relative().unwrap_or_else(|| PathBuf::from(file)),
- FileLocation::AutoDetect => relative().filter(|path| path.exists()).unwrap_or_else(|| PathBuf::from(file)),
+ FileLocation::AutoDetect => relative().filter(|path| files::unc::is_unc_access_allowed(path) && path.exists()).unwrap_or_else(|| PathBuf::from(file)),
FileLocation::Search => matcher.search_include.iter().find_map(|dir| search(Path::new(dir), file, &matcher.search_exclude)).unwrap_or_else(|| PathBuf::from(file)),
};
normalize(&Path::new("/").join(path))
@@ -680,7 +680,7 @@ pub fn resource(file: &str, matcher: &ProblemMatcher) -> PathBuf {
/// `searchForFileLocation`: the first file under `dir` whose path ends with `file`, files before subfolders.
fn search(dir: &Path, file: &str, exclude: &[String]) -> Option<PathBuf> {
- if exclude.iter().any(|excluded| Path::new(excluded) == dir) {
+ if exclude.iter().any(|excluded| Path::new(excluded) == dir) || !files::unc::is_unc_access_allowed(dir) {
return None;
}
let mut subdirs = Vec::new();
@@ -784,6 +784,28 @@ mod tests {
assert_eq!(found[0].marker["message"], "bad");
}
+ /// `//var/...` is `/var/...` on macOS and Linux, and a folder on UNC host `var` to the check.
+ #[cfg(unix)]
+ #[test]
+ fn a_search_or_autodetect_folder_on_a_refused_unc_host_is_not_probed() {
+ let dir = std::env::temp_dir().join(format!("problem-matcher-unc-{}", std::process::id()));
+ std::fs::create_dir_all(dir.join("src")).unwrap();
+ std::fs::write(dir.join("src/a.ts"), "").unwrap();
+ let unc = format!("/{}", dir.display());
+ let host = dir.components().nth(1).unwrap().as_os_str().to_str().unwrap().to_owned();
+ let registry = Registry::new(&[]);
+ let search = registry.parse(&json!({ "owner": "x", "fileLocation": ["search", { "include": [unc] }], "pattern": { "regexp": "^(.*):(\\d+): (.*)$", "message": 3 } }), &mut Messages::new()).unwrap();
+ let auto = registry.parse(&json!({ "owner": "x", "fileLocation": ["autoDetect", unc], "pattern": { "regexp": "^(.*):(\\d+): (.*)$", "message": 3 } }), &mut Messages::new()).unwrap();
+ files::unc::restrict_unc_access_on_this_thread(Some(&[]));
+ assert_eq!(run(&search, &["a.ts:1: bad"])[0].resource, PathBuf::from("/a.ts"));
+ assert_eq!(run(&auto, &["src/a.ts:1: bad"])[0].resource, PathBuf::from("/src/a.ts"));
+ files::unc::restrict_unc_access_on_this_thread(Some(&[&host]));
+ assert_eq!(run(&search, &["a.ts:1: bad"])[0].resource, dir.join("src/a.ts"));
+ assert_eq!(run(&auto, &["src/a.ts:1: bad"])[0].resource, dir.join("src/a.ts"));
+ files::unc::restrict_unc_access_on_this_thread(None);
+ std::fs::remove_dir_all(&dir).unwrap();
+ }
+
/// problemMatcher.test.ts ProblemPatternParser cases, and the registries' extension messages.
#[test]
fn invalid_problem_patterns_and_matchers_are_extension_messages() {
diff --git a/native/crates/app/src/workbench/command_line.rs b/native/crates/app/src/workbench/command_line.rs
index 68f0d550f4c..86d80ac04d1 100644
--- a/native/crates/app/src/workbench/command_line.rs
+++ b/native/crates/app/src/workbench/command_line.rs
@@ -70,6 +70,10 @@ impl CommandLine {
false => (arg.clone(), None, None),
};
let path = cwd.join(path);
+ if let Err(error) = files::unc::check_unc_access(&path) {
+ eprintln!("[windows] Invalid path provided: {}, {error}", path.display());
+ continue;
+ }
let openable = if path.exists() { Openable::of(path) } else { Openable::File(path) };
match openable {
Openable::Workspace(path) if args.flag("add") && path.is_dir() => command_line.folders_to_add.push(path),
diff --git a/native/crates/app/src/workbench/command_line/tests.rs b/native/crates/app/src/workbench/command_line/tests.rs
index 6d2931f57de..9488d09ba37 100644
--- a/native/crates/app/src/workbench/command_line/tests.rs
+++ b/native/crates/app/src/workbench/command_line/tests.rs
@@ -30,6 +30,60 @@ fn command_line(args: &[&str], cwd: &Path) -> CommandLine {
CommandLine::from_args(&argv::parse_and_validate(&args).unwrap().0, cwd)
}
+/// `//var/...` is `/var/...` on macOS and Linux, and a path on UNC host `var` to the check.
+#[cfg(unix)]
+fn on_unc_host(path: &Path) -> (PathBuf, String) {
+ (PathBuf::from(format!("/{}", path.display())), path.components().nth(1).unwrap().as_os_str().to_str().unwrap().to_owned())
+}
+
+#[cfg(unix)]
+#[test]
+fn a_command_line_path_on_a_refused_unc_host_is_left_out() {
+ let dir = std::env::temp_dir().join(format!("code-gpui-cli-unc-{}", std::process::id()));
+ std::fs::create_dir_all(&dir).unwrap();
+ std::fs::write(dir.join("a.txt"), "").unwrap();
+ let (unc, host) = on_unc_host(&dir.join("a.txt"));
+ files::unc::restrict_unc_access_on_this_thread(Some(&[]));
+ assert!(command_line(&[unc.to_str().unwrap()], &dir).files.open.is_empty());
+ files::unc::restrict_unc_access_on_this_thread(Some(&[&host]));
+ assert_eq!(command_line(&[unc.to_str().unwrap()], &dir).files.open.len(), 1);
+ files::unc::restrict_unc_access_on_this_thread(None);
+ std::fs::remove_dir_all(&dir).unwrap();
+}
+
+/// windowsMainService.ts `onUNCHostNotAllowed`: Cancel opens nothing, Learn More asks again, Allow opens the path.
+#[cfg(unix)]
+#[gpui::test]
+fn a_path_on_a_refused_unc_host_asks_before_it_opens(cx: &mut TestAppContext) {
+ let (dir, workbench, cx) = workbench_in("unc", cx);
+ let (unc, host) = on_unc_host(&dir.join("a.txt"));
+ files::unc::restrict_unc_access_on_this_thread(Some(&[]));
+ workbench.update_in(cx, |workbench, window, cx| {
+ workbench.update_user_setting("window.dialogStyle", "custom".into());
+ workbench.open_window(vec![super::super::workspace_actions::Openable::of(unc.clone())], None, false, window, cx)
+ });
+ cx.run_until_parked();
+ let shown = |cx: &mut VisualTestContext| workbench.read_with(cx, |workbench, _| workbench.dialogs.iter().map(|shown| shown.dialog.message.clone()).collect::<Vec<_>>());
+ assert_eq!(shown(cx), [format!("The host '{host}' was not found in the list of allowed hosts. Do you want to allow it anyway?")]);
+ workbench.update(cx, |workbench, cx| workbench.close_custom_dialog(2, cx));
+ cx.run_until_parked();
+ assert!(shown(cx).is_empty());
+ assert!(workbench.read_with(cx, |workbench, _| workbench.editors.active().is_none()));
+
+ workbench.update_in(cx, |workbench, window, cx| workbench.open_window(vec![super::super::workspace_actions::Openable::of(unc.clone())], None, false, window, cx));
+ cx.run_until_parked();
+ workbench.update(cx, |workbench, cx| workbench.close_custom_dialog(1, cx));
+ cx.run_until_parked();
+ assert_eq!(shown(cx).len(), 1, "Learn More shows the dialog again");
+ workbench.update(cx, |workbench, cx| workbench.close_custom_dialog(0, cx));
+ cx.run_until_parked();
+ assert!(shown(cx).is_empty());
+ assert_eq!(workbench.read_with(cx, |workbench, _| workbench.editors.active().unwrap().document().path.clone()), unc);
+ assert!(files::unc::is_unc_access_allowed(&unc));
+ files::unc::restrict_unc_access_on_this_thread(None);
+ std::fs::remove_dir_all(&dir).unwrap();
+}
+
fn open(workbench: &gpui::Entity<Workbench>, cx: &mut VisualTestContext, command_line: CommandLine) {
workbench.update_in(cx, |workbench, window, cx| workbench.open_command_line_files(command_line.files, None, window, cx));
cx.run_until_parked();
diff --git a/native/crates/app/src/workbench/terminal_links.rs b/native/crates/app/src/workbench/terminal_links.rs
index 85c0c955847..f7867c06807 100644
--- a/native/crates/app/src/workbench/terminal_links.rs
+++ b/native/crates/app/src/workbench/terminal_links.rs
@@ -335,7 +335,7 @@ fn link_at(text: &str, index: usize, cwd: &Path, home: Option<&Path>) -> Option<
(Some(rest), Some(home)) => home.join(rest),
_ => cwd.join(raw),
};
- if !path.is_file() {
+ if !files::unc::is_unc_access_allowed(&path) || !path.is_file() {
return None;
}
let (line, column) = parsed.suffix.map_or((None, None), |suffix| (suffix.row, suffix.col));
@@ -361,6 +361,23 @@ mod tests {
std::fs::remove_dir_all(&dir).unwrap();
}
+ /// `//var/...` is `/var/...` on macOS and Linux, and a path on UNC host `var` to the check.
+ #[cfg(unix)]
+ #[test]
+ fn a_file_on_a_refused_unc_host_is_not_probed() {
+ let dir = std::env::temp_dir().join(format!("terminal-links-unc-{}", std::process::id()));
+ std::fs::create_dir_all(&dir).unwrap();
+ std::fs::write(dir.join("main.rs"), "fn main() {}\n").unwrap();
+ let text = format!("/{}", dir.join("main.rs").display());
+ let host = dir.components().nth(1).unwrap().as_os_str().to_str().unwrap().to_owned();
+ files::unc::restrict_unc_access_on_this_thread(Some(&[]));
+ assert_eq!(link_at(&text, 3, Path::new("/"), None), None);
+ files::unc::restrict_unc_access_on_this_thread(Some(&[&host]));
+ assert!(link_at(&text, 3, Path::new("/"), None).is_some());
+ files::unc::restrict_unc_access_on_this_thread(None);
+ std::fs::remove_dir_all(&dir).unwrap();
+ }
+
#[test]
fn a_link_wrapped_over_two_rows_is_found_from_either_row() {
let app_root = std::path::Path::new(env!("VSCODE_SRC")).to_path_buf();
diff --git a/native/crates/app/src/workbench/workspace_actions.rs b/native/crates/app/src/workbench/workspace_actions.rs
index ba1d87cde90..e4b4e8c5496 100644
--- a/native/crates/app/src/workbench/workspace_actions.rs
+++ b/native/crates/app/src/workbench/workspace_actions.rs
@@ -27,7 +27,8 @@ pub enum Openable {
impl Openable {
pub(super) fn of(path: PathBuf) -> Openable {
- match path.is_dir() || path.extension().is_some_and(|extension| extension == "code-workspace") {
+ let folder = files::unc::is_unc_access_allowed(&path) && path.is_dir();
+ match folder || path.extension().is_some_and(|extension| extension == "code-workspace") {
true => Openable::Workspace(path),
false => Openable::File(path),
}
@@ -117,6 +118,10 @@ impl Workbench {
let mut files = FilesToOpen::default();
let mut workspaces = Vec::new();
for openable in openables {
+ if !files::unc::is_unc_access_allowed(openable.path()) {
+ self.confirm_unc_host(openable.path().to_path_buf(), at, force_new_window, window, cx);
+ continue;
+ }
if !openable.path().exists() {
let detail = format!("The path '{}' does not exist on this computer.", path_label(openable.path(), None));
let _ = dialog::show_message_box(window, crate::dialog::InTests::Show, PromptLevel::Info, "Path does not exist", Some(&detail), &["OK"], None, cx);
@@ -162,6 +167,41 @@ impl Workbench {
opened
}
+ /// windowsMainService.ts `onUNCHostNotAllowed`: Allow opens the path with its host allowed for this session, and
+ /// with the checkbox in `security.allowedUNCHosts` too; Learn More shows the dialog again.
+ fn confirm_unc_host(&mut self, path: PathBuf, at: Option<(u32, u32)>, force_new_window: bool, window: &mut Window, cx: &mut Context<Self>) {
+ let host = files::unc::unc_host(&path.to_string_lossy().replace('/', "\\")).unwrap_or_default().to_owned();
+ let message = format!("The host '{host}' was not found in the list of allowed hosts. Do you want to allow it anyway?");
+ let detail = format!("The path '{}' uses a host that is not allowed. Unless you trust the host, you should press 'Cancel'", path_label(&path, None));
+ let checkbox = format!("Permanently allow host '{host}'");
+ cx.spawn_in(window, async move |workbench, cx| {
+ loop {
+ let Ok(answer) = workbench.update_in(cx, |_, window, cx| dialog::show_message_box(window, crate::dialog::InTests::Show, PromptLevel::Warning, &message, Some(&detail), &["Allow", "Learn More", "Cancel"], Some(&checkbox), cx)) else { return };
+ let Ok((button, permanently)) = answer.await else { return };
+ match button {
+ 0 => break drop(workbench.update_in(cx, |workbench, window, cx| workbench.allow_unc_host(&host, permanently, Openable::of(path), at, force_new_window, window, cx))),
+ 1 => drop(cx.update(|_, cx| cx.open_url("https://aka.ms/vscode-windows-unc"))),
+ _ => break,
+ }
+ }
+ })
+ .detach();
+ }
+
+ /// window.ts `vscode:configureAllowedUNCHost` for the permanent allow, Windows only.
+ #[allow(clippy::too_many_arguments)]
+ fn allow_unc_host(&mut self, host: &str, permanently: bool, openable: Openable, at: Option<(u32, u32)>, force_new_window: bool, window: &mut Window, cx: &mut Context<Self>) {
+ files::unc::add_unc_host_to_allowlist(host);
+ if permanently && cfg!(windows) {
+ let mut hosts: Vec<Value> = self.setting("security.allowedUNCHosts").as_array().cloned().unwrap_or_default();
+ if !hosts.iter().any(|allowed| allowed == host) {
+ hosts.push(host.into());
+ self.update_user_setting("security.allowedUNCHosts", Value::Array(hosts));
+ }
+ }
+ self.open_window(vec![openable], at, force_new_window, window, cx);
+ }
+
/// windowActions.ts `OpenRecentAction`: the recent folders and workspaces, then the recent files.
fn show_open_recent(&mut self, window: &mut Window, cx: &mut Context<Self>) {
let recent = recently_opened::load(&mut self.shared_storage.lock().unwrap());
diff --git a/native/crates/files/src/unc.rs b/native/crates/files/src/unc.rs
index 9de8eea79d4..a3537e412cc 100644
--- a/native/crates/files/src/unc.rs
+++ b/native/crates/files/src/unc.rs
@@ -16,10 +16,11 @@ pub fn unc_host_allowlist() -> Vec<String> {
/// `addUNCHostToAllowlist`: Windows only, lowercased (UNC hosts are case-insensitive).
pub fn add_unc_host_to_allowlist(host: &str) {
- if !cfg!(windows) {
+ let host = host.to_lowercase();
+ let added_on_this_thread = THREAD_ALLOWLIST.with_borrow_mut(|allowlist| allowlist.as_mut().map(|allowlist| allowlist.push(host.clone())).is_some());
+ if added_on_this_thread || !cfg!(windows) {
return;
}
- let host = host.to_lowercase();
let mut allowlist = ALLOWLIST.lock().unwrap();
if !allowlist.contains(&host) {
allowlist.push(host);
@@ -79,21 +80,30 @@ pub fn is_path_allowed_by_unc_host_allowlist(path: &str, allowed_hosts: &[String
}
/// `isUNCAccessAllowed`.
-pub fn is_unc_access_allowed(path: &str) -> bool {
- is_unc_access_restrictions_disabled() || unc_access_error(path, &unc_host_allowlist()).is_none()
+pub fn is_unc_access_allowed(path: &Path) -> bool {
+ check_unc_access(path).is_ok()
}
/// The error Electron's `fs` throws for a path `is_unc_access_allowed` refuses.
pub fn check_unc_access(path: &Path) -> std::io::Result<()> {
- if is_unc_access_restrictions_disabled() {
+ let Some(allowlist) = THREAD_ALLOWLIST.with_borrow(Clone::clone).or_else(|| (!is_unc_access_restrictions_disabled()).then(unc_host_allowlist)) else {
return Ok(());
- }
- match unc_access_error(&path.to_string_lossy(), &unc_host_allowlist()) {
+ };
+ match unc_access_error(&path.to_string_lossy(), &allowlist) {
Some(message) => Err(std::io::Error::new(std::io::ErrorKind::PermissionDenied, message)),
None => Ok(()),
}
}
+thread_local! {
+ static THREAD_ALLOWLIST: std::cell::RefCell<Option<Vec<String>>> = const { std::cell::RefCell::new(None) };
+}
+
+/// For tests on any OS: Windows' restrictions with `allowlist` on this thread, `None` back to the process's.
+pub fn restrict_unc_access_on_this_thread(allowlist: Option<&[&str]>) {
+ THREAD_ALLOWLIST.set(allowlist.map(|hosts| hosts.iter().map(|host| host.to_lowercase()).collect()));
+}
+
/// diskFileSystemProvider.ts `toFileSystemProviderError` of `ERR_UNC_HOST_NOT_ALLOWED`.
pub fn provider_message(error: &std::io::Error) -> String {
format!("{error}. Please update the 'security.allowedUNCHosts' setting if you want to allow this host.")
diff --git a/port/ledger.md b/port/ledger.md
index c14c1850327..e51ac534b5d 100644
--- a/port/ledger.md
+++ b/port/ledger.md
@@ -84,7 +84,7 @@ Status: `open`, `in progress`, `waiting on Artur`, `later` (postponed), `done`,
| M24 Windows | app/src/keyboard_layout.rs:7 | open | [windows M] keyboard layout info and raw mapping (native-keymap's Windows `GetKeyboardLayout`, `MapVirtualKeyEx`, `ToUnicodeEx`). | `cargo gc test -p app keyboard` on the windows runner |
| M24 Windows | app/src/clipboard.rs:91 | open | [windows M] clipboard file lists, HTML and custom formats (Chromium's registered clipboard formats); GPUI's Windows clipboard has text and images. Windows shows now: text only. | `cargo gc test -p app clipboard` on the windows runner |
| M24 Windows | files/src/disk.rs:58 | open | [windows M] file system on NTFS: read-only through `FILE_ATTRIBUTE_READONLY`, file and directory symlinks, case-insensitive path compare, Recycle Bin (trash crate), ReadDirectoryChangesW (notify); Windows versions of the `cfg(unix)` tests that lock files or folders or make symlinks (readonly, text_files, explorer_actions, terminal completion_service). | `cargo gc test -p files` on the windows runner |
-| M24 Windows | app/src/editor_history.rs:59 | in progress | [windows L] drive-letter paths and file URIs (`file:///c%3A/...`, uri.ts `fsPath` on Windows, backslash separators in labels). Done: uri.rs `Uri::file` and `fs_path` as uri.ts `URI.file` and `uriToFsPath` (backslashes, drive letters, UNC authorities), used by editor_history.rs, the editor's model URIs (editor.rs `uri_value`, `uri_string`, host_requests.rs `uri_parts`, on Windows only: elsewhere a `//host` path keeps the port's form), backup_tracker.rs, file_dialogs.rs, language_features.rs and webview resources (`file_roots`, `is_contained` comparing `fsPath`s ignoring case as `extUri` on Windows, the WebView2 file read). Open: the other `file` URI reads (`uri["path"]` of a `file` URI taken as the path: debug, scm, search, notebooks, tasks and the rest), backslash separators in labels (labels.ts `getPathLabel`). UNC host check (base/node/unc.ts, Electron's `ERR_UNC_HOST_NOT_ALLOWED`, `security.restrictUNCAccess` and `security.allowedUNCHosts` read at start as app.ts): done for the file service (disk.rs), the text file models, editor reads and webview resources (files/src/unc.rs); open: the reads that bypass these seams (terminal cwd, search, scm, debug, tasks, the extension host's own file access) and windowsMainService.ts `onUNCHostNotAllowed`, the Allow, Cancel, Learn More prompt for an opened path on a host not allowed (the port opens it and its reads fail with the setting's message). | `cargo gc test -p app uri::tests::file_uris_and_fs_paths_per_platform`, `cargo gc test -p app webview::tests::maps_resource_urls`, `cargo gc test -p files unc::tests` and `cargo gc test -p config the_unc_settings_are_registered_only_on_windows_and_restrict_by_default` on the host; [windows] api-tests and a webview image from the workspace on the windows runner |
+| M24 Windows | app/src/editor_history.rs:59 | in progress | [windows L] drive-letter paths and file URIs (`file:///c%3A/...`, uri.ts `fsPath` on Windows, backslash separators in labels). Done: uri.rs `Uri::file` and `fs_path` as uri.ts `URI.file` and `uriToFsPath` (backslashes, drive letters, UNC authorities), used by editor_history.rs, the editor's model URIs (editor.rs `uri_value`, `uri_string`, host_requests.rs `uri_parts`, on Windows only: elsewhere a `//host` path keeps the port's form), backup_tracker.rs, file_dialogs.rs, language_features.rs and webview resources (`file_roots`, `is_contained` comparing `fsPath`s ignoring case as `extUri` on Windows, the WebView2 file read). Open: the other `file` URI reads (`uri["path"]` of a `file` URI taken as the path: debug, scm, search, notebooks, tasks and the rest), backslash separators in labels (labels.ts `getPathLabel`). UNC host check (base/node/unc.ts, Electron's `ERR_UNC_HOST_NOT_ALLOWED`, `security.restrictUNCAccess` and `security.allowedUNCHosts` read at start as app.ts): done for the file service (disk.rs), the text file models, editor reads and webview resources (files/src/unc.rs), the extension host's `fs` (uncFsGuard.ts from `NODE_UNC_HOST_ALLOWLIST` as utilityProcess.ts), the probes of paths the user did not open (terminal links, problem matcher `autoDetect` and `search`, quick open's absolute path) and windowsMainService.ts `onUNCHostNotAllowed` (Allow, Cancel, Learn More) for Open, Open Recent and `vscode://file` URLs. Open: a command line path on a host not allowed is left out with upstream's "Invalid path provided" log instead of the prompt (no window to own it yet); the direct `std::fs` reads of paths inside an opened, so allowed, folder (breadcrumbs, launch.json, scm, search) stay unchecked; child processes with a UNC cwd or argument (terminal, ripgrep, git, tasks) spawn as upstream's, whose terminalProcess.ts `_validateCwd` ignores errors other than ENOENT. | `cargo gc test -p app uri::tests::file_uris_and_fs_paths_per_platform`, `cargo gc test -p app webview::tests::maps_resource_urls`, `cargo gc test -p files unc::tests`, `cargo gc test -p app unc` (terminal links, problem matcher, quick open, command line, the prompt) and `cargo gc test -p config the_unc_settings_are_registered_only_on_windows_and_restrict_by_default` on the host, `bun test src/vs/base/test/node/uncFsGuard.test.ts` in the exthost build; [windows] api-tests and a webview image from the workspace on the windows runner | `cargo gc test -p app uri::tests::file_uris_and_fs_paths_per_platform`, `cargo gc test -p app webview::tests::maps_resource_urls`, `cargo gc test -p files unc::tests` and `cargo gc test -p config the_unc_settings_are_registered_only_on_windows_and_restrict_by_default` on the host; [windows] api-tests and a webview image from the workspace on the windows runner |
| M24 Windows | app/src/settings_import.rs:28 | open | [windows S] settings import from `%APPDATA%\Code`, `%APPDATA%\Cursor`, `%APPDATA%\VSCodium`, extensions from `%USERPROFILE%\.vscode\extensions` and the others. | `cargo gc test -p app settings_import` on the windows runner |
| M24 Windows | app/src/workbench/shell_command.rs:70 | in progress | [windows S] no Shell Command on Windows (upstream has it on macOS only): the user setup puts `{app}\bin` on the user PATH (code.iss `addtopath`), the zip leaves PATH alone. | the commands absent from the palette on the windows runner; the installer row's check |
| M24 Windows | app/src/update/install.rs:21 | in progress | [windows M] updates as a download link, as on Linux (decision "Windows updates"). | `cargo gc test -p app update::` on the host |
diff --git a/port/notes.md b/port/notes.md
index 616bc9adc2c..ba74868a38e 100644
--- a/port/notes.md
+++ b/port/notes.md
@@ -1023,7 +1023,7 @@ What to do (milestone 21, in order):
- Console: the app is a GUI-subsystem binary, as Electron's, so a start from Explorer or the Start menu opens no console window; at start it attaches to the console of the process that started it unless the output is redirected or the CLI set `ELECTRON_NO_ATTACH_CONSOLE` (electron_main_win.cc, Chromium's `RouteStdioToConsole`), so `bin\<applicationName>.cmd --help` prints in the terminal.
- Proxy: `request/windows.rs` sends through curl.exe as Linux does, with the proxy picked first: the session proxy, else the IE settings, auto-detect and the PAC URL through WinHTTP's resolver where Chromium runs the script in its own V8 (same answer, other engine), then the manual proxy. The rule and bypass parsing is Chromium's (`request/proxy_rules.rs`, built on every platform for its host tests). Difference: curl takes one proxy, so a PAC list's later entries are no fallback. `WinHttpGetProxyForUrl` runs without `fAutoLogonIfChallenged` first and with it only after `ERROR_WINHTTP_LOGIN_FAILURE`, as Chromium's proxy_resolver_winhttp.cc, so the logon credentials go to a WPAD or PAC server only when it asks.
- File URIs: `uri.rs` `Uri::file` and `fs_path` are uri.ts `URI.file` and `uriToFsPath`, with the platform a parameter so the host tests check the Windows branches. The editor's model URIs take them on Windows only: elsewhere the port keeps a `//host/a` model path in the URI path (editor.rs `a_non_file_uri_keeps_its_authority`) where upstream makes `host` the authority.
-- UNC hosts: `files/src/unc.rs` is base/node/unc.ts with the allowlist Electron's Node checks on every `fs` call (`ERR_UNC_HOST_NOT_ALLOWED`). The port has no patched `fs`, so the check sits on its file seams: disk.rs `path` (the file service, with diskFileSystemProvider.ts's "Please update the 'security.allowedUNCHosts' setting" suffix), the text file models, editor reads and webview resources. Node checks the namespaced path, so `//host/share` counts as UNC and `\\.\` and `\\?\` paths without a host it understands fail closed. main.rs `configure_unc_access` reads `security.restrictUNCAccess` and `security.allowedUNCHosts` once at start as app.ts (a restart applies a change, as upstream's setting text says) and allows the extensions folder's host as main.ts `allowWindowsUNCPath`. The settings register on Windows only (workbench/common/configuration.ts). Not ported yet: windowsMainService.ts's Allow prompt for an opened path, and reads outside these seams (ledger row `app/src/editor_history.rs:59`).
+- UNC hosts: `files/src/unc.rs` is base/node/unc.ts with the allowlist Electron's Node checks on every `fs` call (`ERR_UNC_HOST_NOT_ALLOWED`). The port has no patched `fs`, so the check sits on its file seams: disk.rs `path` (the file service, with diskFileSystemProvider.ts's "Please update the 'security.allowedUNCHosts' setting" suffix), the text file models, editor reads and webview resources. Node checks the namespaced path, so `//host/share` counts as UNC and `\\.\` and `\\?\` paths without a host it understands fail closed. main.rs `configure_unc_access` reads `security.restrictUNCAccess` and `security.allowedUNCHosts` once at start as app.ts (a restart applies a change, as upstream's setting text says) and allows the extensions folder's host as main.ts `allowWindowsUNCPath`. The settings register on Windows only (workbench/common/configuration.ts). The extension host is Node's own `fs` upstream, so `src-uncFsGuard.patch` wraps `fs`, `fs.promises` and `fs/promises` on Windows from the `NODE_UNC_HOST_ALLOWLIST` or `NODE_DISABLE_UNC_ACCESS_CHECKS` the app sets as utilityProcess.ts; Bun's ESM named imports of a builtin do not see changes to its module object, so build-exthost routes the bundle's `fs` imports through `createRequire`. In the app the gate sits before each probe of a path the user did not open (terminal links, problem matcher, quick open's absolute path); Open, Open Recent and `vscode://file` URLs ask with windowsMainService.ts `onUNCHostNotAllowed`. Left as gaps: command line paths, reads inside an opened folder and child process cwds (ledger row `app/src/editor_history.rs:59`).
- Keybindings: `keybindings.rs` `Os` is platform.ts `OperatingSystem`, `OS` the build's; labels, the Electron accelerator and contributed rules (`win`, `mac`, `linux` before `key`, keybindingService.ts `bindToCurrentPlatform`) take it as a parameter so the host tests check Windows. `default-win.json` is the reference's own Windows export ("Developer: Export Default Keybindings" with the platform forced, keybindingsExport.contribution.ts) turned into the port's table by `port/tools/default-keybindings`, which reproduces `default-macos.json` byte for byte from the macOS export; the weights come from the macOS rows. Linux keeps the macOS table until M23 adds `default-linux.json` in `default_table`. Windows has no keyboard mapper yet: labels are the US layout's.
- Menu bar and title bar: on Windows `workbench.rs` `title_bar` adds `menubar.rs` `custom_menubar` at the left and `window_controls` at the right, gated on `keybindings::OS`, so Linux (M23) turns it on by its `OS`. A title opens its `MenubarMainMenu` submenu as the workbench's context menu below it; `compact` opens one menu of the menus. The context keys `isMac`, `isMacNative`, `isWindows` and `isLinux` follow `OS` (`contextkey.rs` `constant_in`), which brings in upstream's Windows-only rows. Difference: Electron's title bar overlay draws the window controls with the system's glyphs; the port draws them with the codicon `chrome-*` glyphs and titlebarpart.css's `.window-icon` hover colors, and marks them with GPUI's `WindowControlArea`, so Windows hit-tests them as caption buttons (`HTMINBUTTON`, `HTMAXBUTTON` with snap layouts, `HTCLOSE`). The rest of the bar is `HTCAPTION`, hit-tested before any listener runs: the menu bar, the command center and the toolbar `occlude` it.