From 68d2578732429b190d14550fcbce2bdae5fd7919 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Mon, 18 Aug 2025 22:52:27 +0200 Subject: [PATCH] Validate extraOptions configuration --- src/DependencyInjection/Configuration.php | 16 +++++++++++++++- tests/DependencyInjection/ConfigurationTest.php | 2 +- .../Fixtures/config/yml/full.yml | 4 +++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index db190e3c..00be0881 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -12,6 +12,7 @@ use Symfony\Component\Config\Definition\ConfigurationInterface; use function count; +use function explode; use function in_array; use function is_array; use function is_string; @@ -428,7 +429,20 @@ private function addConnectionsSection(ArrayNodeDefinition $rootNode): void ->end() ->end() ->arrayNode('extraOptions') - ->prototype('variable')->end() + ->children() + ->scalarNode('mongocryptdURI')->end() + ->booleanNode('mongocryptdBypassSpawn')->end() + ->scalarNode('mongocryptdSpawnPath')->end() + ->arrayNode('mongocryptdSpawnArgs') + ->beforeNormalization() + ->ifString() + ->then(static fn ($v) => explode(' ', $v)) + ->end() + ->prototype('scalar')->cannotBeEmpty()->end() + ->end() + ->scalarNode('cryptSharedLibPath')->end() + ->booleanNode('cryptSharedLibRequired')->end() + ->end() ->end() ->booleanNode('bypassQueryAnalysis')->end() ->arrayNode('tlsOptions') diff --git a/tests/DependencyInjection/ConfigurationTest.php b/tests/DependencyInjection/ConfigurationTest.php index 42a66d78..b2068366 100644 --- a/tests/DependencyInjection/ConfigurationTest.php +++ b/tests/DependencyInjection/ConfigurationTest.php @@ -257,7 +257,7 @@ public function testFullConfiguration(array $config): void 'mongocryptdURI' => 'mongodb://localhost:27020', 'mongocryptdBypassSpawn' => true, 'mongocryptdSpawnPath' => '%kernel.project_dir%/bin/mongocryptd', - 'mongocryptdSpawnArgs' => '--pidfilepath=%kernel.project_dir%/var/mongocryptd.pid --idleShutdownTimeoutSecs=60', + 'mongocryptdSpawnArgs' => ['--pidfilepath=%kernel.project_dir%/var/mongocryptd.pid', '--idleShutdownTimeoutSecs=60'], 'cryptSharedLibPath' => '%kernel.project_dir%/bin/mongo_crypt_v1.dylib', 'cryptSharedLibRequired' => true, ], diff --git a/tests/DependencyInjection/Fixtures/config/yml/full.yml b/tests/DependencyInjection/Fixtures/config/yml/full.yml index 4b334a38..eb08b7aa 100644 --- a/tests/DependencyInjection/Fixtures/config/yml/full.yml +++ b/tests/DependencyInjection/Fixtures/config/yml/full.yml @@ -130,7 +130,9 @@ doctrine_mongodb: mongocryptdURI: 'mongodb://localhost:27020' mongocryptdBypassSpawn: true mongocryptdSpawnPath: '%kernel.project_dir%/bin/mongocryptd' - mongocryptdSpawnArgs: '--pidfilepath=%kernel.project_dir%/var/mongocryptd.pid --idleShutdownTimeoutSecs=60' + mongocryptdSpawnArgs: + - '--pidfilepath=%kernel.project_dir%/var/mongocryptd.pid' + - '--idleShutdownTimeoutSecs=60' cryptSharedLibPath: '%kernel.project_dir%/bin/mongo_crypt_v1.dylib' cryptSharedLibRequired: true