mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-23 21:53:35 +00:00
Merge "Add abusefilter-bypass-blocked-external-domains right"
This commit is contained in:
commit
651ad4f507
|
@ -28,7 +28,8 @@
|
|||
"abusefilter-hidden-log",
|
||||
"abusefilter-hide-log",
|
||||
"abusefilter-modify-global",
|
||||
"abusefilter-modify-blocked-external-domains"
|
||||
"abusefilter-modify-blocked-external-domains",
|
||||
"abusefilter-bypass-blocked-external-domains"
|
||||
],
|
||||
"GroupPermissions": {
|
||||
"*": {
|
||||
|
@ -47,6 +48,9 @@
|
|||
"suppress": {
|
||||
"abusefilter-hidden-log": true,
|
||||
"abusefilter-hide-log": true
|
||||
},
|
||||
"bot": {
|
||||
"abusefilter-bypass-blocked-external-domains": true
|
||||
}
|
||||
},
|
||||
"GrantPermissions": {
|
||||
|
@ -62,6 +66,9 @@
|
|||
"abusefilter-hidden-log": true,
|
||||
"abusefilter-log-private": true,
|
||||
"abusefilter-view-private": true
|
||||
},
|
||||
"editprotected": {
|
||||
"abusefilter-bypass-blocked-external-domains": true
|
||||
}
|
||||
},
|
||||
"SpecialPages": {
|
||||
|
@ -376,7 +383,8 @@
|
|||
"AbuseFilterEditRevUpdater",
|
||||
"AbuseFilterVariablesManager",
|
||||
"AbuseFilterBlockedDomainStorage",
|
||||
"UrlUtils"
|
||||
"UrlUtils",
|
||||
"PermissionManager"
|
||||
]
|
||||
},
|
||||
"CheckUser": {
|
||||
|
|
|
@ -598,5 +598,7 @@
|
|||
"notification-link-text-show-filter": "Show filter",
|
||||
"right-abusefilter-modify-blocked-external-domains": "Create or modify what external domains are blocked from being linked",
|
||||
"action-abusefilter-modify-blocked-external-domains": "create or modify what external domains are blocked from being linked",
|
||||
"right-abusefilter-bypass-blocked-external-domains": "Bypass blocked external domains",
|
||||
"action-abusefilter-bypass-blocked-external-domains": "bypass blocked external domain",
|
||||
"abusefilter-blocked-domains-cannot-edit-directly": "Create or modify what external domains are blocked from being linked must be done through [[Special:BlockedExternalDomains|the special page]]."
|
||||
}
|
||||
|
|
|
@ -640,5 +640,7 @@
|
|||
"notification-link-text-show-filter": "Label for button that links to the filter that was throttled.",
|
||||
"right-abusefilter-modify-blocked-external-domains": "{{doc-right|abusefilter-modify-blocked-external-domains}}",
|
||||
"action-abusefilter-modify-blocked-external-domains": "{{doc-action|abusefilter-modify-blocked-external-domains}}",
|
||||
"right-abusefilter-bypass-blocked-external-domains": "{{doc-right|abusefilter-bypass-blocked-external-domains}}",
|
||||
"action-abusefilter-bypass-blocked-external-domains": "{{doc-action|abusefilter-bypass-blocked-external-domains}}",
|
||||
"abusefilter-blocked-domains-cannot-edit-directly": "Error message shown when someone tries to edit the list of blocked domains directly and bypass the Special page."
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ use MediaWiki\Hook\UploadStashFileHook;
|
|||
use MediaWiki\Hook\UploadVerifyUploadHook;
|
||||
use MediaWiki\Logger\LoggerFactory;
|
||||
use MediaWiki\Page\Hook\ArticleDeleteHook;
|
||||
use MediaWiki\Permissions\PermissionManager;
|
||||
use MediaWiki\Revision\SlotRecord;
|
||||
use MediaWiki\Storage\Hook\ParserOutputStashForEditHook;
|
||||
use MediaWiki\Utils\UrlUtils;
|
||||
|
@ -52,6 +53,7 @@ class FilteredActionsHandler implements
|
|||
private VariablesManager $variablesManager;
|
||||
private BlockedDomainStorage $blockedDomainStorage;
|
||||
private UrlUtils $urlUtils;
|
||||
private PermissionManager $permissionManager;
|
||||
|
||||
/**
|
||||
* @param IBufferingStatsdDataFactory $statsDataFactory
|
||||
|
@ -61,6 +63,7 @@ class FilteredActionsHandler implements
|
|||
* @param VariablesManager $variablesManager
|
||||
* @param BlockedDomainStorage $blockedDomainStorage
|
||||
* @param UrlUtils $urlUtils
|
||||
* @param PermissionManager $permissionManager
|
||||
*/
|
||||
public function __construct(
|
||||
IBufferingStatsdDataFactory $statsDataFactory,
|
||||
|
@ -69,7 +72,8 @@ class FilteredActionsHandler implements
|
|||
EditRevUpdater $editRevUpdater,
|
||||
VariablesManager $variablesManager,
|
||||
BlockedDomainStorage $blockedDomainStorage,
|
||||
UrlUtils $urlUtils
|
||||
UrlUtils $urlUtils,
|
||||
PermissionManager $permissionManager
|
||||
) {
|
||||
$this->statsDataFactory = $statsDataFactory;
|
||||
$this->filterRunnerFactory = $filterRunnerFactory;
|
||||
|
@ -78,6 +82,7 @@ class FilteredActionsHandler implements
|
|||
$this->variablesManager = $variablesManager;
|
||||
$this->blockedDomainStorage = $blockedDomainStorage;
|
||||
$this->urlUtils = $urlUtils;
|
||||
$this->permissionManager = $permissionManager;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -163,6 +168,10 @@ class FilteredActionsHandler implements
|
|||
}
|
||||
|
||||
$this->editRevUpdater->setLastEditPage( $page );
|
||||
|
||||
if ( $this->permissionManager->userHasRight( $user, 'abusefilter-bypass-blocked-external-domains' ) ) {
|
||||
return Status::newGood();
|
||||
}
|
||||
$blockedDomainFilterResult = $this->blockedDomainFilter( $vars );
|
||||
if ( $blockedDomainFilterResult instanceof Status ) {
|
||||
return $blockedDomainFilterResult;
|
||||
|
@ -354,6 +363,9 @@ class FilteredActionsHandler implements
|
|||
// @todo Return all errors instead of only the first one
|
||||
$error = $filterResultApi->getErrors()[0]['message'];
|
||||
} else {
|
||||
if ( $this->permissionManager->userHasRight( $user, 'abusefilter-bypass-blocked-external-domains' ) ) {
|
||||
return true;
|
||||
}
|
||||
$blockedDomainFilterResult = $this->blockedDomainFilter( $vars );
|
||||
if ( $blockedDomainFilterResult instanceof Status ) {
|
||||
$error = $blockedDomainFilterResult->getErrors()[0]['message'];
|
||||
|
|
|
@ -511,7 +511,8 @@ class AbuseFilterConsequencesTest extends MediaWikiIntegrationTestCase {
|
|||
AbuseFilterServices::getEditRevUpdater(),
|
||||
AbuseFilterServices::getVariablesManager(),
|
||||
AbuseFilterServices::getBlockedDomainStorage(),
|
||||
$services->getUrlUtils()
|
||||
$services->getUrlUtils(),
|
||||
$services->getPermissionManager()
|
||||
);
|
||||
$hooksHandler->onEditFilterMergedContent( $context, $content, $status, $summary,
|
||||
$this->user, false );
|
||||
|
|
|
@ -320,7 +320,8 @@ class ActionVariablesIntegrationTest extends ApiTestCase {
|
|||
AbuseFilterServices::getEditRevUpdater(),
|
||||
AbuseFilterServices::getVariablesManager(),
|
||||
AbuseFilterServices::getBlockedDomainStorage(),
|
||||
MediaWikiServices::getInstance()->getUrlUtils()
|
||||
MediaWikiServices::getInstance()->getUrlUtils(),
|
||||
MediaWikiServices::getInstance()->getPermissionManager()
|
||||
);
|
||||
$this->setTemporaryHook(
|
||||
'EditFilterMergedContent',
|
||||
|
|
Loading…
Reference in a new issue