fix: Address simpler review comments

This commit is contained in:
timedout committed 2026-11-23 14:43:46 +00:00
1 parent 4dc2c1c63d
commit 304d3ea242
4 files changed
+14 -14

No files matched your search

+3 -7
View File
@@ -22,7 +22,6 @@ use ruma::{
get_remote_server_keys_batch::v2::QueryCriteria, get_server_keys,
},
serde::Raw,
uint,
};
use serde_json::value::to_raw_value;
use service::{server_keys, server_keys::in_one_week};
@@ -59,7 +58,7 @@ pub(crate) async fn get_remote_server_keys_batch_route(
State(services): State<crate::State>,
body: Ruma<get_remote_server_keys_batch::v2::Request>,
) -> Result<get_remote_server_keys_batch::v2::Response> {
query_inner(&services, &body.server_keys, false)
query_inner(&services, &body.server_keys, true)
.await
.map(get_remote_server_keys_batch::v2::Response::new)
}
@@ -102,7 +101,7 @@ async fn query_inner(
let total_queried_servers = body.len();
let total_queried_keys = body
.values()
.fold(body.len(), |acc, q| acc.saturating_add(q.len()));
.fold(0_usize, |acc, q| acc.saturating_add(q.len().max(1)));
if !v2 {
// If we're on the v3 endpoint, we can apply these limits explicitly.
@@ -282,10 +281,7 @@ async fn acquire_keys_as_notary(
continue;
}
let minimum_valid_until_ts = criteria
.clone()
.minimum_valid_until_ts
.unwrap_or_else(|| MilliSecondsSinceUnixEpoch(uint!(0)));
let minimum_valid_until_ts = criteria.clone().minimum_valid_until_ts.unwrap_or(start);
let Some(ssk) = server_keys.get_signing_key(&remote, &key_id).await else {
debug!(%remote, %key_id, "Could not find a matching signing key locally.");
+1 -3
View File
@@ -22,9 +22,7 @@ pub mod unstable {
method: POST,
rate_limited: true,
authentication: ServerSignatures,
history: {
unstable("org.continuwuity.msc4553") => "/_matrix/key/unstable/org.continuwuity.msc4556/query",
}
path: "/_matrix/key/unstable/org.continuwuity.msc4556/query",
}
#[request]
+2 -4
View File
@@ -245,10 +245,8 @@ impl Service {
| None => self.discover_old_signing_keys().await,
};
let valid_until_ts = timepoint_from_now(VALID_UNTIL_TS_DURATION)
.map(|tp| {
MilliSecondsSinceUnixEpoch::from_system_time(tp)
.expect("key validity period must be before the heat death of the universe")
})
.ok()
.and_then(MilliSecondsSinceUnixEpoch::from_system_time)
.expect("key validity period must be before the heat death of the universe");
let server_keys = assign!(
ServerSigningKeys::new(self.services.server.name.clone(), valid_until_ts),
+8
View File
@@ -165,6 +165,14 @@ impl super::Service {
}
}
/// Removes extraneous signatures from the signature map. This is done to avoid
/// leaking the signatures from notaries we've used, in case the response is
/// being forwarded to a third party. This also reduces the risk of accidentally
/// trusting a notary's signature as the origin's signature if `notaries` is
/// empty.
///
/// Infallible & mutates the original canonical JSON object. Signatures by
/// server names that cannot be parsed are always removed.
pub fn strip_extraneous_signatures(
canonical: &mut CanonicalJsonObject,
origin: &ServerName,