fix(docker): escape container status commands

Build container status commands with escaped container names in the
Docker helper so callers can pass raw identifiers consistently.
This commit is contained in:
Andras Bacsai
2026-07-07 18:00:40 +02:00
parent a165e03d06
commit 9f13434273
3 changed files with 22 additions and 10 deletions
@@ -1016,12 +1016,20 @@ describe('service application lifecycle command escaping', function () {
'stop action' => 'Actions/Service/StopServiceApplication.php',
]);
test('service application logs endpoint escapes container name before docker helpers', function () {
test('docker status helper escapes container names', function () {
$source = file_get_contents(base_path('bootstrap/helpers/docker.php'));
expect($source)->toContain('function buildContainerStatusCommand')
->and($source)->toContain('escapeshellarg("name={$container_id}")')
->and($source)->toContain('escapeshellarg($container_id)');
});
test('service application logs endpoint passes raw container name to docker helpers', function () {
$source = file_get_contents(app_path('Http/Controllers/Api/ServiceApplicationsController.php'));
expect($source)->toContain('$safeContainerName = escapeshellarg($containerName)')
->and($source)->toContain('getContainerStatus($server, $safeContainerName)')
->and($source)->toContain('getContainerLogs($server, $containerName, $lines)');
expect($source)->toContain('getContainerStatus($server, $containerName)')
->and($source)->toContain('getContainerLogs($server, $containerName, $lines)')
->and($source)->not->toContain('$safeContainerName = escapeshellarg($containerName)');
});
});