mirror of
https://github.com/tiennm99/coolify.git
synced 2026-09-04 06:19:40 +00:00
fix(database): set PostgreSQL SSL certificate ownership (#11286)
This commit is contained in:
@@ -21,6 +21,35 @@ it('escapeshellarg wraps postgres_user in single quotes for chown command', func
|
||||
->toContain('chown');
|
||||
});
|
||||
|
||||
it('sets postgres SSL file ownership before starting the database container', function () {
|
||||
$source = file_get_contents(__DIR__.'/../../app/Actions/Database/StartPostgresql.php');
|
||||
|
||||
$permissionCommandPosition = strpos($source, '--entrypoint chown');
|
||||
$startCommandPosition = strpos($source, 'docker-compose.yml up -d');
|
||||
|
||||
expect($permissionCommandPosition)->not->toBeFalse()
|
||||
->and($startCommandPosition)->not->toBeFalse()
|
||||
->and($permissionCommandPosition)->toBeLessThan($startCommandPosition)
|
||||
->and($source)->toContain('postgres:postgres /var/lib/postgresql/certs/server.key')
|
||||
->not->toContain('chown {$postgresUser}:{$postgresUser}');
|
||||
});
|
||||
|
||||
it('sets database SSL file ownership before startup', function (string $action, string $owner, string $keyPath) {
|
||||
$source = file_get_contents(__DIR__."/../../app/Actions/Database/{$action}.php");
|
||||
|
||||
$permissionCommandPosition = strpos($source, '--entrypoint chown');
|
||||
$startCommandPosition = strpos($source, 'docker-compose.yml up -d');
|
||||
|
||||
expect($permissionCommandPosition)->not->toBeFalse()
|
||||
->and($startCommandPosition)->not->toBeFalse()
|
||||
->and($permissionCommandPosition)->toBeLessThan($startCommandPosition)
|
||||
->and($source)->toContain("{$owner} {$keyPath}");
|
||||
})->with([
|
||||
'mysql' => ['StartMysql', 'mysql:mysql', '/etc/mysql/certs/server.key'],
|
||||
'mariadb' => ['StartMariadb', 'mysql:mysql', '/etc/mysql/certs/server.key'],
|
||||
'mongodb' => ['StartMongodb', 'mongodb:mongodb', '/etc/mongo/certs/server.pem'],
|
||||
]);
|
||||
|
||||
it('advisory PoC postgres_user payload is contained by escapeshellarg in chown command', function () {
|
||||
// Simulates a legacy row that bypassed validation
|
||||
$maliciousUser = 'root; touch /tmp/pwned_rce; #';
|
||||
|
||||
Reference in New Issue
Block a user