From bc9efa7b01bb3d4f3bb79406ac8d3febbaff56e8 Mon Sep 17 00:00:00 2001 From: Michael Vickers Date: Tue, 1 Oct 2019 21:33:35 +0100 Subject: [PATCH 1/2] Perform case insensitive comparison against the password list Make the password list and user provided password both lowercase, so bad passwords are always identified regardless of how many characters are capitalised --- src/DumbPasswordServiceProvider.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/DumbPasswordServiceProvider.php b/src/DumbPasswordServiceProvider.php index b5cb6da..c0a4317 100644 --- a/src/DumbPasswordServiceProvider.php +++ b/src/DumbPasswordServiceProvider.php @@ -40,9 +40,12 @@ public function boot() $path = realpath(__DIR__ . '/../resources/config/passwordlist.txt'); $cache_key = md5_file($path); $data = Cache::rememberForever('dumbpwd_list_' . $cache_key, function () use ($path) { - return collect(explode("\n", file_get_contents($path))); + return collect(explode("\n", file_get_contents($path))) + ->map(function ($password) { + return strtolower($password); + }); }); - return !$data->contains($value); + return !$data->contains(strtolower($value)); }, $this->message); } @@ -56,7 +59,7 @@ public function register() /** * Get the services provided by the provider. - * + * * @return array */ public function provides() From c377449ed9dfc4faff23d6ffd71bf801b729d8f5 Mon Sep 17 00:00:00 2001 From: Michael Vickers Date: Tue, 1 Oct 2019 21:48:17 +0100 Subject: [PATCH 2/2] Reinstate white space --- src/DumbPasswordServiceProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DumbPasswordServiceProvider.php b/src/DumbPasswordServiceProvider.php index c0a4317..719e926 100644 --- a/src/DumbPasswordServiceProvider.php +++ b/src/DumbPasswordServiceProvider.php @@ -59,7 +59,7 @@ public function register() /** * Get the services provided by the provider. - * + * * @return array */ public function provides()