GeezerVison is showing github.com — fix(files): stop executing outside-workspace file links and block UNC… · anomalyco/opencode-rune@ae3e910
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: Cargo.lock +6Lines changed: 6 additions & 0 deletions Collapse file Copy file name to clipboardExpand all lines: apps/browser-engine/Cargo.lock +2Lines changed: 2 additions & 0 deletions Collapse file Copy file name to clipboardExpand all lines: apps/browser-engine/src/engine.rs +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -1372,7 +1372,7 @@ impl EngineManager { | 1372 | 1372 | fn safe_roots(&self, roots: Vec<String>) -> Vec<String> { | 1373 | 1373 | roots | 1374 | 1374 | .into_iter() | 1375 | | - .filter(|r| browser_policy::is_safe_workspace_root(r, self.home.as_deref())) | | 1375 | + .filter(|r| browser_policy::is_safe_local_workspace_root(r, self.home.as_deref())) | 1376 | 1376 | .collect() | 1377 | 1377 | } | 1378 | 1378 |
| |
Collapse file Copy file name to clipboardExpand all lines: apps/browser-engine/src/preview/handle_path.rs +5-14Lines changed: 5 additions & 14 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -203,20 +203,11 @@ mod os { | 203 | 203 | ) -> i32; | 204 | 204 | } | 205 | 205 |
| 206 | | - /// Allow-lists ONLY non-redirecting Windows Cloud Filter placeholder tags (`IO_REPARSE_TAG_CLOUD*` | 207 | | - /// and legacy `IO_REPARSE_TAG_ONEDRIVE`). Strictly refuses every name-surrogate / redirecting tag | 208 | | - /// (bit 29 `0x2000_0000`: symlinks, junctions, volume mount points, WSL symlinks), `APPEXECLINK`, | 209 | | - /// and every unknown tag (`notes/review-rd281.md` Finding #2). | 210 | | - fn is_allowed_cloud_reparse_tag(tag: u32) -> bool { | 211 | | - if (tag & 0x2000_0000) != 0 { | 212 | | - return false; | 213 | | - } | 214 | | - (tag & !0x0000_F000) == 0x9000_001A || tag == 0x8000_0021 | 215 | | - } | 216 | | - | 217 | 206 | /// Inspects `FileAttributeTagInfo` whenever `FILE_ATTRIBUTE_REPARSE_POINT` is set. | 218 | | - /// Returns `Ok(true)` for an allowed Cloud Filter placeholder, `Ok(false)` for a regular | 219 | | - /// non-reparse entry, and `Err(OpenErr::Denied)` for symlinks, junctions, mount points, or unknown tags. | | 207 | + /// Returns `Ok(true)` for an allowed non-redirecting local reparse entry (Cloud Filter, | | 208 | + /// legacy OneDrive, WOF compression, or NTFS deduplication), `Ok(false)` for a regular | | 209 | + /// non-reparse entry, and `Err(OpenErr::Denied)` for symlinks, junctions, mount points, | | 210 | + /// `APPEXECLINK`, or unknown tags. | 220 | 211 | fn verify_reparse_tag(handle: HANDLE, attrs: u32) -> Result<bool, OpenErr> { | 221 | 212 | if (attrs & FILE_ATTRIBUTE_REPARSE_POINT.0) == 0 { | 222 | 213 | return Ok(false); | @@ -230,7 +221,7 @@ mod os { | 230 | 221 | size_of::<FILE_ATTRIBUTE_TAG_INFO>() as u32, | 231 | 222 | ) | 232 | 223 | }; | 233 | | - if ok.is_err() || !is_allowed_cloud_reparse_tag(tag_info.ReparseTag) { | | 224 | + if ok.is_err() || !browser_policy::is_allowed_local_reparse_tag(tag_info.ReparseTag) { | 234 | 225 | return Err(OpenErr::Denied); | 235 | 226 | } | 236 | 227 | Ok(true) | |
Collapse file Copy file name to clipboardExpand all lines: apps/desktop/src/plugin_host/bridge/requests.rs +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -192,7 +192,7 @@ fn apply(app: &mut App, plugin: &std::rc::Rc<str>, request: Request, tx: &mut Tx | 192 | 192 | } | 193 | 193 | } | 194 | 194 | } | 195 | | - Request::Reveal(path) => crate::plugin_host::reveal(&path), | | 195 | + Request::Reveal(path) => crate::open_in::reveal_abs(app, path), | 196 | 196 | Request::CopyText(text) => tx.copy(text), | 197 | 197 | // A muted session, or one under a muted root, shows nothing (`host-apis.tsx`'s notify). | 198 | 198 | Request::Notify { session: Some(id), .. } if crate::session_menu::preferences::silenced(app, crate::servers::runtime::active(app), &id) => {} | |
Collapse file Copy file name to clipboardExpand all lines: apps/desktop/src/plugin_host/mod.rs +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -24,7 +24,7 @@ pub(crate) mod runtime; | 24 | 24 | pub mod services; | 25 | 25 | pub(crate) mod ui; | 26 | 26 |
| 27 | | -pub use opencode_plugin_runtime::{catalogs, flyout, icons, images, machines, process, reveal, tasks}; | | 27 | +pub use opencode_plugin_runtime::{catalogs, flyout, icons, images, machines, process, tasks}; | 28 | 28 |
| 29 | 29 | pub use bridge::{commands, console, cx, project_request, requests, server_sources, servers, stores}; | 30 | 30 | pub(crate) use bridge::contrib; | @@ -52,7 +52,6 @@ pub use contrib::{ | 52 | 52 | pub use flyout::{Flyout, FlyoutEvent, Overlay}; | 53 | 53 | pub use machines::{Hot, HotEffect, Life, LifeEffect, LifeEvent, Trust, TrustEffect, TrustEvent}; | 54 | 54 | pub use plugin::Half; | 55 | | -pub use reveal::reveal; | 56 | 55 | pub use runtime::boot::{boot_builtin, doze_owed, first_frame, setup}; | 57 | 56 | pub use runtime::lifecycle::{drive, fire_named, poll, reload, step_trust, toggle}; | 58 | 57 | pub use servers::{ | |
Collapse file Copy file name to clipboardExpand all lines: apps/desktop/src/shell/chrome/status_toast.rs +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -181,7 +181,7 @@ impl ToastHost for App { | 181 | 181 | } | 182 | 182 |
| 183 | 183 | fn reveal_path(&mut self, path: &Path) { | 184 | | - crate::plugin_host::reveal(&path.to_string_lossy()); | | 184 | + crate::open_in::reveal_abs(self, path.to_string_lossy().into_owned()); | 185 | 185 | } | 186 | 186 | } | 187 | 187 |
| |
Collapse file Copy file name to clipboardExpand all lines: apps/desktop/src/shell/view/home/projects.rs +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -220,7 +220,7 @@ pub(crate) fn open_project_menu(s: &mut App, id: &str, anchor: String, tx: &mut | 220 | 220 | Some("history") => super::browse::history(s, &server, &proj, tx), | 221 | 221 | Some("reveal") => { | 222 | 222 | if let Err(e) = super::super::location_card::reveal(&proj.directory) { | 223 | | - if !std::path::Path::new(&proj.directory).exists() { | | 223 | + if e == super::super::location_card::MISSING_DIR_ERR { | 224 | 224 | let name = super::super::project_or_dir(Some(&proj), &proj.directory); | 225 | 225 | crate::status_toast::fail( | 226 | 226 | s, | |
Collapse file Copy file name to clipboardExpand all lines: apps/desktop/src/shell/view/location_card.rs +16-8Lines changed: 16 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -319,16 +319,24 @@ pub(crate) fn reveal_label() -> &'static str { | 319 | 319 | opencode_i18n::t!("session.header.reveal.containingFolder") | 320 | 320 | } | 321 | 321 |
| 322 | | -/// Shows folder `dir` in the system's file manager; a headless run opens nothing. | | 322 | +/// Error string returned by [`reveal`] when a verified local path does not exist on disk, | | 323 | +/// so callers never need to touch `Path::exists()` on a refused UNC/mapped/reparse path. | | 324 | +pub(crate) const MISSING_DIR_ERR: &str = "Path doesn't exist"; | | 325 | + | | 326 | +/// Shows folder `dir` in the system's file manager; a headless run opens nothing. Verifies local | | 327 | +/// fixed drive / `MNT_LOCAL`, non-`subst`-UNC, zero symlinks/reparse points, directory kind, and | | 328 | +/// non-bundle on macOS BEFORE touching disk, then reveals via `browser_policy::reveal_in_file_manager` | | 329 | +/// (never spawns bare `explorer.exe <path>` or `/usr/bin/open <path>`). | 323 | 330 | pub(crate) fn reveal(dir: &str) -> Result<(), String> { | 324 | 331 | if crate::headless() { | 325 | 332 | return Ok(()); | 326 | 333 | } | 327 | | - #[cfg(target_os = "windows")] | 328 | | - let mut cmd = std::process::Command::new("explorer.exe"); | 329 | | - #[cfg(target_os = "macos")] | 330 | | - let mut cmd = std::process::Command::new("/usr/bin/open"); | 331 | | - #[cfg(not(any(target_os = "windows", target_os = "macos")))] | 332 | | - let mut cmd = std::process::Command::new("xdg-open"); | 333 | | - cmd.arg(dir).spawn().map(|_| ()).map_err(|e| e.to_string()) | | 334 | + let verified = browser_policy::verify_local_path(dir).map_err(|e| match e { | | 335 | + browser_policy::LocalPathError::NotFound => MISSING_DIR_ERR.to_owned(), | | 336 | + other => other.to_string(), | | 337 | + })?; | | 338 | + if !verified.is_dir || browser_policy::is_macos_bundle(&verified.path) { | | 339 | + return Err("Path is not a local folder".into()); | | 340 | + } | | 341 | + browser_policy::reveal_in_file_manager(&verified.path).map(|_| ()).map_err(|e| e.to_string()) | 334 | 342 | } |
Collapse file Copy file name to clipboardExpand all lines: apps/desktop/src/shell/view/session/host.rs +10Lines changed: 10 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -173,6 +173,16 @@ impl session_view::TimelineHost for App { | 173 | 173 | fn open_link(&mut self, url: &str, tx: &mut Tx) { | 174 | 174 | self.open_reply_link(url, tx); | 175 | 175 | } | | 176 | + fn open_file(&mut self, path: std::path::PathBuf) { | | 177 | + crate::open_in::reveal_abs(self, path.to_string_lossy().into_owned()); | | 178 | + } | | 179 | + fn reveal_file(&mut self, path: &std::path::Path) -> bool { | | 180 | + let Ok(verified) = browser_policy::verify_local_path(&path.to_string_lossy()) else { | | 181 | + return false; | | 182 | + }; | | 183 | + crate::open_in::reveal_abs(self, verified.path); | | 184 | + true | | 185 | + } | 176 | 186 | fn reply_link_menu(&mut self, url: &str, press: rune::PointerPress, tx: &mut Tx) -> bool { | 177 | 187 | crate::files::reply::menu(self, url, press, tx) | 178 | 188 | } | |
|