An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
fix(storage): guard volume names and authorize source removal
Andras Bacsai937892b3ea5d
diff --git a/app/Livewire/Project/Service/Storage.php b/app/Livewire/Project/Service/Storage.phpindex bb8a39d2b1..6880b5ab09 100644--- a/app/Livewire/Project/Service/Storage.php+++ b/app/Livewire/Project/Service/Storage.php@@ -374,10 +374,9 @@ class Storage extends Componentprivate function generateDefaultVolumeName(): string{- return str($this->resource->name ?? 'volume')- ->slug()- ->append('-data')- ->value();+ $name = str($this->resource->name)->slug()->value();++ return ($name ?: 'volume').'-data';}public function fileStoragePreviewPath(): stringdiff --git a/resources/views/livewire/project/shared/storages/all.blade.php b/resources/views/livewire/project/shared/storages/all.blade.phpindex 09377dac91..dbe21fd7b8 100644--- a/resources/views/livewire/project/shared/storages/all.blade.php+++ b/resources/views/livewire/project/shared/storages/all.blade.php@@ -160,6 +160,7 @@<x-forms.input id="forms.{{ $id }}.hostPath" /></div><x-modal-confirmation title="Remove Source Path?" isErrorButton+ canGate="update" :canResource="$resource"buttonTitle="Remove" submitAction="clearHostPath({{ $id }})":actions="['Are you sure you want to remove the source path?',diff --git a/tests/Feature/PersistentStorageVolumesLayoutTest.php b/tests/Feature/PersistentStorageVolumesLayoutTest.phpindex 1a94eda2e7..99133d7945 100644--- a/tests/Feature/PersistentStorageVolumesLayoutTest.php+++ b/tests/Feature/PersistentStorageVolumesLayoutTest.php@@ -215,6 +215,7 @@ it('keeps bind mount source paths out of the add volume form', function () {->not->toContain('id="host_path"')->not->toContain('Swarm Mode detected')->and($volumesView)+ ->toMatch('/<x-modal-confirmation title="Remove Source Path\?"[^>]*canGate="update"[^>]*:canResource="\$resource"/')->toContain('The next deployment will use a named Docker volume instead.')->toContain('Data from the existing host directory will not be copied to the named volume.');});@@ -242,6 +243,13 @@ it('uses a resource based default name for new volumes', function () {->assertSet('name', 'storage-app-data');});+it('uses a valid fallback default volume name when the resource name has no slug characters', function () {+ [$application] = createApplicationWithVolume(['name' => '---']);++ Livewire::test(Storage::class, ['resource' => $application])+ ->assertSet('name', 'volume-data');+});+it('removes existing bind mount source paths from the volume table', function () {[$application, $volume] = createApplicationWithVolume(volumeAttributes: ['host_path' => '/srv/storage',