Skip to content

Commit a27c87b

Browse files
Mark DSNs as #[SensitiveParameter]
1 parent 4b33917 commit a27c87b

32 files changed

+54
-82
lines changed

src/Symfony/Component/Cache/Adapter/AbstractAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public static function createSystemCache(string $namespace, int $defaultLifetime
110110
return new ChainAdapter([$apcu, $opcache]);
111111
}
112112

113-
public static function createConnection(string $dsn, array $options = [])
113+
public static function createConnection(#[\SensitiveParameter] string $dsn, array $options = [])
114114
{
115115
if (str_starts_with($dsn, 'redis:') || str_starts_with($dsn, 'rediss:')) {
116116
return RedisAdapter::createConnection($dsn, $options);

src/Symfony/Component/Cache/Adapter/CouchbaseBucketAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function __construct(\CouchbaseBucket $bucket, string $namespace = '', in
5454
$this->marshaller = $marshaller ?? new DefaultMarshaller();
5555
}
5656

57-
public static function createConnection(array|string $servers, array $options = []): \CouchbaseBucket
57+
public static function createConnection(#[\SensitiveParameter] array|string $servers, array $options = []): \CouchbaseBucket
5858
{
5959
if (\is_string($servers)) {
6060
$servers = [$servers];

src/Symfony/Component/Cache/Adapter/CouchbaseCollectionAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function __construct(Collection $connection, string $namespace = '', int
4747
$this->marshaller = $marshaller ?? new DefaultMarshaller();
4848
}
4949

50-
public static function createConnection(array|string $dsn, array $options = []): Bucket|Collection
50+
public static function createConnection(#[\SensitiveParameter] array|string $dsn, array $options = []): Bucket|Collection
5151
{
5252
if (\is_string($dsn)) {
5353
$dsn = [$dsn];

src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public static function isSupported()
9292
*
9393
* @throws \ErrorException When invalid options or servers are provided
9494
*/
95-
public static function createConnection(array|string $servers, array $options = []): \Memcached
95+
public static function createConnection(#[\SensitiveParameter] array|string $servers, array $options = []): \Memcached
9696
{
9797
if (\is_string($servers)) {
9898
$servers = [$servers];

src/Symfony/Component/Cache/Adapter/PdoAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class PdoAdapter extends AbstractAdapter implements PruneableInterface
5555
* @throws InvalidArgumentException When PDO error mode is not PDO::ERRMODE_EXCEPTION
5656
* @throws InvalidArgumentException When namespace contains invalid characters
5757
*/
58-
public function __construct(\PDO|string $connOrDsn, string $namespace = '', int $defaultLifetime = 0, array $options = [], MarshallerInterface $marshaller = null)
58+
public function __construct(#[\SensitiveParameter] \PDO|string $connOrDsn, string $namespace = '', int $defaultLifetime = 0, array $options = [], MarshallerInterface $marshaller = null)
5959
{
6060
if (\is_string($connOrDsn) && str_contains($connOrDsn, '://')) {
6161
throw new InvalidArgumentException(sprintf('Usage of Doctrine DBAL URL with "%s" is not supported. Use a PDO DSN or "%s" instead. Got "%s".', __CLASS__, DoctrineDbalAdapter::class, $connOrDsn));

src/Symfony/Component/Cache/Traits/RedisTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ private function init(\Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface $
8080
*
8181
* @throws InvalidArgumentException when the DSN is invalid
8282
*/
83-
public static function createConnection(string $dsn, array $options = []): \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface
83+
public static function createConnection(#[\SensitiveParameter] string $dsn, array $options = []): \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface
8484
{
8585
if (str_starts_with($dsn, 'redis:')) {
8686
$scheme = 'redis';

src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class PdoSessionHandler extends AbstractSessionHandler
151151
*
152152
* @throws \InvalidArgumentException When PDO error mode is not PDO::ERRMODE_EXCEPTION
153153
*/
154-
public function __construct(\PDO|string $pdoOrDsn = null, array $options = [])
154+
public function __construct(#[\SensitiveParameter] \PDO|string $pdoOrDsn = null, array $options = [])
155155
{
156156
if ($pdoOrDsn instanceof \PDO) {
157157
if (\PDO::ERRMODE_EXCEPTION !== $pdoOrDsn->getAttribute(\PDO::ATTR_ERRMODE)) {
@@ -415,7 +415,7 @@ public function close(): bool
415415
/**
416416
* Lazy-connects to the database.
417417
*/
418-
private function connect(string $dsn): void
418+
private function connect(#[\SensitiveParameter] string $dsn): void
419419
{
420420
$this->pdo = new \PDO($dsn, $this->username, $this->password, $this->connectionOptions);
421421
$this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
@@ -427,7 +427,7 @@ private function connect(string $dsn): void
427427
*
428428
* @todo implement missing support for oci DSN (which look totally different from other PDO ones)
429429
*/
430-
private function buildDsnFromUrl(string $dsnOrUrl): string
430+
private function buildDsnFromUrl(#[\SensitiveParameter] string $dsnOrUrl): string
431431
{
432432
// (pdo_)?sqlite3?:///... => (pdo_)?sqlite3?://localhost/... or else the URL will be invalid
433433
$url = preg_replace('#^((?:pdo_)?sqlite3?):///#', '$1://localhost/', $dsnOrUrl);

src/Symfony/Component/Lock/Store/DoctrineDbalPostgreSqlStore.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class DoctrineDbalPostgreSqlStore implements BlockingSharedLockStoreInterface, B
3838
*
3939
* @throws InvalidArgumentException When first argument is not Connection nor string
4040
*/
41-
public function __construct(Connection|string $connOrUrl)
41+
public function __construct(#[\SensitiveParameter] Connection|string $connOrUrl)
4242
{
4343
if ($connOrUrl instanceof Connection) {
4444
if (!$connOrUrl->getDatabasePlatform() instanceof PostgreSQLPlatform) {
@@ -243,7 +243,7 @@ private function unlockShared(Key $key): void
243243
*
244244
* @throws InvalidArgumentException when driver is not supported
245245
*/
246-
private function filterDsn(string $dsn): string
246+
private function filterDsn(#[\SensitiveParameter] string $dsn): string
247247
{
248248
if (!str_contains($dsn, '://')) {
249249
throw new InvalidArgumentException(sprintf('String "%" is not a valid DSN for Doctrine DBAL.', $dsn));

src/Symfony/Component/Lock/Store/PdoStore.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class PdoStore implements PersistingStoreInterface
6464
* @throws InvalidArgumentException When PDO error mode is not PDO::ERRMODE_EXCEPTION
6565
* @throws InvalidArgumentException When the initial ttl is not valid
6666
*/
67-
public function __construct(\PDO|string $connOrDsn, array $options = [], float $gcProbability = 0.01, int $initialTtl = 300)
67+
public function __construct(#[\SensitiveParameter] \PDO|string $connOrDsn, #[\SensitiveParameter] array $options = [], float $gcProbability = 0.01, int $initialTtl = 300)
6868
{
6969
$this->init($options, $gcProbability, $initialTtl);
7070

src/Symfony/Component/Lock/Store/PostgreSqlStore.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class PostgreSqlStore implements BlockingSharedLockStoreInterface, BlockingStore
4949
* @throws InvalidArgumentException When PDO error mode is not PDO::ERRMODE_EXCEPTION
5050
* @throws InvalidArgumentException When namespace contains invalid characters
5151
*/
52-
public function __construct(\PDO|string $connOrDsn, array $options = [])
52+
public function __construct(#[\SensitiveParameter] \PDO|string $connOrDsn, #[\SensitiveParameter] array $options = [])
5353
{
5454
if ($connOrDsn instanceof \PDO) {
5555
if (\PDO::ERRMODE_EXCEPTION !== $connOrDsn->getAttribute(\PDO::ATTR_ERRMODE)) {

0 commit comments

Comments
 (0)