commit
3d0308ca2f
@ -13,7 +13,7 @@ assert_matches2 = "0.1.0"
|
||||
assign = "1.1.1"
|
||||
base64 = "0.21.0"
|
||||
criterion = "0.5.0"
|
||||
http = "0.2.8"
|
||||
http = "1.1.0"
|
||||
js_int = "0.2.2"
|
||||
maplit = "1.0.2"
|
||||
ruma-appservice-api = { version = "0.9.0", path = "crates/ruma-appservice-api" }
|
||||
|
@ -17,7 +17,7 @@ use serde::{
|
||||
Deserialize,
|
||||
};
|
||||
use serde_json::{from_str as from_json_str, value::RawValue as RawJsonValue};
|
||||
use tracing::{debug, error, info, warn};
|
||||
use tracing::{debug, error, warn};
|
||||
|
||||
use crate::{
|
||||
power_levels::{
|
||||
@ -127,7 +127,7 @@ pub fn auth_check<E: Event>(
|
||||
current_third_party_invite: Option<impl Event>,
|
||||
fetch_state: impl Fn(&StateEventType, &str) -> Option<E>,
|
||||
) -> Result<bool> {
|
||||
info!(
|
||||
debug!(
|
||||
"auth_check beginning for {} ({})",
|
||||
incoming_event.event_id(),
|
||||
incoming_event.event_type()
|
||||
@ -153,7 +153,7 @@ pub fn auth_check<E: Event>(
|
||||
creator: Option<Raw<IgnoredAny>>,
|
||||
}
|
||||
|
||||
info!("start m.room.create check");
|
||||
debug!("start m.room.create check");
|
||||
|
||||
// If it has any previous events, reject
|
||||
if incoming_event.prev_events().next().is_some() {
|
||||
@ -187,7 +187,7 @@ pub fn auth_check<E: Event>(
|
||||
}
|
||||
}
|
||||
|
||||
info!("m.room.create event was allowed");
|
||||
debug!("m.room.create event was allowed");
|
||||
return Ok(true);
|
||||
}
|
||||
|
||||
@ -251,7 +251,7 @@ pub fn auth_check<E: Event>(
|
||||
if room_version.special_case_aliases_auth {
|
||||
// 4. If type is m.room.aliases
|
||||
if *incoming_event.event_type() == TimelineEventType::RoomAliases {
|
||||
info!("starting m.room.aliases check");
|
||||
debug!("starting m.room.aliases check");
|
||||
|
||||
// If sender's domain doesn't matches state_key, reject
|
||||
if incoming_event.state_key() != Some(sender.server_name().as_str()) {
|
||||
@ -259,7 +259,7 @@ pub fn auth_check<E: Event>(
|
||||
return Ok(false);
|
||||
}
|
||||
|
||||
info!("m.room.aliases event was allowed");
|
||||
debug!("m.room.aliases event was allowed");
|
||||
return Ok(true);
|
||||
}
|
||||
}
|
||||
@ -269,7 +269,7 @@ pub fn auth_check<E: Event>(
|
||||
let sender_member_event = fetch_state(&StateEventType::RoomMember, sender.as_str());
|
||||
|
||||
if *incoming_event.event_type() == TimelineEventType::RoomMember {
|
||||
info!("starting m.room.member check");
|
||||
debug!("starting m.room.member check");
|
||||
let state_key = match incoming_event.state_key() {
|
||||
None => {
|
||||
warn!("no statekey in member event");
|
||||
@ -314,7 +314,7 @@ pub fn auth_check<E: Event>(
|
||||
return Ok(false);
|
||||
}
|
||||
|
||||
info!("m.room.member event was allowed");
|
||||
debug!("m.room.member event was allowed");
|
||||
return Ok(true);
|
||||
}
|
||||
|
||||
@ -380,7 +380,7 @@ pub fn auth_check<E: Event>(
|
||||
return Ok(false);
|
||||
}
|
||||
|
||||
info!("m.room.third_party_invite event was allowed");
|
||||
debug!("m.room.third_party_invite event was allowed");
|
||||
return Ok(true);
|
||||
}
|
||||
|
||||
@ -393,7 +393,7 @@ pub fn auth_check<E: Event>(
|
||||
|
||||
// If type is m.room.power_levels
|
||||
if *incoming_event.event_type() == TimelineEventType::RoomPowerLevels {
|
||||
info!("starting m.room.power_levels check");
|
||||
debug!("starting m.room.power_levels check");
|
||||
|
||||
if let Some(required_pwr_lvl) = check_power_levels(
|
||||
room_version,
|
||||
@ -409,7 +409,7 @@ pub fn auth_check<E: Event>(
|
||||
warn!("power level was not allowed");
|
||||
return Ok(false);
|
||||
}
|
||||
info!("power levels event allowed");
|
||||
debug!("power levels event allowed");
|
||||
}
|
||||
|
||||
// Room version 3: Redaction events are always accepted (provided the event is allowed by
|
||||
@ -434,7 +434,7 @@ pub fn auth_check<E: Event>(
|
||||
}
|
||||
}
|
||||
|
||||
info!("allowing event passed all checks");
|
||||
debug!("allowing event passed all checks");
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
@ -780,7 +780,7 @@ fn check_power_levels(
|
||||
deserialize_power_levels(power_event.content().get(), room_version)?;
|
||||
|
||||
// Validation of users is done in Ruma, synapse for loops validating user_ids and integers here
|
||||
info!("validation of power event finished");
|
||||
debug!("validation of power event finished");
|
||||
|
||||
let current_state = match previous_power_event {
|
||||
Some(current_state) => current_state,
|
||||
@ -912,7 +912,7 @@ fn check_redaction(
|
||||
redact_level: Int,
|
||||
) -> Result<bool> {
|
||||
if user_level >= redact_level {
|
||||
info!("redaction allowed via power levels");
|
||||
debug!("redaction allowed via power levels");
|
||||
return Ok(true);
|
||||
}
|
||||
|
||||
@ -921,7 +921,7 @@ fn check_redaction(
|
||||
if redaction_event.event_id().borrow().server_name()
|
||||
== redaction_event.redacts().as_ref().and_then(|&id| id.borrow().server_name())
|
||||
{
|
||||
info!("redaction event allowed via room version 1 rules");
|
||||
debug!("redaction event allowed via room version 1 rules");
|
||||
return Ok(true);
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ use ruma_events::{
|
||||
StateEventType, TimelineEventType,
|
||||
};
|
||||
use serde_json::from_str as from_json_str;
|
||||
use tracing::{debug, info, trace, warn};
|
||||
use tracing::{debug, trace, warn};
|
||||
|
||||
mod error;
|
||||
pub mod event_auth;
|
||||
@ -63,20 +63,20 @@ where
|
||||
E::Id: 'a,
|
||||
SetIter: Iterator<Item = &'a StateMap<E::Id>> + Clone,
|
||||
{
|
||||
info!("State resolution starting");
|
||||
debug!("State resolution starting");
|
||||
|
||||
// Split non-conflicting and conflicting state
|
||||
let (clean, conflicting) = separate(state_sets.into_iter());
|
||||
|
||||
info!("non conflicting events: {}", clean.len());
|
||||
debug!("non conflicting events: {}", clean.len());
|
||||
trace!("{clean:?}");
|
||||
|
||||
if conflicting.is_empty() {
|
||||
info!("no conflicting state found");
|
||||
debug!("no conflicting state found");
|
||||
return Ok(clean);
|
||||
}
|
||||
|
||||
info!("conflicting events: {}", conflicting.len());
|
||||
debug!("conflicting events: {}", conflicting.len());
|
||||
debug!("{conflicting:?}");
|
||||
|
||||
// `all_conflicted` contains unique items
|
||||
@ -87,7 +87,7 @@ where
|
||||
.filter(|id| fetch_event(id.borrow()).is_some())
|
||||
.collect();
|
||||
|
||||
info!("full conflicted set: {}", all_conflicted.len());
|
||||
debug!("full conflicted set: {}", all_conflicted.len());
|
||||
debug!("{all_conflicted:?}");
|
||||
|
||||
// We used to check that all events are events from the correct room
|
||||
@ -229,7 +229,7 @@ fn reverse_topological_power_sort<E: Event>(
|
||||
let mut event_to_pl = HashMap::new();
|
||||
for event_id in graph.keys() {
|
||||
let pl = get_power_level_for_sender(event_id.borrow(), &fetch_event)?;
|
||||
info!("{event_id} power level {pl}");
|
||||
debug!("{event_id} power level {pl}");
|
||||
|
||||
event_to_pl.insert(event_id.clone(), pl);
|
||||
|
||||
@ -264,7 +264,7 @@ where
|
||||
event_id: &'a Id,
|
||||
}
|
||||
|
||||
info!("starting lexicographical topological sort");
|
||||
debug!("starting lexicographical topological sort");
|
||||
// NOTE: an event that has no incoming edges happened most recently,
|
||||
// and an event that has no outgoing edges happened least recently.
|
||||
|
||||
@ -343,7 +343,7 @@ fn get_power_level_for_sender<E: Event>(
|
||||
event_id: &EventId,
|
||||
fetch_event: impl Fn(&EventId) -> Option<E>,
|
||||
) -> serde_json::Result<Int> {
|
||||
info!("fetch event ({event_id}) senders power level");
|
||||
debug!("fetch event ({event_id}) senders power level");
|
||||
|
||||
let event = fetch_event(event_id);
|
||||
let mut pl = None;
|
||||
@ -387,7 +387,7 @@ fn iterative_auth_check<E: Event + Clone>(
|
||||
unconflicted_state: StateMap<E::Id>,
|
||||
fetch_event: impl Fn(&EventId) -> Option<E>,
|
||||
) -> Result<StateMap<E::Id>> {
|
||||
info!("starting iterative auth check");
|
||||
debug!("starting iterative auth check");
|
||||
|
||||
debug!("performing auth checks on {events_to_check:?}");
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user