Commit Graph

37 Commits

Author SHA1 Message Date
Rasmus Rendal
57af0563ba
Detect stickers as media 2023-05-11 14:45:15 +02:00
David Teller
5b509a226a Setting up Decentralized Abuse Reports automatically by default 2023-01-10 20:46:56 +01:00
Gnuxie
704bb660c2
Refactor how we listen for matrix events. (#446)
* Refactor Matrix event listener in Mjolnir and ManagedMjolnir.

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

Issue #411 says that we have to be careful about room.join,
but this was before we figured how to make matrix-appservice-bridge
echo events sent by its own intents.

* Remove MatrixClientListener since it isn't actually needed.

* Protect which config values can be used for ManagedMjolnirs.

* Introduce MatrixSendClient

so listeners aren't accidentally added to a MatrixClient instead
of MatrixEmitter.

* doc

* Move provisioned mjolnir config to src/config.

This just aids maintance so whenever someone goes to change the config
of the bot they will see this and update it.

* doc for matrix intent listener.
2022-12-06 17:17:40 +00:00
Gnuxie
aa50ab8e00
WordList was matching everything. (#427)
Made several improvements to catch edge cases.
2022-11-22 10:37:37 +00:00
Gnuxie
77ad40e27a
Refactor protected rooms. (#371)
* Attempt to factor out protected rooms from Mjolnir.

This is useful to the appservice because it means we don't
have to wrap a Mjolnir that is designed to sync.

It's also useful if we later on want to have specific
settings per space.

It's also just a nice seperation between Mjolnir's needs while
syncing via client-server and the behaviour of syncing policy rooms.

 ### Things that have changed

- `ErrorCache` no longer a static class (phew), gets used by `ProtectedRooms`.
- `ManagementRoomOutput` class gets created to handle logging back to the management room.
- Responsibilities for syncing member bans and server ACL are handled by `ProtectedRooms`.
- Responsibilities for watched lists should be moved to `ProtectedRooms` if they haven't been.
- `EventRedactionQueue` is moved to `ProtectedRooms` since this needs to happen after
  member bans.
- ApplyServerAcls moved to `ProtectedRooms`
- ApplyMemberBans move to `ProtectedRooms`
- `logMessage` and `replaceRoomIdsWithPills` moved to `ManagementRoomOutput`.
- `resyncJoinedRooms` has been made a little more clear, though I am concerned about how often it does run because it does seem expensive.


* ProtectedRooms is not supposed to track joined rooms.

The reason is because it is supposed to represent a specific
set of rooms to protect, not do horrible logic
for working out what rooms mjolnir is supposed to protect.
2022-09-29 14:49:09 +01:00
Jess Porter
f108935d07
support compound consequences, switch WordList to consequences (#351) 2022-09-26 16:57:21 +01:00
Gnuxie
21aabc879a
Stop the config being global (in almost all contexts). (#334)
* Stop the config being global (in almost all contexts).

* make sure unit test has a config

* Make failing word list more visible

* Only use Healthz from index.ts

Not really sure how useful it is anyways?
2022-08-09 11:29:27 +01:00
David Teller
bcc3405e51
Revert "Fix traceback on Abuse Report. (#230)" (#293)
This reverts commit 27ae3ec625.
2022-05-13 15:29:49 +02:00
Marco Cirillo
27ae3ec625
Fix traceback on Abuse Report. (#230)
* Have the callback work on the packed event Obj.

And also explicitly pack the Mjolnir object inside the event.

* Add VS ignores.

* Commit suggested review changes.

- Add bind to callback
- Add type cast for event packed object

* Fix missing parenthesis.

* Don't pass Mjolnir obj to handleReport().

Co-authored-by: David Teller <davidt@element.io>
2022-05-13 15:18:30 +02:00
Jonathan de Jong
9fce35c000
Add Join Wave Short-Circuit Protection (#280)
* Add Short Circuit Protection

* fix module name

* change to dynamic timescales

* address feedback
2022-05-06 09:24:34 +01:00
jesopo
afd003b905 remove line leftover from debugging 2022-03-21 14:11:45 +00:00
Jess Porter
1880287ac4
standard protection consequences (#232)
* standard protection consequences

* add integration test to make sure good users aren't banned

* the less far `event` propagates, the better

* better document consequence.ts

* improve innocent user integration test

* switch to room.event emit
2022-03-18 10:11:23 +00:00
David Teller
26ae55cd24
A command to show when users in a given room have joined (#225) 2022-03-07 11:34:25 +01:00
David Teller
82a2e63d23
A room Protection designed to measure lag in a room (#217) 2022-02-24 13:43:31 +01:00
Jess Porter
a58c7d3f1a
move LogProxy.logMessage to Mjolnir.logMessage (#194) 2022-02-15 15:44:41 +00:00
Jess Porter
f74cf8a6e5
trusted reporters (#183)
* Trusted Reporters protection

* redact/ban reasons

* some documentation
2022-02-08 13:07:42 +00:00
jesopo
813741c42c refactor (and simplify) how protections are stored in-memory 2022-02-07 13:48:32 +00:00
jesopo
8b23f93b71 splice returns removed items, not a new list with items removed 2022-02-07 13:33:44 +00:00
Jess Porter
f70d97e4d9
enable noImplicitAny (#209) 2022-02-02 12:43:05 +00:00
Jess Porter
423a34bebe
runtime persistent settings system (#158) 2022-01-25 14:47:50 +00:00
Chirayu Desai
69ace9cfa5 Add a new protection, MessageIsMedia
* Simply redacts any media sent to the room, by anyone
* Meant to serve as a temporary measure to prevent image spam,
  in conjunction with FirstMessageIsImage
2021-09-24 16:57:16 +05:30
gnuxie
2889599eb2 Rename AutomaticRedactionQueue to UnlistedUserRedactionQueue.
This seems to be a more descriptive name and it also doesn't clash
with the new redaction queue.
2021-09-14 14:45:07 +01:00
Travis Ralston
4c6511ba3d Definitely didn't copy/paste 2021-08-16 20:35:39 -06:00
Travis Ralston
453784d7ef Add a voice message protection to easily redact unwanted messages 2021-08-16 20:32:00 -06:00
Emi Tatsuo
50f2352001
Refactored to more verbose variable names; Updated copyright 2020-10-31 09:28:50 -04:00
Emi Tatsuo
6fa93e3bae
Corrected description of WordList to be time-independant 2020-06-21 16:26:51 -04:00
Emi Simpson
1e47be497b
Fix lint
Signed-off-by: Emi Simpson <emi@alchemi.dev>
2020-06-21 15:21:50 -04:00
Emi Simpson
c2fbf0934a
Added configuration for wordlist protection 2020-06-21 15:18:34 -04:00
Emi Simpson
bccb18225b
Added unconfigurable wordlist protection 2020-06-21 13:56:11 -04:00
Travis Ralston
635f9ba03f Prioritize bans over redactions, and queue redactions faster
This could do with some cleanup, particularly around the part where it uses a callback.
2020-06-12 08:15:48 -06:00
Travis Ralston
f6a856ed4a Resolve room aliases in messages
Fixes https://github.com/matrix-org/mjolnir/issues/47
2020-04-15 08:12:42 -06:00
Travis Ralston
6753e7f780 Allow the redact command to take globs 2019-12-09 19:43:41 -07:00
Travis Ralston
7de3744875 Respect no-op in more places 2019-12-09 19:20:47 -07:00
Travis Ralston
f9e3c33935 Don't spam protection warnings, and ensure the user is redacted
We now always prioritize redaction over ban to ensure that the user gets removed from our rooms. This also means that the second image posted by a spammer is redacted after join.

This commit also improves the messaging a bit.
2019-12-09 19:15:51 -07:00
Travis Ralston
245b81262e Fix linter 2019-12-04 19:28:49 -07:00
Travis Ralston
1b795c7b17 Add basic flooding protection too 2019-12-04 19:07:04 -07:00
Travis Ralston
d5f260b982 Add a protection system with a "first message is an image" demo 2019-12-04 18:51:03 -07:00