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

Fix _APP_CONSOLE_HOSTNAMES check

Ensure invalid hostnames such as empty strings are not added as a
hostname.
This commit is contained in:
Steven Nguyen 2024-01-03 19:25:54 +00:00
parent 06e385b346
commit faf39fcc81
No known key found for this signature in database
GPG key ID: 22EB8611C67E9E5C

View file

@ -80,6 +80,7 @@ use Utopia\Queue\Connection;
use Utopia\Storage\Storage;
use Utopia\VCS\Adapter\Git\GitHub as VcsGitHub;
use Utopia\Validator\Range;
use Utopia\Validator\Hostname;
use Utopia\Validator\IP;
use Utopia\Validator\URL;
use Utopia\Validator\WhiteList;
@ -947,15 +948,18 @@ App::setResource('clients', function ($request, $console, $project) {
], Document::SET_TYPE_APPEND);
$hostnames = explode(',', App::getEnv('_APP_CONSOLE_HOSTNAMES', ''));
if (is_array($hostnames)) {
foreach ($hostnames as $hostname) {
$console->setAttribute('platforms', [
'$collection' => ID::custom('platforms'),
'type' => Origin::CLIENT_TYPE_WEB,
'name' => $hostname,
'hostname' => $hostname,
], Document::SET_TYPE_APPEND);
$validator = new Hostname();
foreach ($hostnames as $hostname) {
$hostname = trim($hostname);
if (!$validator->isValid($hostname)) {
continue;
}
$console->setAttribute('platforms', [
'$collection' => ID::custom('platforms'),
'type' => Origin::CLIENT_TYPE_WEB,
'name' => $hostname,
'hostname' => $hostname,
], Document::SET_TYPE_APPEND);
}
/**