Commit Graph

220 Commits

Author SHA1 Message Date
gnuxie 27142cf722 Create top level stores in integration test fixtures. 2025-03-22 11:38:21 +00:00
gnuxie 6168669fff Update Draupnir for reworked hash reversal.
We introduced a new PolicyRuleChangeType enum with a variant for
revealed literals.  And we changed our mind about where reversal will
happen, it'll happen in the room state manager factory.
2025-03-22 11:35:57 +00:00
gnuxie 15c1bf23a9 Rework hash store to support storing details about all entities. 2025-03-21 16:19:09 +00:00
gnuxie 1d0feb724a Update Draupnir for new PolicyListRevision API.
We should probably have just accepted multiple recommendations in all
these methods.
2025-03-21 16:19:09 +00:00
gnuxie eaa21680cf Missing stores initialization code in test fixtures. 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 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 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 b50033ba4a Fix manual launch script for changed room backing store interface. 2025-03-21 16:19:08 +00:00
gnuxie 4e9d2a010a We have got issues with utils.ts... 2025-03-14 17:29:17 +00:00
gnuxie 9a9547feb5 Add configuration for synapse-http-antispam. 2025-03-14 17:29: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
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 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 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 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
nexy7574 2300b1eef3 Add --invite to unban command (#666)
This PR closes #622 by adding a `--invite` flag to the `unban` command.

* Add --invite to `unban` command (untested)

* Use RoomInviter to invite users in unban command.

* Condense unban(+invite) log message

---------

Signed-off-by: nexy7574 <git@nexy7574.co.uk>
Co-authored-by: gnuxie <Gnuxie@protonmail.com>
2025-01-19 16:05:23 +00:00
Gnuxie 8a17cfed5d Update for MPS 2.5.2 (#683)
* Test UnbanCommand and UnbanPrompt have unbanned as a side effect.

You'd think it would be obvious, but clearly it hasn't been.  Part of
the reason for it is just how un-ergonomic it used to be to verify
room state.  Fortunately it's quite straight forward to do since MPS
has picked up. So now we can do it easily.

* Update for MPS 2.5.2.

- Fix SchemedMatrixData putting the wrong version number into data.
  Sadly a complication of
  https://github.com/the-draupnir-project/Draupnir/issues/560.

- Fix an issue where the implementation of the RoomUnbanner capability
  was actually calling `/ban`.
2025-01-18 00:54:25 +00:00
Gnuxie fa5ce9ad9c Fix report poller (#662)
Fixes https://github.com/the-draupnir-project/Draupnir/issues/258
Fixes https://github.com/the-draupnir-project/Draupnir/issues/408
Fixes https://github.com/the-draupnir-project/Draupnir/issues/409

* Create a way to only forward reports in WebAPIs.

Honestly, I'm going to revert this because I think I have found a
better way of testing the report poller.

* Begin improving and fixing the report poller.

We need to change the ReportManager so that we can interface it out
for testing. The reason being that the report poller is inactive
in the harness and so we can't use that with a protection handle
to test. Instead I want to instantiate a report poller with
a mocked report manager.

* Update integration test nginx to mirror reports to synapse.

We need this so that we can test the report poller without needing to
do gymnastics to selectively forward reports.

* Interface out ReportManager.

Needed so we can test the report poller without doing gymnastics with
setting up fake protections.

* Fix report poller from paginating over the same reports.

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

* Revert "Create a way to only forward reports in WebAPIs."

This reverts commit 59b335f658.
We don't need this anymore.

* Update for MPS v2.4.0

Gives us the synapse admin client, updates schema, and gives us the fix for https://github.com/the-draupnir-project/Draupnir/issues/560
2025-01-10 17:06:54 +00:00
Gnuxie 3225d5d1d3 Update for MembershipPolicyRevision in MPS 2.2.0 (#650)
* Update for MembershipPolicyMatches in MPS 2.2.0.

* Update MPS to 2.2.0.

https://github.com/Gnuxie/matrix-protection-suite/releases/tag/v2.2.0
Fixes: https://github.com/the-draupnir-project/Draupnir/issues/498
Likely also fixes: https://github.com/the-draupnir-project/Draupnir/issues/451 (discovered and fixed bug in MPS)
2025-01-06 16:19:42 +00:00
Gnuxie 613792769f Fix protections config set/add/remove commands. (#638)
* Stop using `setSerializedValue` on protection settings.

We don't need it now that we've updated the command reader.

* Update interface-manager and MPS.

* Enable standard presentation type translators.

This will fix issues with the ban command reason.
2024-12-09 16:56:29 +00:00
Gnuxie 402c39c708 Readable message for watch command when list is already watched. (#631)
https://github.com/the-draupnir-project/Draupnir/issues/630
2024-11-29 17:56:20 +00:00
gnuxie 29e610cbee Update protections for ConfigSchema protection settings. 2024-11-27 19:34:12 +00:00
gnuxie 164434d528 Prompt for confirmation of the recover command.
Update interface-manager for `--no-confirm` handling.
Update tests for recovery confirmation.
2024-10-11 11:23:48 +01:00
Gnuxie 039f1a8ef0 Improve the information we have about the management room. (#610)
We introduce a new interface `ManagementRoomDetail`, and our implementation of this has immediate access to the room members and room state. 

Immediately, this allows us to warn when the management room is public.

In the future, it gives us a nice place to decide things like decide whether membership of the management room is enough to be considered a moderator, introduce more redundancy in access control, and give capabilities a way to determine who is a moderator (and avoid enacting consequences against them).  

* Move management room to its own folder so we can start introspecting on it.

* Add ManagementRoomDetail.ts

This is just used to track who is a moderator and whether the
management room is public.

* Update ManagementRoomOutput to depend on ManagementRoomDetail.

This should allow us to implement the feature that warns when
the management room is public.

* Send a warning if the management room is public.

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

* Update to MPS 1.7.0 so we can get the join rule event.
2024-10-10 13:37:42 +01:00
Gnuxie 4015543f66 Filesystem config improvements (#604)
* Rename read to configRead as it should have always been.

* Got a way to extract non-default values.

Now let's try unknown configuration values.

* Show unknown property paths with a warning.

Now we just need to make this scrap available in commands.

* Remove the old Mjolnir horrible RUNTIME client.

* Make the path that is used to load the config available.

* Warn when `--draupnir-config` isn't used.

* Introduce configMeta so that we can log meta on process.exit later.

* Only show non-default config values when draupnir is exiting.

to reduce noise.

* Get consistent with logging.

So it turns out that mps4bot-sdk is using a different instance
of the bot-sdk module than Draupnir, i think.

Since we used to tell MPS's logger to use the bot-sdk's `LogService`,
but the `setLogger` that was used was obviously inconsistent with
Draupnir's.

Obviously the bot-sdk should be a peer dependency in the bot-sdk
to prevent this happening in future.
2024-10-09 11:38:24 +01:00
Catalan Lover 9cc64074e1 Rename to Draupnir in Appropriate Places (#591)
* Rename to Draupnir in Appropriate Places

* Integrate Code review feedback on CHANGELOG.md
2024-10-04 20:32:10 +02:00
Gnuxie 56627a417e Make sure config recovery handles vaild but unjoinable rooms. (#590)
* Make sure config recovery handles valid but unjoinable rooms.

Pretty sure that we missed this.

* Update to MPS 1.5.2 for more recovery options.
2024-10-02 19:12:26 +01:00
gnuxie bd6c3c4455 WebAPIs.stop/start method was accidentally and implicitly async, fixed.
This was leading to integration test failures on CI, when the webserver
hadn't been stopped before it was started again in tests.
2024-10-02 11:32:04 +01:00
gnuxie 05f662214c Add WatchedLists and EnabledProtections to config recovery test. 2024-10-01 13:12:37 +01:00
gnuxie 72020e8ad6 Integration tests for recoring from protected rooms failure. 2024-09-30 12:14:00 +01:00
gnuxie fbdd146106 Harden MentionLimitProtection after Mjolnir's introduction of the protection.
From https://github.com/matrix-org/mjolnir/pull/524.

Co-authored-by: Half-Shot <will@half-shot.uk>
2024-09-20 16:09:31 +01:00
gnuxie 8f95c987ad Create a test for turning provisioned Draupnir to safe mode and back
Currently failing because the appservice draupnir manager is broken.
2024-09-19 17:52:53 +01:00
gnuxie f1f1440316 Add ProvisionTestHelper for testing appservice draupnir commands. 2024-09-19 15:26:35 +01:00
gnuxie 0895c58882 Allow manual launch script to use safe mode. 2024-09-18 18:47:13 +01:00
gnuxie 35ccf94794 Make integration test harness use the BotModeToggle. 2024-09-18 18:29:49 +01:00
gnuxie 4db7ce3872 Find a way to print draupnir status on startup from the toggle.
without disrupting e2ee.
2024-09-18 16:04:49 +01:00
gnuxie bd209848a3 Fix integration test fixtures now safe mode toggle controls draupnir. 2024-09-18 15:37:45 +01:00
gnuxie de6e4d7416 Add restart command to safe mode.
Currently integration tests will be broken because we took control
over "who starts Draupnir?" away and gave it to the `SafeModeToggle`.

So we need to fix that.
2024-09-18 15:28:05 +01:00
gnuxie c9a0d60eaf Migrate bot mode to use the safe mode toggle, but only for draupnir. 2024-09-17 17:27:08 +01:00
gnuxie 6c23c747de ThrottlingQueue was supressing errors in unit tests. 2024-09-11 17:08:00 +01:00
Gnuxie a5afdbe9ad Unit tests for the ban and unban commands. (#542)
* Unit test Ban and UnbanCommands.

Fixes https://github.com/the-draupnir-project/Draupnir/issues/441
will follow up with https://github.com/the-draupnir-project/interface-manager/issues/7.

Part of https://github.com/the-draupnir-project/planning/issues/22.

* Update to @the-draupnir-project/interface-manager@2.1.0.

* Rest parameters can only give one argument from prompts.

* Update to @the-draupnir-project/interface-manager@2.2.0.
2024-09-11 10:24:01 +01:00
Gnuxie 8d1af843d3 Unit test the DraupnirKickCommand. (#539)
* Update to MPS v1.2.1.

This will allow us to use `describeProtectedRoomsSet` in unit tests.

* Update to @the-draupnir-project/interface-manager@1.1.1.

This allows for better type inference from the command and also for
partial keywords to be provided to commands as arguments.

* Unit test the DraupnirKickCommand.
2024-09-09 17:20:09 +01:00