Skip to content

Commit a73a9a8

Browse files
Redact login cookie in error toast
1 parent 33da75a commit a73a9a8

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src-tauri/src/lib.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ type Error = Box<dyn std::error::Error>;
3030
type Result<T> = std::result::Result<T, Error>;
3131
type CommandResult<T> = std::result::Result<T, String>;
3232

33+
static LOGIN_COOKIE_REGEX: LazyLock<Regex> = LazyLock::new(|| Regex::new(r#"-t (\S+)"#).unwrap());
34+
3335
static VERSION_NUMBER_REGEX: LazyLock<Regex> =
3436
LazyLock::new(|| Regex::new(r"^v?\d+(?:\.\d)*$").unwrap());
3537
const UPDATE_CHECK_URL: &str =
@@ -104,9 +106,13 @@ async fn do_launch(app_handle: tauri::AppHandle) -> CommandResult<i32> {
104106
let cmd_str = util::get_launch_cmd_dbg_str(&cmd, false);
105107
drop(state);
106108

107-
let mut proc = cmd
108-
.spawn()
109-
.map_err(|e| format!("{} (launch command was: {})", e, cmd_str))?;
109+
let mut proc = cmd.spawn().map_err(|e| {
110+
// we want to censor the login cookie if present
111+
let censored_cmd_str = LOGIN_COOKIE_REGEX
112+
.replace_all(&cmd_str, "-t ***")
113+
.to_string();
114+
format!("{} (launch command was: {})", e, censored_cmd_str)
115+
})?;
110116
if launch_behavior == LaunchBehavior::Quit {
111117
app_handle.exit(0);
112118
return Ok(0);

0 commit comments

Comments
 (0)