Compare commits

..

10 commits

Author SHA1 Message Date
nexy7574
5454c22b5b
style(policy-server): Run clippy
Some checks failed
Checks / Prefligit / prefligit (push) Failing after 3s
Release Docker Image / define-variables (push) Failing after 5s
Release Docker Image / build-image (linux/amd64, release, linux-amd64, base) (push) Has been skipped
Release Docker Image / build-image (linux/arm64, release, linux-arm64, base) (push) Has been skipped
Release Docker Image / merge (push) Has been skipped
Checks / Rust / Format (push) Failing after 11s
Checks / Rust / Clippy (push) Failing after 16s
Checks / Rust / Cargo Test (push) Failing after 13s
2025-07-19 23:54:07 +01:00
nexy7574
977fddf4c5
feat(policy-server): Optimise policy server lookups 2025-07-19 23:51:54 +01:00
nexy7574
fe1610ab1c
feat(policy-server): Limit policy server request timeout to 10 seconds 2025-07-19 23:51:54 +01:00
nexy7574
efce67264e
feat(policy-server): Prevent local events that fail the policy check 2025-07-19 23:51:53 +01:00
nexy7574
40d789dd72
feat(policy-server): Soft-fail redactions for failed events 2025-07-19 23:51:53 +01:00
nexy7574
964b23a428
style(policy-server): Restructure logging 2025-07-19 23:51:53 +01:00
nexy7574
be61ff1465
fix(policy-server): Avoid unnecessary database lookup 2025-07-19 23:51:53 +01:00
nexy7574
1dc9abc00e
chore: Update ruwuma & fix lints 2025-07-19 23:51:53 +01:00
nexy7574
b9ce99d036
feat(policy-server): Policy server following 2025-07-19 23:51:51 +01:00
Jade Ellis
f513cb7598
chore: Remove false positives in typo checks
Some checks failed
Documentation / Build and Deploy Documentation (push) Has been skipped
Checks / Prefligit / prefligit (push) Failing after 4s
Release Docker Image / define-variables (push) Failing after 2s
Checks / Rust / Format (push) Failing after 1s
Release Docker Image / build-image (linux/amd64, release, linux-amd64, base) (push) Has been skipped
Release Docker Image / build-image (linux/arm64, release, linux-arm64, base) (push) Has been skipped
Release Docker Image / merge (push) Has been skipped
Checks / Rust / Clippy (push) Failing after 28s
Checks / Rust / Cargo Test (push) Failing after 28s
2025-07-19 20:31:54 +01:00
4 changed files with 30 additions and 2 deletions

View file

@ -1,5 +1,19 @@
[files]
extend-exclude = ["*.csr"]
extend-exclude = ["*.csr", "*.lock", "pnpm-lock.yaml"]
[default]
extend-ignore-re = [
"(?Rm)^.*(#|//|<!--)\\s*spellchecker:disable-line(\\s*-->)$", # Ignore a line by making it trail with a `spellchecker:disable-line` comment
"^[0-9a-f]{7,}$", # Commit hashes
# some heuristics for base64 strings
"[A-Za-z0-9+=]{72,}",
"([A-Za-z0-9+=]|\\\\\\s\\*){72,}",
"[0-9+][A-Za-z0-9+]{30,}[a-z0-9+]",
"\\$[A-Z0-9+][A-Za-z0-9+]{6,}[a-z0-9+]",
"\\b[a-z0-9+/=][A-Za-z0-9+/=]{7,}[a-z0-9+/=][A-Z]\\b",
]
[default.extend-words]
"allocatedp" = "allocatedp"

View file

@ -11,6 +11,10 @@ use ruma::{
#[implement(super::Service)]
#[tracing::instrument(skip_all, level = "debug")]
pub async fn policyserv_check(&self, pdu: &PduEvent, room_id: &RoomId) -> Result {
if *pdu.event_type() == StateEventType::RoomPolicy.into() {
debug!("Skipping spam check for policy server meta-event in room {room_id}");
return Ok(());
}
let Ok(policyserver) = self
.services
.state_accessor
@ -28,6 +32,14 @@ pub async fn policyserv_check(&self, pdu: &PduEvent, room_id: &RoomId) -> Result
return Ok(());
},
};
if via.is_empty() {
debug!("Policy server is empty for room {room_id}, skipping spam check");
return Ok(());
}
if !self.services.state_cache.server_in_room(via, room_id).await {
debug!("Policy server {via} is not in the room {room_id}, skipping spam check");
return Ok(());
}
let outgoing = self
.services
.sending

View file

@ -43,6 +43,7 @@ struct Services {
server_keys: Dep<server_keys::Service>,
short: Dep<rooms::short::Service>,
state: Dep<rooms::state::Service>,
state_cache: Dep<rooms::state_cache::Service>,
state_accessor: Dep<rooms::state_accessor::Service>,
state_compressor: Dep<rooms::state_compressor::Service>,
timeline: Dep<rooms::timeline::Service>,
@ -68,6 +69,7 @@ impl crate::Service for Service {
pdu_metadata: args.depend::<rooms::pdu_metadata::Service>("rooms::pdu_metadata"),
short: args.depend::<rooms::short::Service>("rooms::short"),
state: args.depend::<rooms::state::Service>("rooms::state"),
state_cache: args.depend::<rooms::state_cache::Service>("rooms::state_cache"),
state_accessor: args
.depend::<rooms::state_accessor::Service>("rooms::state_accessor"),
state_compressor: args

View file

@ -55,7 +55,7 @@ where
// backwards extremities doing all the checks in this list starting at 1.
// These are not timeline events.
debug!("Resolving state at event");
debug!("Resolving state at event {}", incoming_pdu.event_id);
let mut state_at_incoming_event = if incoming_pdu.prev_events().count() == 1 {
self.state_at_incoming_degree_one(&incoming_pdu).await?
} else {