Conditions | 3 |
Paths | 4 |
Total Lines | 21 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php /** MicroConsole */ |
||
48 | public function action($name) |
||
49 | { |
||
50 | $command = '\\App\\Consoles\\'.ucfirst($name).'ConsoleCommand'; |
||
51 | $command = class_exists($command) ? $command : '\\Micro\\Cli\\Consoles\\'.ucfirst($name).'ConsoleCommand'; |
||
52 | |||
53 | if (!class_exists($command)) { |
||
54 | throw new Exception('Command `'.$name.'` not found'); |
||
55 | } |
||
56 | |||
57 | /** @var ConsoleCommand $command */ |
||
58 | $command = new $command(); |
||
|
|||
59 | $command->execute(); |
||
60 | |||
61 | $response = (new ResponseInjector)->build(); |
||
62 | $response = $response->withHeader('status', (string)(int)$command->result); |
||
63 | |||
64 | $stream = $response->getBody(); |
||
65 | $stream->write($command->message); |
||
66 | |||
67 | return $response->withBody($stream); |
||
68 | } |
||
69 | } |
||
70 |
$command
can contain request data and is used in code execution context(s) leading to a potential security vulnerability.1 path for user data to reach this point
$_GET,
and$query ?: $_GET
is passed to ServerRequest::__construct()in vendor/src/ServerRequestFactory.php on line 71
in vendor/src/ServerRequest.php on line 101
in vendor/src/ServerRequest.php on line 156
$rawQuery
is assignedin src/mvc/MvcResolver.php on line 53
$query
is assignedin src/mvc/MvcResolver.php on line 55
$query
is assignedin src/mvc/MvcResolver.php on line 56
in src/mvc/MvcResolver.php on line 58
$this->uri
is passed through substr(), andsubstr($this->uri, 0, $key ?: strlen($this->uri))
is passed through explode(), and$uriBlocks
is assignedin src/mvc/MvcResolver.php on line 84
$uriBlocks
is passed to MvcResolver::prepareAction()in src/mvc/MvcResolver.php on line 93
$uriBlocks
is passed through array_shift(), and MvcResolver::$action is assignedin src/mvc/MvcResolver.php on line 202
in src/mvc/MvcResolver.php on line 264
$action
is assignedin src/base/Application.php on line 88
(string) $action
is passed to Console::action()in src/base/Application.php on line 97
$name
is passed through ucfirst(), and$command
is assignedin src/cli/Console.php on line 51
General Strategies to prevent injection
In general, it is advisable to prevent any user-data to reach this point. This can be done by white-listing certain values:
For numeric data, we recommend to explicitly cast the data: