From 6c4b0ecd5bc47ea12b7e976aecb875a4f088b698 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 20 Feb 2024 23:27:40 +1300 Subject: [PATCH] Simplify allow list --- app/controllers/api/functions.php | 4 +--- app/controllers/api/projects.php | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 11eaa49393..66b995adae 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -172,9 +172,7 @@ App::post('/v1/functions') ->action(function (string $functionId, string $name, string $runtime, array $execute, array $events, string $schedule, int $timeout, bool $enabled, bool $logging, string $entrypoint, string $commands, string $installationId, string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $templateRepository, string $templateOwner, string $templateRootDirectory, string $templateBranch, Request $request, Response $response, Database $dbForProject, Document $project, Document $user, Event $queueForEvents, Build $queueForBuilds, Database $dbForConsole, GitHub $github) use ($redeployVcs) { $functionId = ($functionId == 'unique()') ? ID::unique() : $functionId; - $allowList = empty(App::getEnv('_APP_FUNCTIONS_RUNTIMES')) - ? [] - : \explode(',', App::getEnv('_APP_FUNCTIONS_RUNTIMES')); + $allowList = \array_filter(\explode(',', App::getEnv('_APP_FUNCTIONS_RUNTIMES', ''))); if (!empty($allowList) && !\in_array($runtime, $allowList)) { throw new Exception(Exception::FUNCTION_RUNTIME_UNSUPPORTED, 'Runtime "' . $runtime . '" is not supported'); diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 428e97ff50..73202a6e0a 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -84,9 +84,7 @@ App::post('/v1/projects') throw new Exception(Exception::TEAM_NOT_FOUND); } - $allowList = empty(App::getEnv('_APP_PROJECT_REGIONS')) - ? [] - : \explode(',', App::getEnv('_APP_PROJECT_REGIONS')); + $allowList = \array_filter(\explode(',', App::getEnv('_APP_PROJECT_REGIONS', ''))); if (!empty($allowList) && !\in_array($region, $allowList)) { throw new Exception(Exception::PROJECT_REGION_UNSUPPORTED, 'Region "' . $region . '" is not supported');