matrix-org / mjolnir

A moderation tool for Matrix
Apache License 2.0
330 stars 56 forks source link

Managed Mjolnirs are being informed of every event sent to the appservice #412

Open Gnuxie opened 2 years ago

Gnuxie commented 2 years ago

The mjolnirs will still compare the event against their joined/protected rooms deeper in the chain, so they won't act on any events in rooms they're not joined to or protecting, but this still is problematic and we should have defence in depth. https://github.com/matrix-org/mjolnir/blob/818e4cf3153015591b5175d584f542df10e7951b/src/Mjolnir.ts#L533-L558 https://github.com/matrix-org/mjolnir/blob/818e4cf3153015591b5175d584f542df10e7951b/src/ProtectedRoomsSet.ts#L176-L178

Inspiration should be taken from bridges on how they manage tracking of rooms. The thing is you shouldn't do this naively because it does duplicate effort. Mjolnir instance already track which rooms they are joined to and are protecting, we just don't have a way to map from a roomId to a set of Mjolnirs that are joined to that room.

https://github.com/matrix-org/mjolnir/blob/818e4cf3153015591b5175d584f542df10e7951b/src/appservice/MjolnirManager.ts#L99-L104

Gnuxie commented 2 years ago

Loosely related https://github.com/matrix-org/mjolnir/issues/411

Gnuxie commented 1 year ago

One way to do this is to:

Gnuxie commented 1 year ago

Technically is blocked on #415 but if you just use the data store interface you'll be able to get most of it done