mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
fix: filter Sites build runtimes by _APP_SITES_RUNTIMES
listFrameworks was returning every framework runtime, so the Console showed uninstalled options unlike Functions. Filter against the env allowlist and reject unsupported buildRuntime on create/update. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
3 files changed
+21
No files matched your search
@@ -11,6 +11,7 @@ use Utopia\Config\Config;
|
||||
use Utopia\Database\Document;
|
||||
use Utopia\Platform\Action;
|
||||
use Utopia\Platform\Scope\HTTP;
|
||||
use Utopia\System\System;
|
||||
|
||||
class XList extends Base
|
||||
{
|
||||
@@ -52,11 +53,19 @@ class XList extends Base
|
||||
public function action(Response $response)
|
||||
{
|
||||
$frameworks = Config::getParam('frameworks');
|
||||
$allowList = \array_filter(\array_map('trim', \explode(',', System::getEnv('_APP_SITES_RUNTIMES', ''))));
|
||||
|
||||
foreach ($frameworks as $key => $framework) {
|
||||
if (!empty($framework['adapters'])) {
|
||||
$frameworks[$key]['adapters'] = \array_values($framework['adapters']);
|
||||
}
|
||||
|
||||
if (!empty($allowList) && !empty($framework['runtimes'])) {
|
||||
$frameworks[$key]['runtimes'] = \array_values(\array_filter(
|
||||
$framework['runtimes'],
|
||||
fn ($runtime) => \in_array($runtime, $allowList, true)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
$response->dynamic(new Document([
|
||||
|
||||
@@ -144,6 +144,12 @@ class Create extends Base
|
||||
}
|
||||
}
|
||||
|
||||
$allowList = \array_filter(\array_map('trim', \explode(',', System::getEnv('_APP_SITES_RUNTIMES', ''))));
|
||||
|
||||
if (!empty($allowList) && !\in_array($buildRuntime, $allowList, true)) {
|
||||
throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'Runtime "' . $buildRuntime . '" is not supported');
|
||||
}
|
||||
|
||||
$siteId = ($siteId == 'unique()') ? ID::unique() : $siteId;
|
||||
|
||||
$installation = $dbForPlatform->getDocument('installations', $installationId);
|
||||
|
||||
@@ -158,6 +158,12 @@ class Update extends Base
|
||||
}
|
||||
}
|
||||
|
||||
$allowList = \array_filter(\array_map('trim', \explode(',', System::getEnv('_APP_SITES_RUNTIMES', ''))));
|
||||
|
||||
if (!empty($allowList) && !empty($buildRuntime) && !\in_array($buildRuntime, $allowList, true)) {
|
||||
throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'Runtime "' . $buildRuntime . '" is not supported');
|
||||
}
|
||||
|
||||
// TODO: If only branch changes, re-deploy
|
||||
$site = $dbForProject->getDocument('sites', $siteId);
|
||||
|
||||
|
||||
Reference in new issue
Block a user