Commit Graph

400 Commits

Author SHA1 Message Date
jesopo
0110a03b7a first draft of reportPollingTest 2022-06-27 13:59:19 +00:00
jesopo
23c3f55ceb document 'pollReports' in config 2022-06-27 13:59:19 +00:00
jesopo
5ad671ac70 else linting 2022-06-27 13:59:19 +00:00
jesopo
01e80b1dba missing } 2022-06-27 13:59:19 +00:00
jesopo
38189d3bf4 document next_token 2022-06-27 13:59:19 +00:00
jesopo
af25f831e7 don't allow schedulePoll to be called twice 2022-06-27 13:59:19 +00:00
jesopo
722c9c3774 miss return, remove promise 2022-06-27 13:59:19 +00:00
jesopo
443b59c0a3 document ReportPoll.from 2022-06-27 13:59:19 +00:00
jesopo
126791908d add (default false) option to enable report polling 2022-06-27 13:59:18 +00:00
jesopo
e518541fd0 gracefully handle setAccountData failure 2022-06-27 13:58:39 +00:00
jesopo
7dd98c0b98 switch to using event context api 2022-06-27 13:58:39 +00:00
jesopo
3c128bfeaf stop() ReportPoll in Mjolnir.stop() 2022-06-27 13:58:39 +00:00
jesopo
f3ad0e5db4 handle report poll from setting not existing 2022-06-27 13:58:39 +00:00
jesopo
f218a66c2d use .bind instead of self=this 2022-06-27 13:58:13 +00:00
jesopo
3320fee9a0 switch to setTimeout, handle exceptions 2022-06-27 13:57:45 +00:00
jesopo
3994999306 specific invalid state reasons 2022-06-27 13:57:18 +00:00
jesopo
f49f5ffbaf comments 2022-06-27 13:57:18 +00:00
jesopo
e34d542cb2 underscores for private vars are not proper 2022-06-27 13:57:18 +00:00
jesopo
fbe90ff835 copyright header 2022-06-27 13:57:18 +00:00
jesopo
682a7ec019 typo, this should have been next_token 2022-06-27 13:57:18 +00:00
jesopo
da2b5e35d5 implement polling reports in synapse 2022-06-27 13:57:17 +00:00
gnuxie
d7b846cdb3 Remove duplicated kick from kick command (merging cleanup)
Accidentally introduced while merging https://github.com/matrix-org/mjolnir/pull/291.
2022-06-15 12:34:59 +01:00
Jae Lo Presti
a876a05520
Glob kick command (#291)
This pull requests adds for glob support in the `!mjolnir kick` command.

## Example
```
!mjolnir kick @*:domain.tld <reason> --force
```
This command will kick every user having a mxid matching `domain.tld`.  
You can also still kick a particular user:
```
!mjolnir kick @user:domain.tld <reason>
```

## Tests:
Tested on the Furry Tech room (`vRGLvqJYlFvzpThbxI:matrix.org`) after a spam wave.  
It kicked over 13k bots in a matter of hours without putting too much strain on the homeserver.  
For instance, this command was matching `@spam*`:
![image](https://user-images.githubusercontent.com/76598503/167320002-f0575f50-4b54-41d1-8220-f67d72ccaf16.png)

  
  
Signed-off-by: Jae Lo Presti <me@jae.fi>
2022-06-15 12:20:27 +01:00
David Teller
0eea04bd69
A background queue for kicking (#296)
A background queue for kicking
2022-06-08 11:49:43 +02:00
Gnuxie
558cbb3cae
Remove the need to call /initialSync in getMessagesByUserIn. (#297)
* Remove the need to call `/initialSync` in `getMessagesByUserIn`.

At the moment we call `/initialSync` to give a `from` token to `/messages`.
In this PR we instead do not provide a `from` token when calling `/messages`,
which has recently been permitted in the spec
Technically this is still unstable in the spec
https://spec.matrix.org/unstable/client-server-api/#get_matrixclientv3roomsroomidmessages
https://github.com/matrix-org/matrix-spec/pull/1002

Synapse has supported this for over 2 years and Element web depends on it for threads.
https://github.com/matrix-org/matrix-js-sdk/pull/2065

Given that redactions are super heavy in Mjolnir already and have been reported
as barely functional on matrix.org I believe we should also adopt this approach as
if for some reason the spec did change before the next release (1.3) (extremely unlikely) we can revert this commit.
2022-05-24 11:16:52 +01:00
Jonathan de Jong
bf7f1318af
Improve documentation (#277)
* improve documentation

* incorperate documentation of configuration into sample file
2022-05-20 12:19:26 +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
David Teller
74d8caa7e7
Since command: adding the ability to mute (#272) 2022-05-10 17:19:16 +02:00
gnuxie
a88fc64a07 v1.4.2 2022-05-06 11:25:49 +01: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
Gnuxie
c8caf744c5
Apply members and server bans to the most recently active rooms first. (#274)
* Apply members and server bans to the most recently active rooms first.

https://github.com/matrix-org/mjolnir/issues/273
2022-05-03 12:36:53 +01:00
Jonathan de Jong
cc9f393ed7
fix CI (#282)
ts-mocha has also been updated to make running locally possible (else it gives a confusing error that tsconfig.json is not "json" or the likes)
2022-05-03 11:20:40 +01:00
Gnuxie
3d10f998b7
Change antispam Python module verison with mjolnir version. (#264)
The reason we want this is so that people do not forget to change the version number in the synapse module.
The precedent is that the version number has been 0.1.0 since the begging until now.
While this solution does mean that there may be new version of the module where
nothing has actually changed, this is still better than not changing the version at all.
Another version scheme for the module would be inconsistent to
the git repository tags and that has the potential to cause much more confusion
than "blank" version bumps.
If this is a problem, then antispam must be extracted to another repository.

In order to test this, run `yarn version --patch` observe the changes with `git log` and `git diff HEAD~`,
then YOU MUST delete the tag with `git tag --delete vd.d.d` when you are finished.

* more robust
2022-04-12 16:36:35 +01:00
Gnuxie
b8ee2fddbf
Synapse requires registration to be explicit (#275) 2022-04-12 12:56:27 +01:00
Marco Cirillo
4f070244ce
Amend README.md for antispam config example. (#271) 2022-04-06 18:20:49 +02:00
Gnuxie
f63edbefa0
Make startup failures more controlled and understandable. (#270)
There is no reason to call process.exit() from `index.ts` or in `Mjolnir.start()` because

https://nodejs.org/api/process.html#warning-using-uncaughtexception-correctly

>The 'uncaughtException' event is emitted when an uncaught JavaScript exception bubbles all the way back to the event loop. By default, Node.js handles such exceptions by printing the stack trace to stderr and exiting with code 1, overriding any previously set process.exitCode. Adding a handler for the 'uncaughtException' event overrides this default behaviour.
2022-04-01 16:40:10 +01:00
Gnuxie
fb7167773b
Use github workflows to push dockerhub images+tags. (#265) 2022-03-28 15:25:31 +01:00
dependabot[bot]
31ef9065da
Bump minimist from 1.2.5 to 1.2.6 (#260)
Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6)

---
updated-dependencies:
- dependency-name: minimist
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-03-25 10:05:23 +00:00
gnuxie
4008e3f65d v1.4.1 2022-03-21 14:28:21 +00:00
jesopo
fccb4627ce show room ID in consequence log 2022-03-21 14:25:12 +00:00
jesopo
afd003b905 remove line leftover from debugging 2022-03-21 14:11:45 +00:00
gnuxie
fb027fe2af v1.4.0 2022-03-21 12:32:32 +00:00
David Robertson
95d394b964
Merge pull request #246 from matrix-org/dmr/fix-check-username-as-spam
Fix block_usernames config option
2022-03-21 11:54:12 +00:00
David Teller
e05616b327
New command !mjolnir since <date or duration> <kick | ban | show> <limit> [reason] [...rooms] (#238)
A new command `since` to affect all users who have joined a protected room since a given date.
2022-03-21 10:39:15 +01:00
Gnuxie
814e528eaf
Fix incorrect type deceleration in check_username_for_spam (#250)
Fixes https://github.com/matrix-org/mjolnir/issues/245
2022-03-18 17:20:53 +00:00
Gnuxie
48206a8524
Move message_limit into antispam. (#243)
* Move message_limit into antispam.

https://github.com/matrix-org/message_limit

Not ideal but we've had complaints about keeping them separate
and unfortunately the need for this module is not going to go away.
2022-03-18 11:07:21 +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 Robertson
2c9fc0ccdc
Fix block_usernames config option
Fixes #244.
2022-03-17 16:53:31 +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