|
13 | 13 | use Symfony\Component\Cache\Psr16Cache; |
14 | 14 | use TheCodingMachine\GraphQLite\Mappers\StaticClassListTypeMapper; |
15 | 15 | use TheCodingMachine\GraphQLite\Mappers\StaticClassListTypeMapperFactory; |
| 16 | +use Webmozart\Assert\Assert; |
16 | 17 | use function class_exists; |
17 | 18 | use Doctrine\Common\Annotations\AnnotationException; |
18 | 19 | use Doctrine\Common\Annotations\AnnotationReader as DoctrineAnnotationReader; |
@@ -102,14 +103,19 @@ class GraphqliteCompilerPass implements CompilerPassInterface |
102 | 103 | public function process(ContainerBuilder $container): void |
103 | 104 | { |
104 | 105 | $reader = $this->getAnnotationReader(); |
105 | | - $this->cacheDir = $container->getParameter('kernel.cache_dir'); |
| 106 | + $cacheDir = $container->getParameter('kernel.cache_dir'); |
| 107 | + Assert::string($cacheDir); |
| 108 | + $this->cacheDir = $cacheDir; |
106 | 109 | //$inputTypeUtils = new InputTypeUtils($reader, $namingStrategy); |
107 | 110 |
|
108 | 111 | // Let's scan the whole container and tag the services that belong to the namespace we want to inspect. |
109 | 112 | $controllersNamespaces = $container->getParameter('graphqlite.namespace.controllers'); |
| 113 | + Assert::isIterable($controllersNamespaces); |
110 | 114 | $typesNamespaces = $container->getParameter('graphqlite.namespace.types'); |
| 115 | + Assert::isIterable($typesNamespaces); |
111 | 116 |
|
112 | 117 | $firewallName = $container->getParameter('graphqlite.security.firewall_name'); |
| 118 | + Assert::string($firewallName); |
113 | 119 | $firewallConfigServiceName = 'security.firewall.map.config.'.$firewallName; |
114 | 120 |
|
115 | 121 | // 2 seconds of TTL in environment mode. Otherwise, let's cache forever! |
@@ -183,13 +189,20 @@ public function process(ContainerBuilder $container): void |
183 | 189 | if ($container->getParameter('graphqlite.security.introspection') === false) { |
184 | 190 | $rulesDefinition[] = $container->findDefinition(DisableIntrospection::class); |
185 | 191 | } |
186 | | - if ($container->getParameter('graphqlite.security.maximum_query_complexity')) { |
187 | | - $complexity = (int) $container->getParameter('graphqlite.security.maximum_query_complexity'); |
188 | | - $rulesDefinition[] = $container->findDefinition(QueryComplexity::class)->setArgument(0, $complexity); |
| 192 | + if ($container->hasParameter('graphqlite.security.maximum_query_complexity')) { |
| 193 | + $complexity = $container->getParameter('graphqlite.security.maximum_query_complexity'); |
| 194 | + Assert::integerish($complexity); |
| 195 | + |
| 196 | + $rulesDefinition[] = $container->findDefinition(QueryComplexity::class) |
| 197 | + ->setArgument(0, (int) $complexity); |
189 | 198 | } |
190 | | - if ($container->getParameter('graphqlite.security.maximum_query_depth')) { |
191 | | - $depth = (int) $container->getParameter('graphqlite.security.maximum_query_depth'); |
192 | | - $rulesDefinition[] = $container->findDefinition(QueryDepth::class)->setArgument(0, $depth); |
| 199 | + |
| 200 | + if ($container->hasParameter('graphqlite.security.maximum_query_depth')) { |
| 201 | + $depth = $container->getParameter('graphqlite.security.maximum_query_depth'); |
| 202 | + Assert::integerish($depth); |
| 203 | + |
| 204 | + $rulesDefinition[] = $container->findDefinition(QueryDepth::class) |
| 205 | + ->setArgument(0, (int) $depth); |
193 | 206 | } |
194 | 207 | $serverConfigDefinition->addMethodCall('setValidationRules', [$rulesDefinition]); |
195 | 208 |
|
|
0 commit comments