mirror of
https://github.com/tiennm99/coolify.git
synced 2026-09-10 06:20:26 +00:00
fix: improve s3 storage handling
This commit is contained in:
@@ -53,6 +53,7 @@ test('S3Storage model fillable attributes are configured correctly', function ()
|
||||
$s3Storage = new S3Storage;
|
||||
|
||||
expect($s3Storage->getFillable())->toBe([
|
||||
'team_id',
|
||||
'name',
|
||||
'description',
|
||||
'region',
|
||||
@@ -118,3 +119,27 @@ test('S3Storage connection validation returns friendly timeout error', function
|
||||
|
||||
expect($s3Storage->is_usable)->toBeFalse();
|
||||
});
|
||||
|
||||
test('S3Storage testConnection rejects invalid bucket before building client', function (string $bucket) {
|
||||
Storage::shouldReceive('build')->never();
|
||||
|
||||
$s3Storage = new S3Storage;
|
||||
$s3Storage->setRawAttributes([
|
||||
'name' => 'Test S3',
|
||||
'region' => 'us-east-1',
|
||||
'key' => 'AKIAEXAMPLE',
|
||||
'secret' => 'secret',
|
||||
'bucket' => $bucket,
|
||||
'endpoint' => 'https://s3.amazonaws.com',
|
||||
]);
|
||||
|
||||
expect(fn () => $s3Storage->testConnection())
|
||||
->toThrow(RuntimeException::class, 'S3 bucket name is not allowed');
|
||||
})->with([
|
||||
'semicolon injection' => ['lab; id; #'],
|
||||
'command substitution' => ['lab$(id)'],
|
||||
'backticks' => ['lab`id`'],
|
||||
'newline' => ["lab\nid"],
|
||||
'underscore' => ['lab_bucket'],
|
||||
'uppercase' => ['LabBucket'],
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user