aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2025-07-18 23:53:18 -0100
committerMaxence Lange <maxence@artificial-owl.com>2025-07-20 00:49:11 -0100
commit484491e7cc61a17b115b66b0cb2535ccf9f850b7 (patch)
tree7165b8103c73e1c2642de53d700cbe5e8d3a53db
parent20b908cf3fc5d8f47652192cfb07127fd484226c (diff)
downloadnextcloud-server-fix/noid/no-lazy-loading-on-isBypassListed.tar.gz
nextcloud-server-fix/noid/no-lazy-loading-on-isBypassListed.zip
fix(bruteforce): limit appconfig lazy loadingfix/noid/no-lazy-loading-on-isBypassListed
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
-rw-r--r--lib/private/Security/Ip/BruteforceAllowList.php5
-rw-r--r--tests/lib/Security/Ip/BruteforceAllowListTest.php4
2 files changed, 3 insertions, 6 deletions
diff --git a/lib/private/Security/Ip/BruteforceAllowList.php b/lib/private/Security/Ip/BruteforceAllowList.php
index cc4f0ceebe5..fb837690a7b 100644
--- a/lib/private/Security/Ip/BruteforceAllowList.php
+++ b/lib/private/Security/Ip/BruteforceAllowList.php
@@ -36,10 +36,7 @@ class BruteforceAllowList {
return false;
}
- $keys = $this->appConfig->getKeys('bruteForce');
- $keys = array_filter($keys, static fn ($key): bool => str_starts_with($key, 'whitelist_'));
-
- foreach ($keys as $key) {
+ foreach ($this->appConfig->searchKeys('bruteForce', 'whitelist_') as $key) {
$rangeString = $this->appConfig->getValueString('bruteForce', $key);
try {
$range = $this->factory->rangeFromString($rangeString);
diff --git a/tests/lib/Security/Ip/BruteforceAllowListTest.php b/tests/lib/Security/Ip/BruteforceAllowListTest.php
index 0cffc128d64..1454b779c1b 100644
--- a/tests/lib/Security/Ip/BruteforceAllowListTest.php
+++ b/tests/lib/Security/Ip/BruteforceAllowListTest.php
@@ -138,8 +138,8 @@ class BruteforceAllowListTest extends TestCase {
array $allowList,
bool $isAllowListed,
): void {
- $this->appConfig->method('getKeys')
- ->with($this->equalTo('bruteForce'))
+ $this->appConfig->method('searchKeys')
+ ->with($this->equalTo('bruteForce'), $this->equalTo('whitelist_'))
->willReturn(array_keys($allowList));
$this->appConfig->method('getValueString')