This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Geekish\Slimbox; |
||
4 | |||
5 | use mindplay\unbox\ContainerFactory as UnboxFactory; |
||
6 | use mindplay\unbox\ProviderInterface; |
||
7 | use Interop\Container\ContainerInterface; |
||
8 | use Psr\Http\Message\ResponseInterface; |
||
9 | use Psr\Http\Message\ServerRequestInterface; |
||
10 | use Slim\CallableResolver; |
||
11 | use Slim\Handlers\PhpError; |
||
12 | use Slim\Handlers\Error; |
||
13 | use Slim\Handlers\NotFound; |
||
14 | use Slim\Handlers\NotAllowed; |
||
15 | use Slim\Handlers\Strategies\RequestResponse; |
||
16 | use Slim\Http\Environment; |
||
17 | use Slim\Http\Headers; |
||
18 | use Slim\Http\Request; |
||
19 | use Slim\Http\Response; |
||
20 | use Slim\Interfaces\CallableResolverInterface; |
||
21 | use Slim\Interfaces\Http\EnvironmentInterface; |
||
22 | use Slim\Interfaces\InvocationStrategyInterface; |
||
23 | use Slim\Interfaces\RouterInterface; |
||
24 | use Slim\Router; |
||
25 | |||
26 | /** |
||
27 | * Slim's default Service Provider. |
||
28 | */ |
||
29 | class DefaultServicesProvider implements ProviderInterface |
||
30 | { |
||
31 | /** |
||
32 | * @var array |
||
33 | */ |
||
34 | protected $settings = []; |
||
35 | |||
36 | /** |
||
37 | * @param array $settings |
||
38 | */ |
||
39 | public function __construct(array $settings = []) |
||
40 | { |
||
41 | $this->settings = $settings; |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * Register Slim's default services. |
||
46 | * |
||
47 | * @param UnboxFactory $factory |
||
48 | */ |
||
49 | public function register(UnboxFactory $factory) |
||
0 ignored issues
–
show
|
|||
50 | { |
||
51 | $factory->set( |
||
52 | Settings::class, |
||
53 | new Settings($this->settings) |
||
54 | ); |
||
55 | |||
56 | $factory->alias( |
||
57 | "settings", |
||
58 | Settings::class |
||
59 | ); |
||
60 | |||
61 | $factory->register( |
||
62 | Environment::class, |
||
63 | function () { |
||
64 | return new Environment($_SERVER); |
||
65 | } |
||
66 | ); |
||
67 | |||
68 | $factory->alias( |
||
69 | EnvironmentInterface::class, |
||
70 | Environment::class |
||
71 | ); |
||
72 | |||
73 | $factory->alias( |
||
74 | "environment", |
||
75 | Environment::class |
||
76 | ); |
||
77 | |||
78 | $factory->register( |
||
79 | Request::class, |
||
80 | function (Environment $environment) { |
||
81 | return Request::createFromEnvironment($environment); |
||
82 | } |
||
83 | ); |
||
84 | |||
85 | $factory->alias( |
||
86 | ServerRequestInterface::class, |
||
87 | Request::class |
||
88 | ); |
||
89 | |||
90 | $factory->alias( |
||
91 | "request", |
||
92 | Request::class |
||
93 | ); |
||
94 | |||
95 | $factory->register( |
||
96 | Response::class, |
||
97 | function (Settings $settings) { |
||
98 | $headers = new Headers(['Content-Type' => 'text/html; charset=UTF-8']); |
||
99 | $response = new Response(200, $headers); |
||
100 | |||
101 | return $response->withProtocolVersion($settings['httpVersion']); |
||
102 | } |
||
103 | ); |
||
104 | |||
105 | $factory->alias( |
||
106 | ResponseInterface::class, |
||
107 | Response::class |
||
108 | ); |
||
109 | |||
110 | $factory->alias( |
||
111 | "response", |
||
112 | Response::class |
||
113 | ); |
||
114 | |||
115 | $factory->register( |
||
116 | Router::class, |
||
117 | function (Settings $settings) { |
||
118 | $routerCacheFile = false; |
||
119 | if ($settings->has('routerCacheFile') && file_exists($settings['routerCacheFile'])) { |
||
120 | $routerCacheFile = $settings['routerCacheFile']; |
||
121 | } |
||
122 | return (new Router)->setCacheFile($routerCacheFile); |
||
123 | } |
||
124 | ); |
||
125 | |||
126 | $factory->alias( |
||
127 | RouterInterface::class, |
||
128 | Router::class |
||
129 | ); |
||
130 | |||
131 | $factory->alias( |
||
132 | "router", |
||
133 | Router::class |
||
134 | ); |
||
135 | |||
136 | $factory->register( |
||
137 | RequestResponse::class |
||
138 | ); |
||
139 | |||
140 | $factory->alias( |
||
141 | InvocationStrategyInterface::class, |
||
142 | RequestResponse::class |
||
143 | ); |
||
144 | |||
145 | $factory->alias( |
||
146 | "foundHandler", |
||
147 | RequestResponse::class |
||
148 | ); |
||
149 | |||
150 | $factory->register( |
||
151 | PhpError::class, |
||
152 | function (Settings $settings) { |
||
153 | return new PhpError($settings['displayErrorDetails']); |
||
154 | } |
||
155 | ); |
||
156 | |||
157 | $factory->alias( |
||
158 | "phpErrorHandler", |
||
159 | PhpError::class |
||
160 | ); |
||
161 | |||
162 | $factory->register( |
||
163 | Error::class, |
||
164 | function (Settings $settings) { |
||
165 | return new Error($settings['displayErrorDetails']); |
||
166 | } |
||
167 | ); |
||
168 | |||
169 | $factory->alias( |
||
170 | "errorHandler", |
||
171 | Error::class |
||
172 | ); |
||
173 | |||
174 | $factory->register( |
||
175 | NotFound::class |
||
176 | ); |
||
177 | |||
178 | $factory->alias( |
||
179 | "notFoundHandler", |
||
180 | NotFound::class |
||
181 | ); |
||
182 | |||
183 | $factory->register( |
||
184 | NotAllowed::class |
||
185 | ); |
||
186 | |||
187 | $factory->alias( |
||
188 | "notAllowedHandler", |
||
189 | NotAllowed::class |
||
190 | ); |
||
191 | |||
192 | $factory->register( |
||
193 | CallableResolver::class, |
||
194 | function (ContainerInterface $container) { |
||
195 | return new CallableResolver($container); |
||
196 | } |
||
197 | ); |
||
198 | |||
199 | $factory->alias( |
||
200 | CallableResolverInterface::class, |
||
201 | CallableResolver::class |
||
202 | ); |
||
203 | |||
204 | $factory->alias( |
||
205 | "callableResolver", |
||
206 | CallableResolver::class |
||
207 | ); |
||
208 | } |
||
209 | } |
||
210 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: