Skip to content

Commit

Permalink
Merge pull request #221 from the-draupnir-project/gnuxie/matrix-prote…
Browse files Browse the repository at this point in the history
…ction-suite-raw

#### This is a rewrite of the core functionality of Draupnir

This has been done with a library called the [matrix-protection-suite](https://github.com/Gnuxie/matrix-protection-suite) that Draupnir now depends upon. The protection suite provides a plugin system that allows all of Draupnir's functionality to be implemented as protections, that can be disabled/enabled and configured individually as distinct modules. The protection suite also introduces capability interfaces and capability providers which allow the user to modify what each individual protection can do without needing to change modify the protection's code.

#221
  • Loading branch information
Gnuxie authored Apr 6, 2024
2 parents f5c2ba2 + 971b4ed commit 6949364
Show file tree
Hide file tree
Showing 153 changed files with 5,960 additions and 11,197 deletions.
6 changes: 4 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
module.exports = {
"extends": [ "plugin:editorconfig/all" ],
"env": {
"browser": false,
"es6": true,
"node": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.json",
"project": ["tsconfig.json", "test/tsconfig.json"],
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
"@typescript-eslint",
"editorconfig"
],
"root": true,
"rules": {
Expand Down
8 changes: 8 additions & 0 deletions config/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,14 @@ protections:
# (users will always be banned if they say a bad word)
minutesBeforeTrusting: 20

# The room state backing store writes a copy of the room state for all protected
# rooms to the data directory.
# It is recommended to enable this option unless you deploy Draupnir close to the
# homeserver and know that Draupnir is starting up quickly. If your homeserver can
# respond quickly to Draupnir's requests for `/state` then you might not need this option.
roomStateBackingStore:
enabled: false

# Options for advanced monitoring of the health of the bot.
health:
# healthz options. These options are best for use in container environments
Expand Down
7 changes: 1 addition & 6 deletions config/harness.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ autojoinOnlyIfManager: true

# If `autojoinOnlyIfManager` is false, only the members in this space can invite
# the bot to new rooms.
acceptInvitesFromSpace: '!example:example.org'
acceptInvitesFromSpace: "!example:example.org"

# If the bot is invited to a room and it won't accept the invite (due to the
# conditions above), report it to the management room. Defaults to disabled (no
Expand All @@ -53,7 +53,6 @@ managementRoom: "#moderators:localhost:9999"
# mainly involves "all-OK" messages, and debugging messages for when draupnir checks bans in a room.
verboseLogging: false


# The log level for the logs themselves. One of DEBUG, INFO, WARN, and ERROR.
# This should be at INFO or DEBUG in order to get support for Mjolnir problems.
logLevel: "DEBUG"
Expand Down Expand Up @@ -201,7 +200,3 @@ web:
abuseReporting:
# Whether to enable this feature.
enabled: true
# A web API for a description of all the combined rules from watched banlists.
# GET /api/1/ruleserver/updates
ruleServer:
enabled: false
16 changes: 13 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
"license": "AFL-3.0",
"private": true,
"scripts": {
"build": "tsc",
"postbuild": "yarn remove-tests-from-lib && yarn describe-version",
"build": "tsc --project test/tsconfig.json && tsc > /dev/null 2>&1",
"postbuild": "yarn describe-version",
"describe-version": "(git describe > version.txt.tmp && mv version.txt.tmp version.txt) || true && rm -f version.txt.tmp",
"remove-tests-from-lib": "rm -rf lib/test/ && cp -r lib/src/* lib/ && rm -rf lib/src/",
"lint": "eslint ./**/*.ts",
"lint": "eslint -c .eslintrc.js src/**/*.ts test/**/*.ts src/**/*.tsx",
"start:dev": "yarn build && node --async-stack-traces lib/index.js",
"test": "ts-mocha --project ./tsconfig.json test/commands/**/*.ts",
"test:integration": "NODE_ENV=harness ts-mocha --async-stack-traces --forbid-only --require test/integration/fixtures.ts --timeout 300000 --project ./tsconfig.json \"test/integration/**/*Test.ts\"",
Expand All @@ -23,6 +23,7 @@
"version": "sed -i '/# version automated/s/[0-9][0-9]*\\.[0-9][0-9]*\\.[0-9][^\"]*/'$npm_package_version'/' synapse_antispam/setup.py && git add synapse_antispam/setup.py && cat synapse_antispam/setup.py"
},
"devDependencies": {
"@types/better-sqlite3": "^7.6.9",
"@types/config": "^3.3.1",
"@types/crypto-js": "^4.2.2",
"@types/express": "^4.17.21",
Expand All @@ -40,6 +41,7 @@
"@typescript-eslint/parser": "^6.19.0",
"crypto-js": "^4.2.0",
"eslint": "^8.56",
"eslint-plugin-editorconfig": "^4.0.3",
"expect": "^29.7.0",
"mocha": "^10.2.0",
"ts-mocha": "^10.0.0",
Expand All @@ -49,7 +51,9 @@
"dependencies": {
"@sentry/node": "^7.17.2",
"@sentry/tracing": "^7.17.2",
"@sinclair/typebox": "~0.31.15",
"await-lock": "^2.2.2",
"better-sqlite3": "^9.4.3",
"body-parser": "^1.20.2",
"config": "^3.3.9",
"express": "^4.18",
Expand All @@ -59,12 +63,18 @@
"js-yaml": "^4.1.0",
"jsdom": "^24.0.0",
"matrix-appservice-bridge": "^9.0.1",
"matrix-protection-suite": "npm:@gnuxie/[email protected]",
"matrix-protection-suite-for-matrix-bot-sdk": "npm:@gnuxie/[email protected]",
"parse-duration": "^1.0.2",
"pg": "^8.8.0",
"shell-quote": "^1.7.3",
"ulidx": "^2.2.1",
"yaml": "^2.3.2"
},
"overrides": {
"matrix-bot-sdk": "$@vector-im/matrix-bot-sdk",
"@vector-im/matrix-bot-sdk": "npm:@vector-im/matrix-bot-sdk@^0.6.6-element.1"
},
"engines": {
"node": ">=18.0.0"
}
Expand Down
Loading

0 comments on commit 6949364

Please sign in to comment.