From fe18012d30d1d8b3ffa10c8e321710eba644ef94 Mon Sep 17 00:00:00 2001 From: Lucas Fernandes Nogueira Date: Mon, 4 Mar 2024 21:10:55 -0300 Subject: [PATCH] fix(core): resolve symlink on fs scope check (#9072) --- .changes/fix-fs-scope-check-symlink.md | 5 +++++ core/tauri/src/scope/fs.rs | 8 ++++++++ 2 files changed, 13 insertions(+) create mode 100644 .changes/fix-fs-scope-check-symlink.md diff --git a/.changes/fix-fs-scope-check-symlink.md b/.changes/fix-fs-scope-check-symlink.md new file mode 100644 index 000000000..7804412d4 --- /dev/null +++ b/.changes/fix-fs-scope-check-symlink.md @@ -0,0 +1,5 @@ +--- +"tauri": patch:bug +--- + +Resolve symlinks on the filesystem scope check. diff --git a/core/tauri/src/scope/fs.rs b/core/tauri/src/scope/fs.rs index 1fa281b2b..11af889c2 100644 --- a/core/tauri/src/scope/fs.rs +++ b/core/tauri/src/scope/fs.rs @@ -298,6 +298,14 @@ impl Scope { /// Determines if the given path is allowed on this scope. pub fn is_allowed>(&self, path: P) -> bool { let path = path.as_ref(); + let path = if path.is_symlink() { + match std::fs::read_link(path) { + Ok(p) => p, + Err(_) => return false, + } + } else { + path.to_path_buf() + }; let path = if !path.exists() { crate::Result::Ok(path.to_path_buf()) } else {