mirror of
https://github.com/dani-garcia/vaultwarden.wiki.git
synced 2026-11-23 02:59:38 +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
+14
-16
@@ -161,13 +161,9 @@ pub fn should_block_host<S: AsRef<str>>(host: &Host<S>) -> Result<(), CustomHttp
|
||||
});
|
||||
}
|
||||
|
||||
if should_block_address_regex(&host_str) {
|
||||
return Err(CustomHttpClientError::Blocked {
|
||||
domain: host_str,
|
||||
});
|
||||
}
|
||||
|
||||
Ok(())
|
||||
(!should_block_address_regex(&host_str)).ok_or(CustomHttpClientError::Blocked {
|
||||
domain: host_str,
|
||||
})
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -211,7 +207,7 @@ impl CustomHttpClientError {
|
||||
|
||||
while let Some(err) = source {
|
||||
source = err.source();
|
||||
if let Some(err) = err.downcast_ref::<CustomHttpClientError>() {
|
||||
if let Some(err) = err.downcast_ref::<Self>() {
|
||||
return Some(err);
|
||||
}
|
||||
}
|
||||
@@ -258,7 +254,7 @@ impl CustomDns {
|
||||
fn instance(enforce_block: bool) -> Self {
|
||||
static INSTANCE: LazyLock<Arc<CustomDnsResolver>> = LazyLock::new(CustomDnsResolver::new);
|
||||
|
||||
CustomDns {
|
||||
Self {
|
||||
enforce_block,
|
||||
resolver: Arc::clone(&*INSTANCE),
|
||||
}
|
||||
@@ -409,7 +405,7 @@ pub(crate) mod aws {
|
||||
Ok(HttpResponse::new(status, bytes.into()))
|
||||
};
|
||||
|
||||
HttpConnectorFuture::new(Box::pin(future))
|
||||
HttpConnectorFuture::new(future)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -419,7 +415,7 @@ pub(crate) mod aws {
|
||||
_settings: &HttpConnectorSettings,
|
||||
_components: &RuntimeComponents,
|
||||
) -> SharedHttpConnector {
|
||||
SharedHttpConnector::new(AwsReqwestConnector {
|
||||
SharedHttpConnector::new(Self {
|
||||
client: self.client.clone(),
|
||||
})
|
||||
}
|
||||
@@ -430,8 +426,10 @@ pub(crate) mod aws {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::util::is_global_hardcoded;
|
||||
use std::net::{Ipv4Addr, Ipv6Addr};
|
||||
use url::Host;
|
||||
use std::{
|
||||
assert_matches,
|
||||
net::{Ipv4Addr, Ipv6Addr},
|
||||
};
|
||||
|
||||
// ===
|
||||
// IPv4 numeric-format normalization
|
||||
@@ -535,19 +533,19 @@ mod tests {
|
||||
#[test]
|
||||
fn get_valid_host_normalizes_decimal_int() {
|
||||
let h = get_valid_host("2130706433").expect("valid");
|
||||
assert!(matches!(h, Host::Ipv4(ip) if ip == Ipv4Addr::LOCALHOST));
|
||||
assert_matches!(h, Host::Ipv4(ip) if ip == Ipv4Addr::LOCALHOST);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn get_valid_host_normalizes_hex() {
|
||||
let h = get_valid_host("0x7f000001").expect("valid");
|
||||
assert!(matches!(h, Host::Ipv4(ip) if ip == Ipv4Addr::LOCALHOST));
|
||||
assert_matches!(h, Host::Ipv4(ip) if ip == Ipv4Addr::LOCALHOST);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn get_valid_host_normalizes_octal() {
|
||||
let h = get_valid_host("017700000001").expect("valid");
|
||||
assert!(matches!(h, Host::Ipv4(ip) if ip == Ipv4Addr::LOCALHOST));
|
||||
assert_matches!(h, Host::Ipv4(ip) if ip == Ipv4Addr::LOCALHOST);
|
||||
}
|
||||
|
||||
// ===
|
||||
|
||||
Reference in new issue
Block a user