From 14b7c4947dd86cca1263f87e0d5e0e18247c3c23 Mon Sep 17 00:00:00 2001 From: Josh Salway Date: Tue, 7 Apr 2026 13:40:38 +1000 Subject: [PATCH] Add null check for SSH key generation in KeyRepository KeyRepository::create() calls keysFactory.php via exec() and json_decodes the result without checking for failure. If the subprocess fails (wrong PHP binary, missing deps, PHAR path issues), json_decode returns null and the subsequent array access crashes with "Trying to access array offset on null". This adds an abort_if guard with a helpful error message pointing to the script that failed. Fixes #96 --- app/Repositories/KeyRepository.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Repositories/KeyRepository.php b/app/Repositories/KeyRepository.php index 4e4e8db..90dfd2a 100644 --- a/app/Repositories/KeyRepository.php +++ b/app/Repositories/KeyRepository.php @@ -42,6 +42,8 @@ public function create($name) $keys = json_decode(exec($basePath.'/scripts/keysFactory.php'), true); + abort_if(is_null($keys), 1, 'Failed to generate SSH key. Ensure PHP can execute '.$basePath.'/scripts/keysFactory.php'); + File::put($this->keysPath.'/'.$this->privateKeyName($name), $keys['private']); File::chmod($this->keysPath.'/'.$this->privateKeyName($name), 0600);