Skip to content

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.

fix: Escape container name in orphaned PR cleanup job

Andras Bacsaiebac90097a60
diff --git a/app/Jobs/CleanupOrphanedPreviewContainersJob.php b/app/Jobs/CleanupOrphanedPreviewContainersJob.php
index 790ad14896..5d3bed4573 100644
--- a/app/Jobs/CleanupOrphanedPreviewContainersJob.php
+++ b/app/Jobs/CleanupOrphanedPreviewContainersJob.php
@@ -179,6 +179,16 @@ class CleanupOrphanedPreviewContainersJob implements ShouldBeEncrypted, ShouldBe
private function removeContainer($container, Server $server): void
{
$containerName = data_get($container, 'Names');
+
+ if (empty($containerName)) {
+ Log::warning('CleanupOrphanedPreviewContainersJob - Cannot remove container: missing container name', [
+ 'container_data' => $container,
+ 'server' => $server->name,
+ ]);
+
+ return;
+ }
+
$applicationId = $this->extractApplicationId($container);
$pullRequestId = $this->extractPullRequestId($container);
@@ -189,9 +199,11 @@ class CleanupOrphanedPreviewContainersJob implements ShouldBeEncrypted, ShouldBe
'server' => $server->name,
]);
+ $escapedContainerName = escapeshellarg($containerName);
+
try {
instant_remote_process(
- ["docker rm -f {$containerName}"],
+ ["docker rm -f {$escapedContainerName}"],
$server,
false
);