From ff9527a2e969ae1baa691add01f6cdbde36eb709 Mon Sep 17 00:00:00 2001 From: Sky Mulley Date: Thu, 8 Oct 2026 09:54:19 +0100 Subject: [PATCH] fix tests to pass --- .../Auth/ResetPasswordController.php | 4 +-- .../Middleware/Api/AuthenticateIPAccess.php | 3 +-- app/Http/Middleware/VerifyReCaptcha.php | 3 +-- .../Api/Client/Account/StoreApiKeyRequest.php | 2 +- app/Listeners/RevocationListener.php | 8 +++--- app/Models/Mount.php | 27 ++++++++++--------- app/Rules/NotInPathHierarchy.php | 3 +-- 7 files changed, 24 insertions(+), 26 deletions(-) diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.php index 7d32b492b..d043136db 100644 --- a/app/Http/Controllers/Auth/ResetPasswordController.php +++ b/app/Http/Controllers/Auth/ResetPasswordController.php @@ -114,9 +114,7 @@ class ResetPasswordController extends Controller if (! $user->use_totp) { Auth::guard()->login($user); - if (method_exists(Auth::guard(), 'logoutOtherDevices')) { - Auth::guard()->logoutOtherDevices($password); - } + Auth::guard()->logoutOtherDevices($password); } $this->hasTwoFactor = $user->use_totp; diff --git a/app/Http/Middleware/Api/AuthenticateIPAccess.php b/app/Http/Middleware/Api/AuthenticateIPAccess.php index fddefc5bf..dc0322298 100644 --- a/app/Http/Middleware/Api/AuthenticateIPAccess.php +++ b/app/Http/Middleware/Api/AuthenticateIPAccess.php @@ -6,7 +6,6 @@ namespace Pterodactyl\Http\Middleware\Api; use Closure; use Illuminate\Http\Request; -use Illuminate\Support\Facades\Log; use InvalidArgumentException; use IPTools\Exception\IpException; use IPTools\Exception\NetworkException; @@ -62,7 +61,7 @@ class AuthenticateIPAccess if (Range::parse($ip)->contains($find)) { return $next($request); } - } catch (IpException | NetworkException | InvalidArgumentException $exception) { + } catch (IpException|NetworkException|InvalidArgumentException) { // Ignore the error entirely continue; } diff --git a/app/Http/Middleware/VerifyReCaptcha.php b/app/Http/Middleware/VerifyReCaptcha.php index 8f9e4c796..0a0dd3848 100644 --- a/app/Http/Middleware/VerifyReCaptcha.php +++ b/app/Http/Middleware/VerifyReCaptcha.php @@ -12,7 +12,6 @@ use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Http\Request; use Illuminate\Http\Response; use Illuminate\Support\Arr; -use Illuminate\Support\Facades\Log; use Pterodactyl\Events\Auth\FailedCaptcha; use Pterodactyl\Support\JsonValueGuard; use Symfony\Component\HttpKernel\Exception\HttpException; @@ -76,7 +75,7 @@ class VerifyReCaptcha if ($res->getStatusCode() === 200) { return $this->decodeResponse($res->getBody()->__toString()); } - } catch (GuzzleException $exception) { + } catch (GuzzleException) { // Ignore the error entirely, we will just return a failed response below. } diff --git a/app/Http/Requests/Api/Client/Account/StoreApiKeyRequest.php b/app/Http/Requests/Api/Client/Account/StoreApiKeyRequest.php index d1178cdd3..156035598 100644 --- a/app/Http/Requests/Api/Client/Account/StoreApiKeyRequest.php +++ b/app/Http/Requests/Api/Client/Account/StoreApiKeyRequest.php @@ -52,7 +52,7 @@ class StoreApiKeyRequest extends ClientApiRequest $valid = false; try { $valid = Range::parse($ip)->valid(); - } catch (IpException | NetworkException | InvalidArgumentException) { + } catch (IpException|NetworkException|InvalidArgumentException) { $valid = false; } diff --git a/app/Listeners/RevocationListener.php b/app/Listeners/RevocationListener.php index 49554c65e..43dca9dc9 100644 --- a/app/Listeners/RevocationListener.php +++ b/app/Listeners/RevocationListener.php @@ -6,6 +6,7 @@ namespace Pterodactyl\Listeners; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Database\Eloquent\Collection; +use Illuminate\Database\Query\Builder; use Illuminate\Foundation\Bus\PendingDispatch; use Illuminate\Support\Facades\DB; use Illuminate\Support\Str; @@ -14,6 +15,7 @@ use Pterodactyl\Events\User\PasswordChanged; use Pterodactyl\Extensions\Illuminate\Events\Contracts\SubscribesToEvents; use Pterodactyl\Jobs\RevokeSftpAccessJob; use Pterodactyl\Models\Node; +use Pterodactyl\Support\JsonValueGuard; class RevocationListener implements SubscribesToEvents { @@ -26,13 +28,13 @@ class RevocationListener implements SubscribesToEvents ])->saveQuietly(); if (config('session.driver') === 'database') { - $table = config('session.table', 'sessions'); - if (is_string($table) && $table !== '') { + $table = JsonValueGuard::string(config('session.table', 'sessions')); + if ($table !== '') { $currentSessionId = session()->isStarted() ? session()->getId() : null; DB::table($table) ->where('user_id', $user->id) - ->when($event instanceof PasswordChanged && $currentSessionId, function ($query) use ($currentSessionId): void { + ->when($event instanceof PasswordChanged && $currentSessionId, function (Builder $query) use ($currentSessionId): void { $query->where('id', '!=', $currentSessionId); }) ->delete(); diff --git a/app/Models/Mount.php b/app/Models/Mount.php index 887414cba..6d003ef2a 100644 --- a/app/Models/Mount.php +++ b/app/Models/Mount.php @@ -65,6 +65,18 @@ class Mount extends Model implements Identifiable '/home/container', ]; + /** + * @return array + */ + protected function casts(): array + { + return [ + 'id' => 'int', + 'read_only' => 'bool', + 'user_mountable' => 'bool', + ]; + } + /** * Normalizes an absolute path string by resolving '.', '..', and duplicate slashes * without requiring the path to exist on the host filesystem. @@ -80,25 +92,14 @@ class Mount extends Model implements Identifiable if ($segment === '..') { array_pop($parts); + continue; } $parts[] = $segment; } - return '/' . implode('/', $parts); - } - - /** - * @return array - */ - protected function casts(): array - { - return [ - 'id' => 'int', - 'read_only' => 'bool', - 'user_mountable' => 'bool', - ]; + return '/'.implode('/', $parts); } /** diff --git a/app/Rules/NotInPathHierarchy.php b/app/Rules/NotInPathHierarchy.php index 551531bec..f477bcd84 100644 --- a/app/Rules/NotInPathHierarchy.php +++ b/app/Rules/NotInPathHierarchy.php @@ -26,7 +26,7 @@ class NotInPathHierarchy implements ValidationRule foreach ($this->invalidPaths as $blocked) { $blocked = rtrim($blocked, '/'); - if ($path === $blocked || str_starts_with($path, $blocked . '/')) { + if ($path === $blocked || str_starts_with($path, $blocked.'/')) { $fail("The {$attribute} path cannot be or reside within [{$blocked}]."); return; @@ -34,4 +34,3 @@ class NotInPathHierarchy implements ValidationRule } } } -