Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Executor/StorageFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class StorageFactory
*
* @throws InvalidArgumentException When the connection string cannot be parsed or names a scheme with no device
*/
public static function getDevice(string $root, ?string $connection = '', (ClientInterface&StreamingClientInterface)|null $client = null): Device
public static function getDevice(string $root, #[\SensitiveParameter] ?string $connection = '', (ClientInterface&StreamingClientInterface)|null $client = null): Device
{
$connection ??= '';
$localSchemes = ['file', DeviceType::Local->value];
Expand All @@ -40,8 +40,8 @@ public static function getDevice(string $root, ?string $connection = '', (Client

try {
$dsn = new DSN($connection);
} catch (\Throwable $throwable) {
throw new InvalidArgumentException('Unable to parse storage DSN: ' . $throwable->getMessage(), previous: $throwable);
} catch (\Throwable) {
throw new InvalidArgumentException('Unable to parse storage DSN');
}

$scheme = $dsn->getScheme();
Expand Down
22 changes: 22 additions & 0 deletions tests/unit/Executor/StorageFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,28 @@ public function testUnusableConnectionIsRefused(string $connection): void
StorageFactory::getDevice('/storage/builds/app-test', $connection);
}

public function testRefusalDoesNotPrintTheConnection(): void
{
$ignoreArgs = \ini_set('zend.exception_ignore_args', '0');
$maxLength = \ini_set('zend.exception_string_param_max_len', '1000000');

try {
foreach (self::unusableConnections() as $name => [$connection]) {
try {
StorageFactory::getDevice('/storage/builds/app-test', $connection);
$this->fail(sprintf("Connection '%s' was accepted", $name));
} catch (InvalidArgumentException $exception) {
$printed = (string) $exception;
$this->assertStringContainsString('/storage/builds/app-test', $printed, $name);
$this->assertStringNotContainsString($connection, $printed, $name);
}
}
} finally {
\ini_set('zend.exception_ignore_args', $ignoreArgs);
\ini_set('zend.exception_string_param_max_len', $maxLength);
}
}

/**
* @return \Iterator<string, array{(string | null)}>
*/
Expand Down
Loading