From 468cec0edfc17284681bca20239902f9555a054b Mon Sep 17 00:00:00 2001 From: Jordon Date: Sat, 16 May 2026 09:55:35 +0100 Subject: [PATCH 01/17] fix(logging): warn on log directory creation failure Instead of silently swallowing the error with let _ =, log a warning when the log directory cannot be created. --- Backend/src/logging.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Backend/src/logging.rs b/Backend/src/logging.rs index 0171ed3..22beabb 100644 --- a/Backend/src/logging.rs +++ b/Backend/src/logging.rs @@ -337,7 +337,9 @@ pub fn init() { let dir = crate::app_identity::project_dirs() .map(|pd| pd.data_dir().join("logs")) .unwrap_or_else(|| std::path::PathBuf::from("logs")); - let _ = fs::create_dir_all(&dir); // best effort + if let Err(e) = fs::create_dir_all(&dir) { + log::warn!("logging: failed to create log directory '{}': {e}", dir.display()); + } rotate_existing_log(&dir); prune_archives(&dir, cfg.logging.retain_archives as usize); From 1c79ff05107a8b82de855cac56604c8ee6e7b6b1 Mon Sep 17 00:00:00 2001 From: Jordon Date: Sat, 16 May 2026 09:55:49 +0100 Subject: [PATCH 02/17] fix(validate): replace unwrap with expect for regex compilation Hardcoded regex patterns are virtually always valid, but unwrap in production code is a latent panic vector. Use expect with descriptive messages instead. --- Backend/src/validate.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Backend/src/validate.rs b/Backend/src/validate.rs index 8f79522..9e11617 100644 --- a/Backend/src/validate.rs +++ b/Backend/src/validate.rs @@ -5,11 +5,11 @@ use std::sync::LazyLock; /// Regex pattern for scp-like VCS URLs. static SCP_LIKE_RE: LazyLock = - LazyLock::new(|| regex::Regex::new(r"^[\w.-]+@[\w.-]+:[\w./-]+(?:\.git)?$").unwrap()); + LazyLock::new(|| regex::Regex::new(r"^[\w.-]+@[\w.-]+:[\w./-]+(?:\.git)?$").expect("hardcoded SCP-like regex is valid")); /// Regex pattern for Windows absolute paths. static WIN_ABS_RE: LazyLock = - LazyLock::new(|| regex::Regex::new(r"^[A-Za-z]:[\\/]").unwrap()); + LazyLock::new(|| regex::Regex::new(r"^[A-Za-z]:[\\/]").expect("hardcoded Windows path regex is valid")); #[derive(serde::Serialize)] pub struct Validation { From 20b7fae24d32d6616ee97bcb0a6b229d76505bab Mon Sep 17 00:00:00 2001 From: Jordon Date: Sat, 16 May 2026 09:55:51 +0100 Subject: [PATCH 03/17] fix(themes): sanitize theme markup to prevent script injection Add sanitizeThemeMarkup() that strips