扩展:滥用过滤器

From MediaWiki.org
Jump to: navigation, search
This page is a translated version of the page Extension:AbuseFilter and the translation is 80% complete.

Other languages:
български • ‎català • ‎čeština • ‎dansk • ‎Deutsch • ‎English • ‎español • ‎فارسی • ‎suomi • ‎français • ‎galego • ‎עברית • ‎italiano • ‎日本語 • ‎한국어 • ‎polski • ‎português • ‎português do Brasil • ‎русский • ‎sicilianu • ‎粵語 • ‎中文
MediaWiki扩展手册Manual:Extensions
Crystal Clear action run.png
AbuseFilter

发布状态:Extension status 稳定版

AbuseFilter-Management.png
实现Template:Extension#type User activity, Special page, API
描述Template:Extension#description 允许特定基于行为的限制应用于wiki活动中。
作者Template:Extension#username
兼容性方针Compatibility#mediawiki_extensions 发行分支
MediaWikiTemplate:Extension#mediawiki 1.25+
PHPTemplate:Extension#php 建议5.4+
数据更新Template:Extension#needs-updatephp
表格Template:Extension#table1 abuse_filterExtension:AbuseFilter/abuse_filter table
abuse_filter_actionExtension:AbuseFilter/abuse_filter_action table
abuse_filter_historyExtension:AbuseFilter/abuse_filter_history table
abuse_filter_logExtension:AbuseFilter/abuse_filter_log table
许可协议Template:Extension#license GNU General Public License 2.0 or later
下载
参数Template:Extension#parameters
  • $wgAbuseFilterActions
  • $wgAbuseFilterConditionLimit
  • $wgAbuseFilterEmergencyDisableThreshold
  • $wgAbuseFilterEmergencyDisableCount
  • $wgAbuseFilterEmergencyDisableAge
  • $wgAbuseFilterParserClass
  • $wgAbuseFilterRestrictions
  • $wgAbuseFilterNotifications
  • $wgAbuseFilterNotificationsPrivate
  • $wgAbuseFilterCentralDB
  • $wgAbuseFilterIsCentral
  • $wgAbuseFilterDisallowGlobalLocalBlocks
  • $wgAbuseFilterBlockDuration
  • $wgAbuseFilterAnonBlockDuration
  • $wgAbuseFilterCustomActionsHandler
  • $wgAbuseFilterValidGroups
  • $wgAbuseFilterDefaultWarningMessage
  • $wgAbuseFilterIPMaxAge
  • $wgAbuseFilterProfile
  • $wgAbuseFilterRuntimeProfile
添加的权限Template:Extension#rights
  • abusefilter-view
  • abusefilter-log
  • abusefilter-log-detail
  • abusefilter-revert
  • abusefilter-private
  • abusefilter-view-private
  • abusefilter-log-private
  • abusefilter-hidden-log
  • abusefilter-hide-log
  • abusefilter-modify
  • abusefilter-modify-restricted
  • abusefilter-modify-global
使用的钩子Template:Extension#hook
EditFilterMergedManual:Hooks/EditFilterMerged
GetAutoPromoteGroupsManual:Hooks/GetAutoPromoteGroups
AbortMoveManual:Hooks/AbortMove
MovePageCheckPermissionsManual:Hooks/MovePageCheckPermissions
ArticleDeleteManual:Hooks/ArticleDelete
RecentChange_saveManual:Hooks/RecentChange_save
ListDefinedTagsManual:Hooks/ListDefinedTags
ChangeTagsListActiveManual:Hooks/ChangeTagsListActive
LoadExtensionSchemaUpdatesManual:Hooks/LoadExtensionSchemaUpdates
ContributionsToolLinksManual:Hooks/ContributionsToolLinks
UploadVerifyFileManual:Hooks/UploadVerifyFile
UploadVerifyUploadManual:Hooks/UploadVerifyUpload
UploadStashFileManual:Hooks/UploadStashFile
MakeGlobalVariablesScriptManual:Hooks/MakeGlobalVariablesScript
PageContentSaveCompleteManual:Hooks/PageContentSaveComplete
UserMergeAccountFieldsManual:Hooks/UserMergeAccountFields
ParserOutputStashForEditManual:Hooks/ParserOutputStashForEdit

翻译AbuseFilter扩展如果在translatewiki.net可用

检查使用和版本矩阵。

问题Phabricator

开放的工作 · 报告错误

滥用过滤器(AbuseFilter)扩展允许具有权限的用户设置当用户的操作(例如编辑)匹配特定标准时,要进行的特定操作。 例如,可以创建一个过滤器防止匿名用户添加外部链接或封禁移除超过2000个字符的用户。

条件

本扩展功能不依赖于其他功能,但如果需要使用字符串正常化功能的话,建议安装Extension:AntiSpoof

安装

  • 下载文件,并将其放置在您extensions/文件夹中的AbuseFilter目录内。
  • 将下列代码放置在您的LocalSettings.php的底部:
    wfLoadExtension( 'AbuseFilter' );
    
  • 运行更新脚本,它将自动创建此扩展必须依赖的数据库表。
  • YesY 完成 - 在您的wiki上导航至Special:Version,以验证扩展已成功安装。

致使用MediaWiki 1.26或更早版本的用户:

上面的说明介绍的是安装此扩展的新方法,它使用wfLoadExtension() 如果您需要在早期版本(MediaWiki 1.26和更早版本)中安装此扩展,而不是wfLoadExtension( 'AbuseFilter' );,您需要使用:

require_once "$IP/extensions/AbuseFilter/AbuseFilter.php";


用户权限

一旦您安装了此扩展,您将不得不在LocalSettings.php设置用户权限。

权限 描述
abusefilter-modify 修改防滥用过滤器
abusefilter-view 查看滥用过滤器
abusefilter-log 查看滥用日志
abusefilter-log-detail 查看详细滥用日志
abusefilter-private 查看滥用日志中的私有数据
abusefilter-modify-restricted 修改包含受限动作的防滥用过滤器
abusefilter-modify-global 创建或修改全域滥用过滤器
abusefilter-revert 撤销指定防滥用过滤器作出的所有更改
abusefilter-view-private 查看被标记为私有的防滥用过滤器
abusefilter-log-private 查看标记为私有的过滤器的过滤日志
abusefilter-hide-log 将条目在滥用日志中隐藏
abusefilter-hidden-log 查看隐藏的滥用日志条目

举个例子,如果按照以下配置的话,管理员能对滥用过滤器做任何设定,而任何人都能查看过滤日志和已公开的过滤器过滤代码:

$wgGroupPermissions['sysop']['abusefilter-modify'] = true;
$wgGroupPermissions['*']['abusefilter-log-detail'] = true;
$wgGroupPermissions['*']['abusefilter-view'] = true;
$wgGroupPermissions['*']['abusefilter-log'] = true;
$wgGroupPermissions['sysop']['abusefilter-private'] = true;
$wgGroupPermissions['sysop']['abusefilter-modify-restricted'] = true;
$wgGroupPermissions['sysop']['abusefilter-revert'] = true;
如果某过滤器被标记为私用,则拥有abusefilter-modify或abusefilter-view-private权限的用户才能查看该过滤器。

创建和管理过滤器

当安装好本插件,通过滥用管理器管理页Special:AbuseFilter查看过滤日志和创建、修改、测试、删除过滤器。

配置

值名 默认值 描述
$wgAbuseFilterActions array( 'flag' => true, 'throttle' => true, 'warn' => true, 'disallow' => true, 'blockautopromote' => true, 'block' => true, 'rangeblock' => false, 'degroup' => true, 'tag' => true ) 滥用过滤器可以进行的操作。
$wgAbuseFilterConditionLimit 1000 The maximum number of 'conditions' that can be used each time the filters are run against a change. (More complex filters require more 'conditions').
$wgAbuseFilterValidGroups 'default' The list of "groups" filters can be divided into. By default there is only one group.
$wgAbuseFilterEmergencyDisableThreshold array( 'default' => 0.05 ) Disable a filter if it matched more than 2 edits, constituting more than 5 % of the actions which were checked against the filter's group in the "observed" period (at most one day), unless the filter has been changed in the last 86400 seconds (one day)
$wgAbuseFilterEmergencyDisableCount array( 'default' => 2 )
$wgAbuseFilterEmergencyDisableAge array( 'default' => 86400 )
$wgAbuseFilterParserClass 'AbuseFilterParser' 滥用过滤器的解析器级的名字。
$wgAbuseFilterRestrictions array( 'block' => true, 'degroup' => true, 'blockautopromote' => true, 'rangeblock' => true ) Users must have the "abusefilter-modify-restricted" user right as well as "abusefilter-modify" in order to create or modify filters which carry out these actions.
$wgAbuseFilterNotifications false 允许配置扩展以发送触发通知至Special:RecentChanges或UDP。 可行的操作: rc, udp, rcandudp
$wgAbuseFilterNotificationsPrivate false 允许私有过滤器使用通知功能。
$wgAbuseFilterCentralDB null 指定全域过滤器的数据库名(只支持在最新开发版)
$wgAbuseFilterIsCentral false 设定为true时指定全域过滤器的存入数据库(只支持在最新开发版)
$wgAbuseFilterDisallowGlobalLocalBlocks false Disallow Centralised filters from taking actions that locally block, remove from groups, or revoke permissions.
$wgAbuseFilterBlockDuration 'indefinite' 滥用过滤器做出的封禁时限
$wgAbuseFilterAnonBlockDuration null Duration of blocks made by AbuseFilter on users who are not logged in. The value of $wgAbuseFilterBlockDuration will be used if this is not set.
$wgAbuseFilterCustomActionsHandlers array() 自定义动作的回调方法。
$wgAbuseFilterValidGroups array('default') Valid "filter groups" – used for applying edit filters to certain types of actions
$wgAbuseFilterDefaultWarningMessage array( 'default' => 'abusefilter-warning' ) 每个过滤器组的默认警告信息
$wgAbuseFilterLogIPMaxAge 3 * 30 * 24 * 3600 Age used as cutoff when purging old IP log data. Defaults to 3 months. Used by maintenance script purgeOldLogIPData.php.
$wgAbuseFilterProfile false
MediaWiki版本: 1.27

Whether to record data about the performance of filters – the average number of conditions used and the time consumed by every filter.

(This was always enabled in MediaWiki up to 1.25, then entirely removed from 1.26 for performance reasons, then restored in 1.27.)

$wgAbuseFilterRuntimeProfile false Whether to calculate and record the total runtime, conditions, and matched filters on each execution.


API

滥用过滤器有两个API的list模块,一个用于获得过滤器列表(“abusefilters”),另一个用于获得过滤日志。过滤日志是孤立于其他MediaWiki日志的(日志名为“abuselog”)。不能通过API创建或修改滥用过滤器。

list = abusefilters

列出关于过滤器的信息

参数
  • abfstartid:从该过滤器ID开始列举
  • abfendid:列举到该过滤器ID为止
  • abfdir:列举的方向(older、newer)
  • abfshow:只显示符合对应属性的过滤器(enabled|!enabled|deleted|!deleted|private|!private)
  • abflimit:每次列举最大数量
  • abfprop:欲获取的属性(id|description|pattern|actions|hits|comments|lasteditor|lastedittime|status|private)

如果过滤器是非公开的且您没有查看它的权限,abfprop中某些参数则不会显示。

例子

列出非私有滥用过滤器

list = abuselog

列出过滤器的触发日志。

参数
  • aflstart:从该时间戳开始列举
  • aflend:列举到该时间戳为止
  • afldir:列举的方向(older、newer,分别表示更旧、更新的日志先列出)
  • afluser:只显示该用户或IP地址触发过滤器的日志
  • afltitle:只显示该页面中触发过滤器的日志
  • aflfilter:只显示该过滤器ID的触发日志
  • afllimit:每次列举最大数量
  • aflprop:欲获取的属性(ids|user|title|action|result|timestamp|details)
例如

列出其中触发滥用过滤器响应用户“SineBot”的操作的实例

Possible errors

  • Some users might experience that creating new filters or modifying old filters fail and the user just gets redirected to the original page. If the Wiki is using SSL certificates, this error could possibly be because of the $wgServer value, which might be using "http://" instead of "https://". An indication of this error will be, the browser giving https warning for Special:AbuseFilter pages. (Topic:T23dyyih0ofjada5)

参见