Commit graph

13 commits

Author SHA1 Message Date
thiemowmde e5df1df69e Lazy load large domains.php file only when it's really needed
I have seen this popping up once in a recent flame graph. I think most
services should be designed in a way that they can be instantiated
very quickly and only start doing expensive stuff when we are sure we
really need it. This was not the case here. The file domains.php is
about 150,000 lines long and can take several 100ms to load in the
worst case.

Bug: T200758
Change-Id: I7c0c787230e8cff40e8e73fede0ac1dce63ea1ca
2023-06-14 22:19:40 -04:00
Umherirrender da8ba82393 tests: Make PHPUnit data providers static
Initally used a new sniff with autofix (T333745)

Bug: T332865
Change-Id: I7cc7ccda4db61bc20f6b3ee225c9a5b7d484dd88
2023-05-20 14:02:30 +02:00
Reedy 4341066093 tests: Replace assertRegExp with assertMatchesRegularExpression
The method was renamed in PHPUnit 9.

Bug: T320334
Change-Id: I0a3f80ca07eecede80e21c4937ce70ef557c5ca7
2022-10-08 23:55:14 +01:00
Umherirrender f49dab01a1 Improve performance of string operation on domain lookup
The benchLookup.php shows that the lookups take half the time as before,
without more memory

In the lookup use offsets instead of preg_replace to create the smaller
strings, also simplify the return

In the hook handler use str_starts_with to check start of string,
strpos needs to scan the whole string for a negative check,
but we need only need information about the begin

Bug: T316443
Change-Id: Ibc0cbe5f7f14bd56d4e126fa7ed183a807d9a99c
2022-08-27 19:35:03 +00:00
Kunal Mehta 0509d34225 Switch to new hook handler format
* Turn HSTSPreloadLookup into a real service, per @todo
* Convert Hooks into a non-static class, take lookup as an argument
* Update tests for new calling style

== Test plan ==
* CI/tests pass
* Use Special:ExpandTemplates with a preloaded domain and localhost,
  observe preloaded link changes, localhost stays http

Bug: T271027
Change-Id: I0196350e85c09eedfba4dbf1dab81f9a757b2a12
2022-06-05 12:12:39 -04:00
jenkins-bot 6c4a07925c Merge "MediaWikiTestCase -> MediaWikiIntegrationTestCase" 2021-12-03 16:08:12 +00:00
Reedy 2e20b3edcd Fetch list from GitHub
For some reason Mozilla is blocking our requests from Toolforge,
using GitHub is something we know that works and should be the
same in practice.

Bug: T292242
Change-Id: Ic7d5da9758122ecb36f5e8f43716b4f8cf6f889d
2021-11-24 21:56:13 +00:00
Alexander Vorwerk d2f79d1664 MediaWikiTestCase -> MediaWikiIntegrationTestCase
MediaWikiTestCase has been renamed to MediaWikiIntegrationTestCase in 1.34.

Bug: T293043
Change-Id: I3a4b25e284497b72ef3fa6bb4082e07fb57a4fb9
2021-11-08 23:04:46 +00:00
Kunal Mehta dfa2506116 Update Legoktm's email address
Change-Id: Ic20c6d24d221fd5377bfa4a36a7f0ee034fad9e1
2021-04-11 19:10:07 -07:00
Kunal Mehta 933ce7188e Add a test verifying the reproducibility of domains.php
This test downloads the specified revision of the HSTS preload list,
regenerates it, and compares it with the committed version at
domains.php.

In theory it would catch any potential code injection in domains.php,
which is hard to manually review due to its length.

Bug: T241522
Change-Id: Iee2a393c590b830c6e78adba48edc921e2873465
2019-12-28 17:33:07 -08:00
Kunal Mehta 518d26f4a8 Add sanity check test for domains.php
The test verifies:
* domains.php returns an array
* The array has at least 50,000 items (right now it has ~78,000)
* Each domain in the array passes a regex, and the value is either 1 or 0

Bug: T240743
Change-Id: Ic4e2c2e36ddcb0f775f4ac22d1418c814db5b389
2019-12-13 23:09:54 -08:00
Kunal Mehta 537b15acf8 Add tests for Hooks
Change-Id: I0f30e9ccc995cbda7095aee040defcb061a174ac
2018-08-05 00:22:52 -06:00
Kunal Mehta f0ed5222ff Refactor out a HSTSPreloadLookup class plus tests
Makes it much easier to write tests, and do potential further
refactoring.

Change-Id: I072951bb2bc87639e076d03c233f7283c0b175ff
2018-08-01 21:23:49 -07:00