summary refs log tree commit diff
path: root/synapse/events/spamcheck.py (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Move Spam Checker callbacks to a dedicated file (#15453)Andrew Morgan2023-04-181-822/+0
|
* Refactor media modules. (#15146)Patrick Cloke2023-02-271-2/+2
| | | | | | | * Removes the `v1` directory from `test.rest.media.v1`. * Moves the non-REST code from `synapse.rest.media.v1` to `synapse.media`. * Flatten the `v1` directory from `synapse.rest.media`, but leave compatiblity with 3rd party media repositories and spam checkers.
* Instrument `_check_sigs_and_hash_and_fetch` to trace time spent in child ↵Eric Eastwood2022-08-231-0/+2
| | | | | | | | | concurrent calls (#13588) Instrument `_check_sigs_and_hash_and_fetch` to trace time spent in child concurrent calls because I've see `_check_sigs_and_hash_and_fetch` take [10.41s to process 100 events](https://github.com/matrix-org/synapse/issues/13587) Fix https://github.com/matrix-org/synapse/issues/13587 Part of https://github.com/matrix-org/synapse/issues/13356
* Uniformize spam-checker API, part 5: expand other spam-checker callbacks to ↵David Teller2022-07-111-35/+128
| | | | | | return `Tuple[Codes, dict]` (#13044) Signed-off-by: David Teller <davidt@element.io> Co-authored-by: Brendan Abolivier <babolivier@matrix.org>
* Uniformize spam-checker API, part 4: port other spam-checker callbacks to ↵David Teller2022-06-131-80/+197
| | | | | return `Union[Allow, Codes]`. (#12857) Co-authored-by: Brendan Abolivier <babolivier@matrix.org>
* Merge branch 'master' into developErik Johnston2022-05-311-20/+27
|\
| * Fix import in module_api module and docs on the new check_event_for_spam ↵Brendan Abolivier2022-05-311-22/+27
| | | | | | | | | | signature (#12918) Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* | Uniformize spam-checker API, part 3: Expand check_event_for_spam with the ↵David Teller2022-05-301-7/+13
|/ | | | | ability to return additional fields (#12846) Signed-off-by: David Teller <davidt@element.io>
* Uniformize spam-checker API, part 2: check_event_for_spam (#12808)David Teller2022-05-231-10/+39
| | | Signed-off-by: David Teller <davidt@element.io>
* add SpamChecker callback for silently dropping inbound federated events (#12744)Jess Porter2022-05-231-0/+40
| | | Signed-off-by: jesopo <github@lolnerd.net>
* SpamChecker metrics (#12513)Jess Porter2022-05-131-23/+58
| | | | | | | | | * add Measure blocks all over SpamChecker Signed-off-by: jesopo <github@lolnerd.net> * fix test_spam_checker_may_join_room and test_threepid_invite_spamcheck * better changelog entry
* Implement cancellation support/protection for module callbacks (#12568)Sean Quah2022-05-091-11/+25
| | | | | | | | | | | | There's no guarantee that module callbacks will handle cancellation appropriately. Protect module callbacks with read semantics from cancellation and avoid swallowing `CancelledError`s that arise. Other module callbacks, such as the `on_*` callbacks, are presumed to live on code paths that involve writes and aren't cancellation-friendly. These module callbacks have been left alone. Signed-off-by: Sean Quah <seanq@element.io>
* Correct `check_username_for_spam` annotations and docs (#12246)David Robertson2022-03-181-4/+3
| | | | | | | * Formally type the UserProfile in user searches * export UserProfile in synapse.module_api * Update docs Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
* fix misleading comment in `check_events_for_spam` (#12203)Shay2022-03-101-2/+2
|
* Remove deprecated user_may_create_room_with_invites callback (#11950)Brendan Abolivier2022-02-111-42/+0
| | | Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* Add type hints to synapse.events.*. (#11066)Patrick Cloke2021-10-131-11/+14
| | | Except `synapse/events/__init__.py`, which will be done in a follow-up.
* Add a spamchecker method to allow or deny 3pid invites (#10894)Brendan Abolivier2021-10-061-0/+35
| | | | | This is in the context of creating new module callbacks that modules in https://github.com/matrix-org/synapse-dinsic can use, in an effort to reconcile the spam checker API in synapse-dinsic with the one in mainline. Note that a module callback already exists for 3pid invites (https://matrix-org.github.io/synapse/develop/modules/third_party_rules_callbacks.html#check_threepid_can_be_invited) but it doesn't check whether the sender of the invite is allowed to send it.
* Add a spamchecker callback to allow or deny room joins (#10910)Brendan Abolivier2021-10-061-0/+24
| | | Co-authored-by: Erik Johnston <erik@matrix.org>
* Add a spamchecker callback to allow or deny room creation based on invites ↵Brendan Abolivier2021-09-241-0/+42
| | | | | | | (#10898) This is in the context of creating new module callbacks that modules in https://github.com/matrix-org/synapse-dinsic can use, in an effort to reconcile the spam checker API in synapse-dinsic with the one in mainline. This adds a callback that's fairly similar to user_may_create_room except it also allows processing based on the invites sent at room creation.
* Use direct references for configuration variables (part 5). (#10897)Patrick Cloke2021-09-241-1/+1
|
* Use inline type hints in various other places (in `synapse/`) (#10380)Jonathan de Jong2021-07-151-2/+2
|
* Fix wrapping of legacy check_registration_for_spam (#10238)Brendan Abolivier2021-06-231-6/+7
| | | Fixes #10234
* Standardise the module interface (#10062)Brendan Abolivier2021-06-181-88/+218
| | | This PR adds a common configuration section for all modules (see docs). These modules are then loaded at startup by the homeserver. Modules register their hooks and web resources using the new `register_[...]_callbacks` and `register_web_resource` methods of the module API.
* Add missing type hints to handlers and fix a Spam Checker type hint. (#9896)Patrick Cloke2021-04-291-1/+4
| | | | | The user_may_create_room_alias method on spam checkers declared the room_alias parameter as a str when in reality it is passed a RoomAlias object.
* Remove `synapse.types.Collection` (#9856)Richard van der Hoff2021-04-221-2/+1
| | | This is no longer required, since we have dropped support for Python 3.5.
* Remove redundant "coding: utf-8" lines (#9786)Jonathan de Jong2021-04-141-1/+0
| | | | | | | Part of #9744 Removes all redundant `# -*- coding: utf-8 -*-` lines from files, as python 3 automatically reads source code as utf-8 now. `Signed-off-by: Jonathan de Jong <jonathan@automatia.nl>`
* Pass SSO IdP information to spam checker's registration function (#9626)Andrew Morgan2021-03-161-3/+26
| | | | | | | Fixes https://github.com/matrix-org/synapse/issues/9572 When a SSO user logs in for the first time, we create a local Matrix user for them. This goes through the register_user flow, which ends up triggering the spam checker. Spam checker modules don't currently have any way to differentiate between a user trying to sign up initially, versus an SSO user (whom has presumably already been approved elsewhere) trying to log in for the first time. This PR passes `auth_provider_id` as an argument to the `check_registration_for_spam` function. This argument will contain an ID of an SSO provider (`"saml"`, `"cas"`, etc.) if one was used, else `None`.
* Add check_media_file_for_spam spam checker hookErik Johnston2021-02-041-0/+47
|
* Allow spam-checker modules to be provide async methods. (#8890)David Teller2020-12-111-16/+39
| | | | Spam checker modules can now provide async methods. This is implemented in a backwards-compatible manner.
* Use TYPE_CHECKING instead of magic MYPY variable. (#8770)Patrick Cloke2020-11-171-3/+2
|
* Combine `SpamCheckerApi` with the more generic `ModuleApi`. (#8464)Richard van der Hoff2020-10-071-2/+3
| | | | | Lots of different module apis is not easy to maintain. Rather than adding yet another ModuleApi(hs, hs.get_auth_handler()) incantation, first add an hs.get_module_api() method and use it where possible.
* Stop sub-classing object (#8249)Patrick Cloke2020-09-041-1/+1
|
* Allow denying or shadow banning registrations via the spam checker (#8034)Patrick Cloke2020-08-201-2/+33
|
* Extend spam checker to allow for multiple modules (#7435)Andrew Morgan2020-05-081-39/+39
|
* Add type hints to the spam check module (#6915)Patrick Cloke2020-02-141-18/+26
| | | | Add typing information to the spam checker modules.
* Filter the results of user directory searching via the spam checker (#6888)Patrick Cloke2020-02-141-0/+27
| | | Add a method to the spam checker to filter the user directory results.
* Expose some homeserver functionality to spam checkers (#6259)Travis Ralston2019-10-311-1/+13
| | | | | | | | | | | | | | * Offer the homeserver instance to the spam checker * Newsfile * Linting * Expose a Spam Checker API instead of passing the homeserver object * Alter changelog * s/hs/api
* Run Black. (#5482)Amber Brown2019-06-201-1/+3
|
* Remove periods from copyright headers (#5046)Andrew Morgan2019-04-111-1/+1
|
* replace 'except:' with 'except Exception:'Richard van der Hoff2017-10-231-1/+1
| | | | what could possibly go wrong
* Spam checking: add the invitee to user_may_inviteDavid Baker2017-10-051-2/+2
|
* spam check room publishingDavid Baker2017-10-041-0/+18
|
* Add room creation checks to spam checkerDavid Baker2017-10-041-0/+32
| | | | | Lets the spam checker deny attempts to create rooms and add aliases to them.
* s/roomid/room_id/David Baker2017-10-031-2/+2
|
* pass room id tooDavid Baker2017-10-031-2/+2
|
* Actually write warpper functionDavid Baker2017-10-031-0/+16
|
* Don't test is spam_checker not NoneDavid Baker2017-09-271-1/+7
| | | | | Sometimes it's a Mock object which is not none but is still not what we're after
* Remove unintentional debuggingDavid Baker2017-09-271-1/+0
|
* pep8David Baker2017-09-271-0/+1
|
* Make the spam checker a moduleDavid Baker2017-09-261-17/+20
|
* fix thinko'd docstringMatthew Hodgson2017-09-221-1/+1
|
* PoC for filtering spammy events (#2456)Richard van der Hoff2017-09-191-0/+38
Demonstration of how you might add some hooks to filter out spammy events.