Commit graph

6068 commits

Author SHA1 Message Date
Daimona Eaytoy aafd3bcfcd Inject the condition limit into AbuseFilterParser
Change-Id: I487ba25ca3f3ac4b84c3afaf88b35678944cdb4d
2021-01-01 18:27:06 +01:00
Daimona Eaytoy fad9a11f7a Add a TextExtractor service
This is an important step towards removing the AbuseFilter class. Note:
proposals for the name of the new service are welcome.

Change-Id: Ib4632173f728b1bdafadef96e01645a833bfceaa
2021-01-01 18:25:32 +01:00
Matěj Suchánek ec2beb97b7 Rename AbuseFilterTest to GlobalNameUtilsTest
The suite doesn't anything from AbuseFilter class anymore.

Change-Id: If54de5ad2f4c68803768848e08154f8a3199a63a
2021-01-01 18:11:39 +01:00
jenkins-bot bac48babd8 Merge "Partly reorg integration tests" 2021-01-01 17:07:18 +00:00
jenkins-bot 6fcd3e147d Merge "Introduce a VariablesFormatter service" 2021-01-01 17:03:12 +00:00
Daimona Eaytoy e381d1995b Partly reorg integration tests
Move to 'integration' all tests that are meant to stay there. Move
SaveTest outside because, while we might want to finalize it as an
integration test, some parts can still be moved to a unit test.

Change-Id: Id4b6deaac6875fdd85eebbebf0c5fb952d1fbb06
2021-01-01 15:54:52 +00:00
Daimona Eaytoy b85f464530 Introduce a VariablesFormatter service
Moves more methods away from the AbuseFilter class. Testing
buildVarDumpTable is not easy because we'd have to parse the generated HTML.

Change-Id: I073a537201de150ba9dd7bf15a99f3a009dc6ba1
2021-01-01 15:45:52 +01:00
Daimona Eaytoy f7d74a0745 Fix path of parser tests
Follow-up: Ie46ef18d6ba1017e25c76b1762f678e5452264d9

Tests were silently ignored.

Change-Id: Ice0b7c78759add387afd50e5f7724d454a2b0c71
2021-01-01 15:42:09 +01:00
Daimona Eaytoy 0e69c18545 Organize unit tests
Add namespaces, shorten class names.

Non-unit tests and AbuseFilterTest are untouched because those should be
refactored first.

Change-Id: Ie46ef18d6ba1017e25c76b1762f678e5452264d9
2021-01-01 13:26:37 +00:00
jenkins-bot 544911a78d Merge "Add a LazyVariableComputer service" 2021-01-01 00:18:32 +00:00
Daimona Eaytoy a6176399b1 Make tests pass on SQLite
Skip a test that fails with
  Wikimedia\Rdbms\DBQueryError: Error 5: database is locked
  Function: Wikimedia\Rdbms\Database::beginIfImplied (MediaWiki\Extension\AbuseFilter\FilterLookup::getAllActiveFiltersInGroupFromDB)
  
Probably due to some concurrency issue caused by the duplicate connection, and also with

  Wikimedia\Rdbms\DBQueryError: Error 1: no such table: unittest_external_abuse_filter
  Function: MediaWiki\Extension\AbuseFilter\FilterLookup::getAllActiveFiltersInGroupFromDB
  
for unknown reasons.

Move the mwGlobals override inside the test to avoid the same "database is locked" error
on every other test in that class.

Bug: T251967
Change-Id: I552a8d1fa532941f630fd734e590993e7462aeb0
2020-12-31 20:11:10 +00:00
Matěj Suchánek 2793e7f1cf Reversible consequences
Introduce ReversibleConsequence interface for Consequence classes
whose potentially destructive actions can be reverted using
Special:AbuseFilter/revert. This allows moving reverting logic from
AbuseFilterViewRevert to individual Consequence classes and testing.

Unfortunately, the code is definitely not very clean now.

Change-Id: I558da711f1645ccf64792c6102cf743827171320
2020-12-31 14:43:32 +01:00
Daimona Eaytoy c7f06750d6 Add a LazyVariableComputer service
See task for a description of the plan. Also note that
AFComputedVariable should be renamed and its properties made private.

This commit includes some adjustments for taint-check in
AbuseFilter::buildVarDumpTable and ::revisionToString.

There's some space for improvement in the new LazyVariableComputer, but
that's left for another commit.

Bug: T261069
Change-Id: Ia44f6e079d39f44cf0122dec5ddb5513ab54f0c6
2020-12-31 14:05:52 +01:00
jenkins-bot f3d3e3b238 Merge "Replace compact() with real array" 2020-12-30 13:10:04 +00:00
Translation updater bot b27f53cf4b Localisation updates from https://translatewiki.net.
Change-Id: Ifb15e2bde4ce0fe05be14fbe8a032a5401c9e2fa
2020-12-30 10:12:50 +01:00
Umherirrender 18094772c7 Replace compact() with real array
Easier to read

Change-Id: I5eb35b27399d7a4524fcfdf864d38e70a0f3a4ae
2020-12-29 23:00:44 +01:00
Translation updater bot e5184810d2 Localisation updates from https://translatewiki.net.
Change-Id: I1b457600c08fea2e094e30dad106223dd968cb9f
2020-12-29 09:46:00 +01:00
Translation updater bot 886ade187e Localisation updates from https://translatewiki.net.
Change-Id: I8f3f108a96f3825c45552c99ded85ad17dca1859
2020-12-28 10:36:31 +01:00
Translation updater bot 11f9085ad8 Localisation updates from https://translatewiki.net.
Change-Id: I3361882a2c5fe4b5efda7fbbfcbc31ac1fea32aa
2020-12-23 08:31:25 +01:00
Translation updater bot cdfac7b1d0 Localisation updates from https://translatewiki.net.
Change-Id: Ic8704f1b7295614fc39fe2eba3f95c5f47e9e64c
2020-12-22 08:29:14 +01:00
Translation updater bot 2550ee4ad4 Localisation updates from https://translatewiki.net.
Change-Id: I749035dd0207bba6cbfa3f06b044c37e7c1eb0fe
2020-12-21 08:36:54 +01:00
jenkins-bot 534ad9cfe6 Merge "Add a service to format filter specs" 2020-12-20 10:21:39 +00:00
jenkins-bot 16ef710ee3 Merge "Test some Consequence classes and clean up" 2020-12-20 09:25:39 +00:00
jenkins-bot 7be26dcb27 Merge "Improve code coverage" 2020-12-20 09:13:20 +00:00
jenkins-bot 3aafce35d2 Merge "build: Updating mediawiki/mediawiki-phan-config to 0.10.6" 2020-12-19 22:52:07 +00:00
Matěj Suchánek 63b950e5b6 Test some Consequence classes and clean up
Sadly, these are not unit tests.

Bug: T201193
Change-Id: I4c977ab14b273b02803a63f0a7b152a581a838b2
2020-12-19 16:31:22 +01:00
Matěj Suchánek 352a207c70 Improve code coverage
Bug: T201193
Change-Id: Ie086fd525bec19c63c13f8710a27897229cc33c8
2020-12-19 16:28:34 +01:00
jenkins-bot 4ef41d3844 Merge "Avoid 'finally' clause in AbuseFilterParser::parseDetailed" 2020-12-19 15:13:13 +00:00
Daimona Eaytoy 7bcb5ec2d5 Add a service to format filter specs
This requires a MessageLocalizer, which currently means providing the
main RequestContext. This is the only alternative right now, until core
provides a proper MessageLocalizer service (see T247127).

Change-Id: I8c93e2ae7e7bd4fc561c5e8490ed2feb1ef0edc2
2020-12-19 14:22:08 +01:00
libraryupgrader 682b6136e7 build: Updating mediawiki/mediawiki-phan-config to 0.10.6
Change-Id: I910c56e32829cea54a16105253004901e00a1885
2020-12-19 13:09:09 +00:00
Daimona Eaytoy 5d4b2fde27 Avoid 'finally' clause in AbuseFilterParser::parseDetailed
Bug: T270514
Change-Id: I1e3e6675ec8c3bfd435797cb044b85b3d2a34450
2020-12-19 11:17:58 +00:00
Matěj Suchánek dc7509811a Notify of a throttled filter
Use Echo for delivering the notification to the last
user who edited the filter.

Much boilerplate.

Change-Id: I7a46a03b4f15de20902ec70c62fb4fe750096842
Depends-On: If585b14a6dd6fb8c7d2c3bee1f20d9d08eaac706
2020-12-19 10:31:29 +01:00
jenkins-bot d386633103 Merge "Create a dedicated namespace for all consequences-related classes" 2020-12-18 22:57:00 +00:00
Daimona Eaytoy b394956c22 Create a dedicated namespace for all consequences-related classes
Change-Id: Ibc39593e34da36e57b640af0b5bbf2145f725e92
2020-12-18 19:27:33 +00:00
Daimona Eaytoy 7c1d1c6d7d Return warnings from the parser, add warning for catch-all regexps
This commit introduces some boilerplate for emitting warnings from the
AbuseFilter parser, and also code for showing these warnings in the ace
editor. Adding new warnings should be as simple as appending to
AbuseFilterParser::warnings (and adding the relevant i18n).

Bug: T264768
Bug: T269770
Change-Id: Ic11021b379f997a89f59c8c0572338d957e089a6
2020-12-18 18:22:41 +01:00
Daimona Eaytoy 2a3b636a45 Run real-time validation of rules with an Ace worker
The worker itself is essentially a wrapper around the
abusefilterchecksyntax API.

NOTE: As written in code comments, basically the whole
worker-abusefilter.js script consists of boilerplate code. You can
verify this by diffing this file and 6cb8a9cae1/modules/ace/worker-json.js
This means that there are only ~60 lines of code to review in that file.

Bug: T187686
Change-Id: I8950fcd5917ba226dda80b47b2bb713e685fad36
2020-12-18 15:05:28 +00:00
jenkins-bot e1a7acf55f Merge "Implement GetAutoPromoteGroupsHook" 2020-12-18 13:41:28 +00:00
Translation updater bot a039021c60 Localisation updates from https://translatewiki.net.
Change-Id: I329cba239ff3e81c59f8c8834bd40e73dfcc3ce4
2020-12-18 08:23:36 +01:00
James D. Forrester 7109c954a2 Use User->isRegistered(), not deprecated isLoggedIn()
Bug: T270450
Change-Id: I6ebf2f8040b6ac53025b5ccf503e5e221341eb09
2020-12-17 18:37:14 -08:00
jenkins-bot b9af9972c6 Merge "Create FilterRunnerFactory" 2020-12-17 19:16:54 +00:00
jenkins-bot 6d0d2258e8 Merge "Introduce ConsequencesExecutor" 2020-12-17 19:06:44 +00:00
Translation updater bot 1f76eb356b Localisation updates from https://translatewiki.net.
Change-Id: I18c15dcdc2dd1613b042567efa106a6d30e8e01e
2020-12-17 08:53:56 +01:00
Translation updater bot 8c0579b023 Localisation updates from https://translatewiki.net.
Change-Id: I683cd82b16135f7ed1d1af96c5c8e3eb254d2488
2020-12-16 08:29:11 +01:00
Matěj Suchánek 2da4cb4321 Implement GetAutoPromoteGroupsHook
Test coverage included.

Bug: T261067
Change-Id: Iba49f0518d2c1a72405498b2743e5ef300dd6d61
2020-12-15 18:01:04 +01:00
Amir Aharoni 2e70051b61 Remove unnecessary word from abusefilter-log-hide-done
"Successfully" is usually not necessary in messages. See:
https://www.mediawiki.org/wiki/Localisation#Avoid_jargon_and_slang

Change-Id: I6a19fba8aebbb4c9cc09d448abbbfa67c2761c8d
2020-12-15 16:15:14 +02:00
Daimona Eaytoy 3f7dd25fbf Create FilterRunnerFactory
Next step is splitting the Runner into various subclasses.

Change-Id: I766555f31b425cee52fd262c5bfb1c73f3f170d2
2020-12-15 12:47:34 +00:00
Daimona Eaytoy 68adaa5cb1 Introduce ConsequencesExecutor
This is the last big step towards moving Consequences-related things away from
AbuseFilterRunner. There's still some cleanup to do (+ write proper tests), but
this should really be the last important code change.

Change-Id: I347795fe93ba496c43b1d5cfc9ba6e1326842c06
2020-12-15 13:47:21 +01:00
jenkins-bot f430cd211a Merge "Add a VariablesBlobStore service" 2020-12-15 12:43:28 +00:00
Translation updater bot dbb0070f95 Localisation updates from https://translatewiki.net.
Change-Id: I6d932684d6cfe33833ac14964cf02841f7127bd3
2020-12-15 08:34:46 +01:00
jenkins-bot e4023defd0 Merge "Use a BlobStore for storing var dumps" 2020-12-15 02:58:49 +00:00