GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(files): stop executing outside-workspace file links and block UNC… · anomalyco/opencode-rune@ae3e910

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Cargo.lock
  • apps
    • browser-engine
      • Cargo.lock
      • src
        • engine.rs
        • preview
          • handle_path.rs
    • desktop/src
      • plugin_host
        • bridge
          • requests.rs
        • mod.rs
      • shell
        • chrome
          • status_toast.rs
        • view
          • home
            • projects.rs
          • location_card.rs
          • session
            • host.rs
      • surfaces
        • browser
          • mod.rs
        • files
          • mod.rs
          • reply.rs
      • workspace/system
        • open_in.rs
  • crates
    • browser-policy
      • Cargo.toml
      • src
        • lib.rs
        • local_fs
          • mod.rs
          • unix.rs
          • windows.rs
        • local_path.rs
        • workspace_root.rs
    • opencode-plugin-runtime
      • Cargo.toml
      • src
        • reveal.rs
    • session-view
      • Cargo.toml
      • src/images
        • drag.rs
        • menu.rs
  • features
    • files
      • Cargo.toml
      • src
        • code_paths.rs
        • host.rs
        • links.rs
        • ops.rs
        • video.rs
    • open-in
      • Cargo.toml
      • src
        • lib.rs
        • windows.rs
    • settings/src/pages
      • project.rs
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Cargo.lock‎

Copy file name to clipboardExpand all lines: Cargo.lock
+6Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎apps/browser-engine/Cargo.lock‎

Copy file name to clipboardExpand all lines: apps/browser-engine/Cargo.lock
+2Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎apps/browser-engine/src/engine.rs‎

Copy file name to clipboardExpand all lines: apps/browser-engine/src/engine.rs
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1372,7 +1372,7 @@ impl EngineManager {
13721372
fn safe_roots(&self, roots: Vec<String>) -> Vec<String> {
13731373
roots
13741374
.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()))
13761376
.collect()
13771377
}
13781378

Collapse file

‎apps/browser-engine/src/preview/handle_path.rs‎

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 numberDiff line numberDiff line change
@@ -203,20 +203,11 @@ mod os {
203203
) -> i32;
204204
}
205205

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-
217206
/// 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.
220211
fn verify_reparse_tag(handle: HANDLE, attrs: u32) -> Result<bool, OpenErr> {
221212
if (attrs & FILE_ATTRIBUTE_REPARSE_POINT.0) == 0 {
222213
return Ok(false);
@@ -230,7 +221,7 @@ mod os {
230221
size_of::<FILE_ATTRIBUTE_TAG_INFO>() as u32,
231222
)
232223
};
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) {
234225
return Err(OpenErr::Denied);
235226
}
236227
Ok(true)
Collapse file

‎apps/desktop/src/plugin_host/bridge/requests.rs‎

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 numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ fn apply(app: &mut App, plugin: &std::rc::Rc<str>, request: Request, tx: &mut Tx
192192
}
193193
}
194194
}
195-
Request::Reveal(path) => crate::plugin_host::reveal(&path),
195+
Request::Reveal(path) => crate::open_in::reveal_abs(app, path),
196196
Request::CopyText(text) => tx.copy(text),
197197
// A muted session, or one under a muted root, shows nothing (`host-apis.tsx`'s notify).
198198
Request::Notify { session: Some(id), .. } if crate::session_menu::preferences::silenced(app, crate::servers::runtime::active(app), &id) => {}
Collapse file

‎apps/desktop/src/plugin_host/mod.rs‎

Copy file name to clipboardExpand all lines: apps/desktop/src/plugin_host/mod.rs
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub(crate) mod runtime;
2424
pub mod services;
2525
pub(crate) mod ui;
2626

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};
2828

2929
pub use bridge::{commands, console, cx, project_request, requests, server_sources, servers, stores};
3030
pub(crate) use bridge::contrib;
@@ -52,7 +52,6 @@ pub use contrib::{
5252
pub use flyout::{Flyout, FlyoutEvent, Overlay};
5353
pub use machines::{Hot, HotEffect, Life, LifeEffect, LifeEvent, Trust, TrustEffect, TrustEvent};
5454
pub use plugin::Half;
55-
pub use reveal::reveal;
5655
pub use runtime::boot::{boot_builtin, doze_owed, first_frame, setup};
5756
pub use runtime::lifecycle::{drive, fire_named, poll, reload, step_trust, toggle};
5857
pub use servers::{
Collapse file

‎apps/desktop/src/shell/chrome/status_toast.rs‎

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 numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ impl ToastHost for App {
181181
}
182182

183183
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());
185185
}
186186
}
187187

Collapse file

‎apps/desktop/src/shell/view/home/projects.rs‎

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 numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ pub(crate) fn open_project_menu(s: &mut App, id: &str, anchor: String, tx: &mut
220220
Some("history") => super::browse::history(s, &server, &proj, tx),
221221
Some("reveal") => {
222222
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 {
224224
let name = super::super::project_or_dir(Some(&proj), &proj.directory);
225225
crate::status_toast::fail(
226226
s,
Collapse file

‎apps/desktop/src/shell/view/location_card.rs‎

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 numberDiff line numberDiff line change
@@ -319,16 +319,24 @@ pub(crate) fn reveal_label() -> &'static str {
319319
opencode_i18n::t!("session.header.reveal.containingFolder")
320320
}
321321

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>`).
323330
pub(crate) fn reveal(dir: &str) -> Result<(), String> {
324331
if crate::headless() {
325332
return Ok(());
326333
}
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())
334342
}
Collapse file

‎apps/desktop/src/shell/view/session/host.rs‎

Copy file name to clipboardExpand all lines: apps/desktop/src/shell/view/session/host.rs
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,16 @@ impl session_view::TimelineHost for App {
173173
fn open_link(&mut self, url: &str, tx: &mut Tx) {
174174
self.open_reply_link(url, tx);
175175
}
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+
}
176186
fn reply_link_menu(&mut self, url: &str, press: rune::PointerPress, tx: &mut Tx) -> bool {
177187
crate::files::reply::menu(self, url, press, tx)
178188
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.