Extension:BlockAI
Category:Extensions without a compatibility policyCategory:MIT licensed extensions
Release status: experimentalCategory:Experimental extensions |
|
|---|---|
| Implementation | HookCategory:Hook extensions, Artificial intelligenceCategory:Artificial intelligence extensions |
| Description | AI and bot crawler blocker for MediaWiki |
| Author(s) | Alexey (Vedmakatalk) |
| Latest version | 1.0.0 |
| MediaWiki | >= 1.39Category:Extensions with manual MediaWiki version |
| Database changes | No |
|
$wgBlockAIThreshold |
|
| Licence | MIT License |
| Download | GitHub:
Category:Extensions in GitHub version controlNote: |
The BlockAI extension enforces a set of rules that are intended to block AI crawlers and random bots spamming your wiki with requests to expensive pages like Special:RecentChanges and Special:RecentChangesLinked.
The extension evaluates only requests coming from anonymous users and ignores logged-in users completely. Every request is evaluated against a set of eval-rules, and a decision is made based on the request evaluation score.
For blocked requests, the extension forces an early HTTP 418 I am a teapot response.
Installation
- Download, extract and place the file(s) in a directory called
BlockAIin yourextensions/folder. - Add the following code at the bottom of your LocalSettings.php file:
wfLoadExtension( 'BlockAI' );
Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
Embedded evaluation rules
- InvalidRequest - fails for requests that are missing required headers
- ExpensiveActions - fails for requests that trigger expensive actions (any action except `view` and `info` is considered expensive)
- ForeignPosts - fails for requests that do POST but contain no Referrer header
- QueryParamsOrder - fails for requests that contain query parameters in a different order than expected by MediaWiki
- SpecialPageLock - fails for requests that access Special: pages that are considered expensive. All the Special pages are considered expensive except
UserLogin,CreateAccount,Search,Random,PasswordReset,ConfirmEmail.
Configuration parameters
| Parameter | Default value | Description |
|---|---|---|
| $wgBlockAIThreshold | 1.0 | Adjusts the threshold for marking a request as spammy. The default value is 1.0. Every evaluation rule may have its own weight, with the default weight being 1 for all the embedded evaluation rules |
At the moment, all the embedded evaluation rules have a weight of 1, thus you can either disable the blocks completely by setting the threshold to 0 or enable the blocks by setting it to 1. Any other values would take no effect until custom evaluation rules are added with weights < 1
See more details on the scoring logic at README.md
Adding custom evaluation rules
You can add your own evaluation rules by creating new classes that implement the IEval interface. The classes should be part of an extension, be loaded by the autoloader, and registered through extension attributes. See BlockAISample for more details and a sample custom evaluation rule.
