From ad5d360a619f0bcd74ba556a5b8bd0af07b4c1a4 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Fri, 25 May 2018 14:50:55 -0400 Subject: [PATCH] MediaWiki\Auth\Throttler: Change "ip" key name Apparently 'ip' is overwritten by logstash at some level, so use 'ipKey' instead. Change-Id: I0547acdbb9f3fc7a990bd4baa2d748e89bac8c3b --- includes/auth/Throttler.php | 4 ++-- tests/phpunit/includes/auth/ThrottlerTest.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/auth/Throttler.php b/includes/auth/Throttler.php index 3125bd3fd8..717b592e16 100644 --- a/includes/auth/Throttler.php +++ b/includes/auth/Throttler.php @@ -138,7 +138,7 @@ class Throttler implements LoggerAwareInterface { $this->logRejection( [ 'throttle' => $this->type, 'index' => $index, - 'ip' => $ipKey, + 'ipKey' => $ipKey, 'username' => $username, 'count' => $count, 'expiry' => $expiry, @@ -193,7 +193,7 @@ class Throttler implements LoggerAwareInterface { protected function logRejection( array $context ) { $logMsg = 'Throttle {throttle} hit, throttled for {expiry} seconds due to {count} attempts ' - . 'from username {username} and IP {ip}'; + . 'from username {username} and IP {ipKey}'; // If we are hitting a throttle for >= warningLimit attempts, it is much more likely to be // an attack than someone simply forgetting their password, so log it at a higher level. diff --git a/tests/phpunit/includes/auth/ThrottlerTest.php b/tests/phpunit/includes/auth/ThrottlerTest.php index f963ad9c70..12e8a4917b 100644 --- a/tests/phpunit/includes/auth/ThrottlerTest.php +++ b/tests/phpunit/includes/auth/ThrottlerTest.php @@ -199,7 +199,7 @@ class ThrottlerTest extends \MediaWikiTestCase { $logger->expects( $this->once() )->method( 'log' )->with( $this->anything(), $this->anything(), [ 'throttle' => 'custom', 'index' => 0, - 'ip' => '1.2.3.4', + 'ipKey' => '1.2.3.4', 'username' => 'SomeUser', 'count' => 1, 'expiry' => 10, -- 2.20.1