1
0
Fork 0
mirror of synced 2024-09-29 17:01:37 +13:00

Simplify allow list

This commit is contained in:
Jake Barnby 2024-02-20 23:27:40 +13:00
parent eb4d6f8e20
commit 6c4b0ecd5b
No known key found for this signature in database
GPG key ID: C437A8CC85B96E9C
2 changed files with 2 additions and 6 deletions

View file

@ -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');

View file

@ -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');