mirror of
https://github.com/tiennm99/coolify.git
synced 2026-10-15 00:17:16 +00:00
refactor(settings): validate dev_helper_version and escape build args
Constrain dev_helper_version to Docker tag grammar
([A-Za-z0-9_][A-Za-z0-9_.-]{0,127}), re-validate before triggering the
helper image build, and interpolate the image reference via
escapeshellarg() when composing the docker build command.
This commit is contained in:
1 parent
e1f40903c3
commit
dc9322b11f
2 files changed
+102
-2
No files matched your search
@@ -35,7 +35,7 @@ class Index extends Component
|
||||
#[Validate('required|string|timezone')]
|
||||
public string $instance_timezone;
|
||||
|
||||
#[Validate('nullable|string|max:50')]
|
||||
#[Validate(['nullable', 'string', 'max:128', 'regex:/^[A-Za-z0-9_][A-Za-z0-9_.-]{0,127}$/'])]
|
||||
public ?string $dev_helper_version = null;
|
||||
|
||||
public array $domainConflicts = [];
|
||||
@@ -49,6 +49,7 @@ class Index extends Component
|
||||
protected array $messages = [
|
||||
'fqdn.url' => 'Invalid instance URL.',
|
||||
'fqdn.max' => 'URL must not exceed 255 characters.',
|
||||
'dev_helper_version.regex' => 'Dev helper version must match Docker tag format (alphanumeric, _, ., -; first char cannot be . or -).',
|
||||
];
|
||||
|
||||
public function render()
|
||||
@@ -184,6 +185,8 @@ class Index extends Component
|
||||
return;
|
||||
}
|
||||
|
||||
$this->validateOnly('dev_helper_version');
|
||||
|
||||
$version = $this->dev_helper_version ?: config('constants.coolify.helper_version');
|
||||
if (empty($version)) {
|
||||
$this->dispatch('error', 'Please specify a version to build.');
|
||||
@@ -191,7 +194,14 @@ class Index extends Component
|
||||
return;
|
||||
}
|
||||
|
||||
$buildCommand = "docker build -t ghcr.io/coollabsio/coolify-helper:{$version} -f docker/coolify-helper/Dockerfile .";
|
||||
if (! preg_match('/^[A-Za-z0-9_][A-Za-z0-9_.-]{0,127}$/', (string) $version)) {
|
||||
$this->dispatch('error', 'Invalid helper version format.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$imageRef = escapeshellarg("ghcr.io/coollabsio/coolify-helper:{$version}");
|
||||
$buildCommand = "docker build -t {$imageRef} -f docker/coolify-helper/Dockerfile .";
|
||||
|
||||
$activity = remote_process(
|
||||
command: [$buildCommand],
|
||||
|
||||
Reference in new issue
Block a user