Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: set remap-path-prefix, closes #6538 #6543

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/cli.remap-path-prefix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"cli.rs": "patch"
---

Configure the rust compiler to truncate absolute paths in panic messages and debug symbols when building in release mode. This prevents a possible leak of PII through absolute paths.
19 changes: 19 additions & 0 deletions tooling/cli/src/interface/rust/desktop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,25 @@ fn build_command(
build_cmd.arg("build");
build_cmd.args(args);

// set the rust --remap-path-prefix flags to strip absolute paths that could leak usernames or other PII from panic messages and debug symbols
// see https://github.com/tauri-apps/tauri/issues/6538 for context
let mut rustflags = std::env::var("RUSTFLAGS").unwrap_or_default();

rustflags.push_str(&format!(
" --remap-path-prefix={}=",
std::env::current_dir().unwrap().display()
));
rustflags.push_str(&format!(
" --remap-path-prefix={}=cargo",
env!("CARGO_HOME")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The env! macro inspects the env variable at compile time. We should use std::env::var instead.

));
rustflags.push_str(&format!(
" --remap-path-prefix={}=rustup",
env!("RUSTUP_HOME")
));

build_cmd.envs([("RUSTFLAGS", rustflags)]);

Ok(build_cmd)
}

Expand Down