Policy checks and alsl remove assertatte ion

(cherry picked from commit f0ff0e4599c3db8786693e43691b164bb0b7e3c3)
This commit is contained in:
nexy7574 2025-06-20 01:27:21 +01:00
parent 33fbc43f76
commit 333ad204ea
No known key found for this signature in database
GPG key ID: 0FA334385D0B689F
4 changed files with 34 additions and 15 deletions

22
Cargo.lock generated
View file

@ -3695,7 +3695,7 @@ dependencies = [
[[package]]
name = "ruma"
version = "0.10.1"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=1faaf474b122159a04518214e8248b465dae06c9#1faaf474b122159a04518214e8248b465dae06c9"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=8ea4885e34a61fa4b7c0bb38b39ec66a772d89a6#8ea4885e34a61fa4b7c0bb38b39ec66a772d89a6"
dependencies = [
"assign",
"js_int",
@ -3715,7 +3715,7 @@ dependencies = [
[[package]]
name = "ruma-appservice-api"
version = "0.10.0"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=1faaf474b122159a04518214e8248b465dae06c9#1faaf474b122159a04518214e8248b465dae06c9"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=8ea4885e34a61fa4b7c0bb38b39ec66a772d89a6#8ea4885e34a61fa4b7c0bb38b39ec66a772d89a6"
dependencies = [
"js_int",
"ruma-common",
@ -3727,7 +3727,7 @@ dependencies = [
[[package]]
name = "ruma-client-api"
version = "0.18.0"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=1faaf474b122159a04518214e8248b465dae06c9#1faaf474b122159a04518214e8248b465dae06c9"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=8ea4885e34a61fa4b7c0bb38b39ec66a772d89a6#8ea4885e34a61fa4b7c0bb38b39ec66a772d89a6"
dependencies = [
"as_variant",
"assign",
@ -3750,7 +3750,7 @@ dependencies = [
[[package]]
name = "ruma-common"
version = "0.13.0"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=1faaf474b122159a04518214e8248b465dae06c9#1faaf474b122159a04518214e8248b465dae06c9"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=8ea4885e34a61fa4b7c0bb38b39ec66a772d89a6#8ea4885e34a61fa4b7c0bb38b39ec66a772d89a6"
dependencies = [
"as_variant",
"base64 0.22.1",
@ -3782,7 +3782,7 @@ dependencies = [
[[package]]
name = "ruma-events"
version = "0.28.1"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=1faaf474b122159a04518214e8248b465dae06c9#1faaf474b122159a04518214e8248b465dae06c9"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=8ea4885e34a61fa4b7c0bb38b39ec66a772d89a6#8ea4885e34a61fa4b7c0bb38b39ec66a772d89a6"
dependencies = [
"as_variant",
"indexmap 2.9.0",
@ -3807,7 +3807,7 @@ dependencies = [
[[package]]
name = "ruma-federation-api"
version = "0.9.0"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=1faaf474b122159a04518214e8248b465dae06c9#1faaf474b122159a04518214e8248b465dae06c9"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=8ea4885e34a61fa4b7c0bb38b39ec66a772d89a6#8ea4885e34a61fa4b7c0bb38b39ec66a772d89a6"
dependencies = [
"bytes",
"headers",
@ -3829,7 +3829,7 @@ dependencies = [
[[package]]
name = "ruma-identifiers-validation"
version = "0.9.5"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=1faaf474b122159a04518214e8248b465dae06c9#1faaf474b122159a04518214e8248b465dae06c9"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=8ea4885e34a61fa4b7c0bb38b39ec66a772d89a6#8ea4885e34a61fa4b7c0bb38b39ec66a772d89a6"
dependencies = [
"js_int",
"thiserror 2.0.12",
@ -3838,7 +3838,7 @@ dependencies = [
[[package]]
name = "ruma-identity-service-api"
version = "0.9.0"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=1faaf474b122159a04518214e8248b465dae06c9#1faaf474b122159a04518214e8248b465dae06c9"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=8ea4885e34a61fa4b7c0bb38b39ec66a772d89a6#8ea4885e34a61fa4b7c0bb38b39ec66a772d89a6"
dependencies = [
"js_int",
"ruma-common",
@ -3848,7 +3848,7 @@ dependencies = [
[[package]]
name = "ruma-macros"
version = "0.13.0"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=1faaf474b122159a04518214e8248b465dae06c9#1faaf474b122159a04518214e8248b465dae06c9"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=8ea4885e34a61fa4b7c0bb38b39ec66a772d89a6#8ea4885e34a61fa4b7c0bb38b39ec66a772d89a6"
dependencies = [
"cfg-if",
"proc-macro-crate",
@ -3863,7 +3863,7 @@ dependencies = [
[[package]]
name = "ruma-push-gateway-api"
version = "0.9.0"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=1faaf474b122159a04518214e8248b465dae06c9#1faaf474b122159a04518214e8248b465dae06c9"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=8ea4885e34a61fa4b7c0bb38b39ec66a772d89a6#8ea4885e34a61fa4b7c0bb38b39ec66a772d89a6"
dependencies = [
"js_int",
"ruma-common",
@ -3875,7 +3875,7 @@ dependencies = [
[[package]]
name = "ruma-signatures"
version = "0.15.0"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=1faaf474b122159a04518214e8248b465dae06c9#1faaf474b122159a04518214e8248b465dae06c9"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=8ea4885e34a61fa4b7c0bb38b39ec66a772d89a6#8ea4885e34a61fa4b7c0bb38b39ec66a772d89a6"
dependencies = [
"base64 0.22.1",
"ed25519-dalek",

View file

@ -350,7 +350,7 @@ version = "0.1.2"
[workspace.dependencies.ruma]
git = "https://forgejo.ellis.link/continuwuation/ruwuma"
#branch = "conduwuit-changes"
rev = "1faaf474b122159a04518214e8248b465dae06c9"
rev = "8ea4885e34a61fa4b7c0bb38b39ec66a772d89a6"
features = [
"compat",
"rand",

View file

@ -43,13 +43,13 @@ pub async fn policyserv_check(&self, pdu: &PduEvent, room_id: &RoomId) -> Result
// return Err!(Request(InvalidParam("Failed to convert PDU to outgoing event.")));
// },
// };
debug!("Checking pdu {outgoing:?} for spam with policy server {via} for room {room_id}");
let response = self
.services
.sending
.send_federation_request(via, PolicyRequest {
event_id: pdu.event_id().to_owned(),
// pdu: Some(outgoing),
pdu: None, // TODO: figure out why providing the PDU makes the signature invalid
pdu: Some(outgoing),
})
.await;
let response = match response {

View file

@ -698,6 +698,20 @@ impl Service {
.await
.saturating_add(uint!(1));
if state_key.is_none() {
if prev_events.is_empty() {
warn!("Timeline event had zero prev_events, something broke.");
return Err!(Request(Unknown("Timeline event had zero prev_events.")));
}
if depth.le(&uint!(2)) {
warn!(
"Had unsafe depth of {depth} in {room_id} when creating non-state event. \
Bad!"
);
return Err!(Request(Unknown("Unsafe depth for non-state event.")));
}
};
let mut unsigned = unsigned.unwrap_or_default();
if let Some(state_key) = &state_key {
@ -757,6 +771,10 @@ impl Service {
ready(auth_events.get(&key))
};
debug!(
"running auth check on new {} event by {} in {}",
pdu.kind, pdu.sender, pdu.room_id
);
let auth_check = state_res::auth_check(
&room_version,
&pdu,
@ -961,8 +979,9 @@ impl Service {
state_lock: &'a RoomMutexGuard,
) -> Result<Option<RawPduId>>
where
Leaves: Iterator<Item = &'a EventId> + Send + 'a,
Leaves: Iterator<Item = &'a EventId> + Send + Clone + 'a,
{
// assert!(new_room_leaves.clone().count() > 0, "extremities are empty");
// We append to state before appending the pdu, so we don't have a moment in
// time with the pdu without it's state. This is okay because append_pdu can't
// fail.