mirror of
https://github.com/dani-garcia/vaultwarden.wiki.git
synced 2026-11-23 17:49:40 +02:00
Modernize Rust code and Fixes (#7971)
* Modernize Rust code and fix input handling - Adopt newer std APIs, reduce allocations, and consolidate caching on Moka. - Update the Rust toolchain and most dependencies, tighten lints, and expand test coverage. - Fix favicon ranking for URLs with query strings or fragments, and try the next icon when SVG sanitization fails. - Prevent panics when masking 2FA email addresses containing Unicode or missing an @. - Prevent panics on Unicode database paths and recognize short postgres: URLs. - Treat whitespace-only collection and member external IDs as absent and avoid redundant membership updates. - Align stable builds’ global IP classification with Rust’s standard library. Signed-off-by: BlackDex <black.dex@gmail.com> * Update crates and some fixes - Bump Rocket, rocket_ws, Diesel, SQLite bindings, and html5gum. - Reuse WebSocket payload buffers and detect upgrades from the response. - Match favicon rel tokens case-insensitively, honor the first base href, and stop scanning at the end of the head or the start of the body. Signed-off-by: BlackDex <black.dex@gmail.com> --------- Signed-off-by: BlackDex <black.dex@gmail.com>
This commit is contained in:
1 parent
4051a4d3a6
commit
4a0acc3314
51 files changed
+1219
-1569
No files matched your search
+13
-8
@@ -147,7 +147,7 @@ impl User {
|
||||
verified_at: None,
|
||||
last_verifying_at: None,
|
||||
login_verify_count: 0,
|
||||
name: name.unwrap_or(email.clone()),
|
||||
name: name.unwrap_or_else(|| email.clone()),
|
||||
email,
|
||||
akey: String::new(),
|
||||
email_new: None,
|
||||
@@ -222,15 +222,11 @@ impl User {
|
||||
}
|
||||
|
||||
pub fn check_valid_recovery_code(&self, recovery_code: &str) -> bool {
|
||||
if let Some(ref totp_recover) = self.totp_recover {
|
||||
crypto::ct_eq(recovery_code, totp_recover.to_lowercase())
|
||||
} else {
|
||||
false
|
||||
}
|
||||
self.totp_recover.as_ref().is_some_and(|c| crypto::ct_eq(recovery_code, c.to_lowercase()))
|
||||
}
|
||||
|
||||
pub fn check_valid_api_key(&self, key: &str) -> bool {
|
||||
matches!(self.api_key, Some(ref api_key) if crypto::ct_eq(api_key, key))
|
||||
self.api_key.as_ref().is_some_and(|k| crypto::ct_eq(key, k))
|
||||
}
|
||||
|
||||
/// Set the password hash generated
|
||||
@@ -290,7 +286,7 @@ impl User {
|
||||
grace.push(UserStampException {
|
||||
routes: None,
|
||||
security_stamp: previous_stamp,
|
||||
expire: (Utc::now() + *DEFAULT_ACCESS_VALIDITY).timestamp(),
|
||||
expire: (Utc::now() + DEFAULT_ACCESS_VALIDITY).timestamp(),
|
||||
});
|
||||
let mut exceptions = self.stamp_exceptions();
|
||||
exceptions.extend(grace);
|
||||
@@ -773,6 +769,15 @@ mod tests {
|
||||
.args(["--exact", std::thread::current().name().unwrap(), "--nocapture"])
|
||||
.env("VAULTWARDEN_ISOLATED_CONFIG_TEST", "1")
|
||||
.env("DATABASE_URL", "sqlite://:memory:")
|
||||
// Keep a local `.env` out of the tests, such as SMTP settings that would send mail.
|
||||
.env(
|
||||
"ENV_FILE",
|
||||
if cfg!(windows) {
|
||||
"NUL"
|
||||
} else {
|
||||
"/dev/null"
|
||||
},
|
||||
)
|
||||
.output()
|
||||
.unwrap();
|
||||
assert!(
|
||||
|
||||
Reference in new issue
Block a user