Commit Graph

682 Commits

Author SHA1 Message Date
gnuxie ef592a95e4 Plumb takedown command into room discovery. 2025-03-21 16:19:09 +00:00
gnuxie 8cf7e4b638 Add initial draft of takedown command.
Now we need to hook in discovery when the command is run.
2025-03-21 16:19:09 +00:00
gnuxie 19a78d670c Some shite that didn't get comitted to do with messing up hash store. 2025-03-21 16:19:09 +00:00
gnuxie a6b6508af1 Update unban code for unmasked hashed entities.
We will need to work harder to remove masked hashed entities...
2025-03-21 16:19:09 +00:00
gnuxie 0de853b413 Update Draupnir policy handling code for hashed entities. 2025-03-21 16:19:09 +00:00
gnuxie 2909464d36 Store user and server in room hash store too. 2025-03-21 16:19:09 +00:00
gnuxie 9d5e19514a Store details about the room at takedown in the audit log.
We need to do this because they will be impossible to obtain once the
room has been blocked on the server.

We also need to make sure we now include the server the room was
created on, and the creator in the room hash store.
2025-03-21 16:19:09 +00:00
gnuxie 7f0a8da41f Flesh out RoomDiscovery some more.
I really need to move the room details to the audit log, it's there
so we can see what the rooms are that have been takendown.
2025-03-21 16:19:09 +00:00
gnuxie 4fdb142ac2 Only audit takedown when capabilities are not simulated. 2025-03-21 16:19:09 +00:00
gnuxie 003410d41a Change the order of checking the audit log. 2025-03-21 16:19:09 +00:00
gnuxie b80a503ea0 Improve hash store replace query a little.
I'm after realising this whole thing is a mess but there's no time to fix it.
2025-03-21 16:19:08 +00:00
gnuxie 1e581d7394 Test room takedown service and add thoughts to FIXME. 2025-03-21 16:19:08 +00:00
gnuxie d15322dff6 Test and fix the hash store. 2025-03-21 16:19:08 +00:00
gnuxie 442b930d89 Unit test and fix sqlite room audit log. 2025-03-21 16:19:08 +00:00
gnuxie 3f00346ae6 Plumb in SynapseHTTPAntispam to RoomTakedownProtection room discovery. 2025-03-21 16:19:08 +00:00
gnuxie 7b212d75aa Fix typo in SynapseHTTPAntispam UserMayJoinRoom handle. 2025-03-21 16:19:08 +00:00
gnuxie 15f94bc2b2 Export request body types from SynapseHTTPAntispam. 2025-03-21 16:19:08 +00:00
gnuxie 62079457e9 Move roomStateBackingStore into TopLevelStores abstraction. 2025-03-21 16:19:08 +00:00
gnuxie 4ae5e5f63a Begin process of creating top level stores.
We now need to move the roomStateBackingStore into this thingy.
2025-03-21 16:19:08 +00:00
gnuxie 25f39e20d0 Start plumbing up RoomTakedownProtection into Draupnir.
There are a couple of FIXME's to address. Such as plumbing
up the stores into draupnir and how to poll for new rooms.
2025-03-21 16:19:08 +00:00
gnuxie b8bf6c5692 Add RoomTakedownCapability and SynapseAdmin implementation. 2025-03-21 16:19:08 +00:00
gnuxie 7282374caf Clean up better-sqlite store so that we can test stores with in memeory dbs. 2025-03-21 16:19:08 +00:00
gnuxie b7b9cc78c9 Initial RoomTakedown "service".
I want to change the APIs a little bit so that we can get a takedown
reporter like the audit log but for message rendering and testing.

I also want to make the BetterSqliteStore concrete not depend
on where the database came from so that we can use in memory
databases for unit testing stores.

There are a couple other FIXME's littered around so be sure to check
those before merging.
2025-03-21 16:19:08 +00:00
gnuxie 9a9547feb5 Add configuration for synapse-http-antispam. 2025-03-14 17:29:17 +00:00
gnuxie 33e649c508 Add library code to support synapse-http-antispam.
We now need to add config, plumbing, and tests.
2025-03-14 17:29:17 +00:00
gnuxie 2e33e65892 Allow errors from appservice cli to propagate to the top level. 2025-03-12 10:21:17 +00:00
gnuxie 0ede5c8682 Add config schema to appservice config.
Make appservice datapath example consistent with docker image.

Make the appservice config schema check the admin room properly.

We now parse the room id/alias/or permalink.

Make sure to parse the config from cli.ts
2025-03-12 10:21:17 +00:00
Marcel a0f7ee5bb3 Set up state store if configured in d4all mode (#753)
* Set up state store if configured in d4all mode

Signed-off-by: MTRNord <mtrnord1@gmail.com>

* Ensure the dataPath is set in both the example and harness appservice config

Signed-off-by: MTRNord <mtrnord1@gmail.com>

* Move the SqliteRoomStateBackingStore creation to a static method instead

Signed-off-by: MTRNord <mtrnord1@gmail.com>

* Make the storage path canonicalization less confusing

---------

Signed-off-by: MTRNord <mtrnord1@gmail.com>
2025-03-11 20:45:09 +00:00
Bea 04d21a2942 Address #746 and a small SQLite optimization.
Explicitly set the `temp_store` pragma to `file` instead of `memory`
after deciding to place temporary files in `/data` to keep RAM usage
down while addressing #746.

Added a helper function to automatically "flatten" transactions
when you don't need SAVEPOINTs to avoid unnecessary temporary files.

Signed-off-by: Bea <20361868+enbea@users.noreply.github.com>
2025-03-09 17:29:27 +00:00
Gnuxie 0bc511a002 Add a protection to stop excess membership changes. (#748) 2025-03-07 18:02:07 +00:00
Gnuxie 57a169c6c0 Show help when there is an additional argument provided to a command. (#745)
Fixes https://github.com/the-draupnir-project/Draupnir/issues/744.

Shows the specific command help and the specific argument that is the problem.
2025-03-03 18:53:40 +00:00
Gnuxie 7b5ab65328 Test more edge cases in unban command (#743)
* Cover users that are banned indirectly by removed policies

https://github.com/the-draupnir-project/Draupnir/issues/740.

* Move findUnbanInformationForMember to UnbanUsers.tsx

* Remove rules on unban even if there are no matching members.

Fixes https://github.com/the-draupnir-project/Draupnir/issues/742.

* Add even more test cases to unban test.

Fixes #740 
Fixes #742
2025-03-03 18:18:29 +00:00
Gnuxie b5e3de5aa3 Make BanPropagationProtection's unban prompt use the unban command. (#737)
https://github.com/the-draupnir-project/Draupnir/issues/736.
2025-02-28 16:38:43 +00:00
gnuxie 1d413a1ab4 Include confirmation prompt listener into draupnir.
`--no-confirm` prompts will not work without this.
2025-02-28 12:19:59 +00:00
gnuxie a45d308597 Refactor and improve the unban command.
We no longer want to accept an argument for the list. We will just
find all appropriate policies and remove them, like we do with the
unban prompt (which we still might want to update to use the new
`--no-confirm` prompt later).

We fix the bugs where the unban command was inviting users regardless
of whether the `--invite` option was provided.

The unban command now uses a preview which shows all the policies that
will have to be removed to unban a user, all the rooms they will need
to be unbanned from, and any rooms that they will be invited to if the
`--invite` option is used.
2025-02-28 12:19:59 +00:00
Gnuxie 9587d6fcba Update for simulated capabilities from MPS v2.10.0 and add their renderers, commands. (#727)
* Set renderers and glue for new simulated capabilities.

https://github.com/the-draupnir-project/planning/issues/2.

* Distinguish simulated capability messages when rendering.

* Update for MPS 2.10.0

* Add `!protections capability reset <protection name>`  command.

This will allow you to use the default capabilities for a protection.

* Update CHANGELOG for simulated capabilities.
2025-02-12 12:51:44 +00:00
Gnuxie d3b55a879a Add !rules matching members command. (#726)
This shows all the rules that are matching members in the protected
rooms set, but probably cannot be actioned either due to permission
limitations or ACL leakage.
2025-02-11 11:13:24 +00:00
gnuxie 30ad9f098b Remove spurious error wrapping around status info. 2025-02-10 19:59:22 +00:00
gnuxie 2f7c598266 Use the new WatchedPolicyRooms MPS feature.
This simplifies anything to do with the way policy rooms are watched.
There was a lot of weird glue code around finding policy rooms and
revisions that has just been whipped out into the WatchedPolicyRooms
abstraction.
2025-02-10 16:39:03 +00:00
gnuxie 5d727d7114 Modify 'listInfo' from status command.
This function now distinguishes between lists we are watching, lists
that are protected, and lists that we have parted from.

I don't like it. This should exist on the `PolicyRoomsManager` and
this is a complete and total mess. I don't know if there is time to
fix it yet.
2025-02-10 10:07:51 +00:00
gnuxie e9e163e9f3 Show when rooms were last updated in the rooms list command.
https://github.com/the-draupnir-project/Draupnir/issues/718.
2025-02-09 12:39:44 +00:00
Gnuxie 711b9b7413 tidy config properties (#724)
* Remove `syncOnStartup` option since it no longer does anything.

We always 'sync' on startup, not that we have a concept of syncing
anymore. https://github.com/the-draupnir-project/Draupnir/issues/504.

* remove `verboseLogging`.

yeah, cya later pal. https://github.com/the-draupnir-project/Draupnir/issues/504.
2025-02-06 13:43:00 +00:00
Gnuxie 3ec98e7ad1 Show a protection's compatible capability providers in the capability set section of !draupnir protections show. (#723)
Currently looks like this, we just don't have alternative capabilities yet: 
![image](https://github.com/user-attachments/assets/24c1040c-54df-4895-b8b7-37d261254bf9)


* Include compatible capability providers in capability set.

* Update to MPS v2.8.0

This gives us the function to find compatible capability providers for
a capability interface.

* Improve description of capability providers some more.

* Iterate capability provider UX some more.
2025-02-03 16:32:39 +00:00
Gnuxie 24824027c4 Merge documentation and current value rendering into one componenet (#722)
* Condense config documentation and status to show in one block.

* Swap things around to make the current value prominent.

Before:

![image](https://github.com/user-attachments/assets/e554b0f7-408a-4ea6-9ffa-8df53119feac)


After:

![image](https://github.com/user-attachments/assets/26bcc16b-f85b-4639-9b8f-43f820158c7e)
2025-02-03 11:20:01 +00:00
gnuxie 69cf36b090 Fix typo in recover command. 2025-02-03 09:48:30 +00:00
gnuxie 4f5ec25f78 Consistent use of config.dataPath for backing store. 2025-02-03 09:37:35 +00:00
Gnuxie a497821ba9 Fix lack of error handling in parts of backing store. (#717)
Errors propagating here could cause the bot to have only partially
synced by propagating all the way up to the sync response handling in
the bot-sdk.

https://github.com/the-draupnir-project/Draupnir/issues/691.
2025-02-03 09:29:09 +00:00
Gnuxie 5d49bddd74 Be a little more accepting of servers choking on profile. (#714)
Fixes https://github.com/the-draupnir-project/Draupnir/issues/703.
2025-02-01 23:16:58 +00:00
gnuxie 02bcebd597 Make the rooms list command show unprotected and unjoined rooms. 2025-02-01 23:02:54 +00:00
Gnuxie acf0a406de Add functionality for config.protectAllJoinedRooms via a protection + adjacent changes. (#711)
* Initial ProtectAllJoinedRoomsProtection.

We need something like this to implement `config.protectAllJoinedRooms`,
we also need something to go alongside that removes rooms as they
are added or removed.

it will probably be a behaviour of the same protection that we will
split out.

* Move it cos i cba and we need to merge with a protection to unprotect

on leave and ban.

* IDK i keep getting distracted i need my notebook back aaaa.

* Create RoomsSetBehaviourProtection out of redundant protections.

* Add toggle for RoomsSetBehaviour.

* Enable the RoomsSetBehaviour protection by default.

* Add the behaviour protection to protections index.

* Whoopsie unprotected parted rooms should actually call itself.

* Fix bugs meow.

* handleExternalInvite -> handleExternalMembership

* Make sure leave events get propagated in bot mode.

* Add batcher to ProtectJoinedRooms component.

* Hook into handleExternalMembership for RoomsSetBehaviour.

* Remove crap from fixtures.ts

* leave all rooms when starting integration tests.

* Change how protections are informed of membership.

* Add test for Joinig and protecting rooms on invite.

* Tidy up UnprotectPartedRooms rendering.

* Update for MPS v2.7.0

Added

- Generic item batching is now available for protections to use by
  using the `StandardBatcher`.

Changed

- `Task` has been improved to be more liberal in the closures it
  accepts.  And `Task` now has more options for logging how tasks have
  failed.

- The `Protection` callback `handleExternalInvite` has been renamed to
  `handleExternalMembership`.

Fixed

- An issue where adding rooms to the protected rooms set more than
  once could sometimes cause duplicate events to be propagated.

* Fix typo mare.

* Stop protecting rooms automatically when config.protectAllJoinedRooms is false.

* Update CHANGELOG.md
2025-02-01 17:53:10 +00:00