From 1943c7a98b9416473b65bc6b754a56df3fbe3644 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Wed, 3 Mar 2021 21:02:11 -0800 Subject: [PATCH] Prevent catastrophic boot failure in wings when a server egg has bad data; closes #3055 --- app/Services/Eggs/EggConfigurationService.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/Services/Eggs/EggConfigurationService.php b/app/Services/Eggs/EggConfigurationService.php index 3b3ca2d11..597f67611 100644 --- a/app/Services/Eggs/EggConfigurationService.php +++ b/app/Services/Eggs/EggConfigurationService.php @@ -98,6 +98,16 @@ class EggConfigurationService // Normalize the output of the configuration for the new Wings Daemon to more // easily ingest, as well as make things more flexible down the road. foreach ($configs as $file => $data) { + // Try to head off any errors relating to parsing a set of configuration files + // or other JSON data for the egg. This should probably be blocked at the time + // of egg creation/update, but it isn't so this check will at least prevent a + // 500 error which would crash the entire Wings boot process. + // + // @see https://github.com/pterodactyl/panel/issues/3055 + if (!is_object($data) || !isset($data->find)) { + continue; + } + $append = array_merge((array) $data, ['file' => $file, 'replace' => []]); foreach ($this->iterate($data->find, $structure) as $find => $replace) {