|
15 | 15 | use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface; |
16 | 16 | use TheCodingMachine\GraphQLite\Mappers\StaticClassListTypeMapperFactory; |
17 | 17 | use Webmozart\Assert\Assert; |
| 18 | +use function assert; |
18 | 19 | use function class_exists; |
19 | 20 | use Doctrine\Common\Annotations\AnnotationReader as DoctrineAnnotationReader; |
20 | 21 | use Doctrine\Common\Annotations\AnnotationRegistry; |
@@ -75,18 +76,18 @@ public function process(ContainerBuilder $container): void |
75 | 76 | { |
76 | 77 | $reader = $this->getAnnotationReader(); |
77 | 78 | $cacheDir = $container->getParameter('kernel.cache_dir'); |
78 | | - Assert::string($cacheDir); |
| 79 | + assert(is_string($cacheDir)); |
79 | 80 | $this->cacheDir = $cacheDir; |
80 | 81 | //$inputTypeUtils = new InputTypeUtils($reader, $namingStrategy); |
81 | 82 |
|
82 | 83 | // Let's scan the whole container and tag the services that belong to the namespace we want to inspect. |
83 | 84 | $controllersNamespaces = $container->getParameter('graphqlite.namespace.controllers'); |
84 | | - Assert::isIterable($controllersNamespaces); |
85 | 85 | $typesNamespaces = $container->getParameter('graphqlite.namespace.types'); |
86 | | - Assert::isIterable($typesNamespaces); |
| 86 | + assert(is_iterable($controllersNamespaces)); |
| 87 | + assert(is_iterable($typesNamespaces)); |
87 | 88 |
|
88 | 89 | $firewallName = $container->getParameter('graphqlite.security.firewall_name'); |
89 | | - Assert::string($firewallName); |
| 90 | + assert(is_string($firewallName)); |
90 | 91 | $firewallConfigServiceName = 'security.firewall.map.config.'.$firewallName; |
91 | 92 |
|
92 | 93 | // 2 seconds of TTL in environment mode. Otherwise, let's cache forever! |
@@ -128,7 +129,11 @@ public function process(ContainerBuilder $container): void |
128 | 129 |
|
129 | 130 | if ($disableLogin === false) { |
130 | 131 | // Let's do some dark magic. We need the user provider. We need its name. It is stored in the "config" object. |
131 | | - $provider = $container->findDefinition('security.firewall.map.config.'.$firewallName)->getArgument(5); |
| 132 | + $providerConfigKey = 'security.firewall.map.config.'.$firewallName; |
| 133 | + $provider = $container->findDefinition($providerConfigKey)->getArgument(5); |
| 134 | + if (!is_string($provider)){ |
| 135 | + throw new GraphQLException('Expecting to find user provider name from ' . $providerConfigKey); |
| 136 | + } |
132 | 137 |
|
133 | 138 | $container->findDefinition(LoginController::class)->setArgument(0, new Reference($provider)); |
134 | 139 |
|
@@ -157,7 +162,7 @@ public function process(ContainerBuilder $container): void |
157 | 162 | // ServerConfig rules |
158 | 163 | $serverConfigDefinition = $container->findDefinition(ServerConfig::class); |
159 | 164 | $rulesDefinition = []; |
160 | | - if ($container->getParameter('graphqlite.security.introspection') === false) { |
| 165 | + if ($container->getParameter('graphqlite.security.disableIntrospection')) { |
161 | 166 | $rulesDefinition[] = $container->findDefinition(DisableIntrospection::class); |
162 | 167 | } |
163 | 168 |
|
@@ -191,6 +196,9 @@ public function process(ContainerBuilder $container): void |
191 | 196 | // Let's register the mapping with UserInterface if UserInterface is available. |
192 | 197 | if (interface_exists(UserInterface::class)) { |
193 | 198 | $staticTypes = $container->getDefinition(StaticClassListTypeMapperFactory::class)->getArgument(0); |
| 199 | + if (!is_array($staticTypes)){ |
| 200 | + throw new GraphQLException(sprintf('Expecting array in %s, arg #1', StaticClassListTypeMapperFactory::class)); |
| 201 | + } |
194 | 202 | $staticTypes[] = SymfonyUserInterfaceType::class; |
195 | 203 | $container->getDefinition(StaticClassListTypeMapperFactory::class)->setArgument(0, $staticTypes); |
196 | 204 | } |
@@ -294,6 +302,9 @@ private function registerController(string $controllerClassName, ContainerBuilde |
294 | 302 | { |
295 | 303 | $aggregateQueryProvider = $container->findDefinition(AggregateControllerQueryProviderFactory::class); |
296 | 304 | $controllersList = $aggregateQueryProvider->getArgument(0); |
| 305 | + if (!is_array($controllersList)){ |
| 306 | + throw new GraphQLException(sprintf('Expecting array in %s, arg #1', AggregateControllerQueryProviderFactory::class)); |
| 307 | + } |
297 | 308 | $controllersList[] = $controllerClassName; |
298 | 309 | $aggregateQueryProvider->setArgument(0, $controllersList); |
299 | 310 | } |
@@ -336,7 +347,14 @@ private function makePublicInjectedServices(ReflectionClass $refClass, Annotatio |
336 | 347 | return $services; |
337 | 348 | }); |
338 | 349 |
|
| 350 | + if (!is_array($services)){ |
| 351 | + throw new GraphQLException('An error occurred in compiler pass'); |
| 352 | + } |
| 353 | + |
339 | 354 | foreach ($services as $service) { |
| 355 | + if (!is_string($service)){ |
| 356 | + throw new GraphQLException('expecting string as service'); |
| 357 | + } |
340 | 358 | if ($container->hasAlias($service)) { |
341 | 359 | $container->getAlias($service)->setPublic(true); |
342 | 360 | } else { |
|
0 commit comments