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 Acacha\Llum\Console; |
||
4 | |||
5 | use Acacha\Llum\Github\GithubAPI; |
||
6 | use Acacha\Llum\Parser\LlumRCParser; |
||
7 | use GuzzleHttp\Exception\ClientException; |
||
8 | use GuzzleHttp\Exception\ServerException; |
||
9 | use Symfony\Component\Console\Input\InputArgument; |
||
10 | use Symfony\Component\Console\Input\InputInterface; |
||
11 | use Symfony\Component\Console\Output\OutputInterface; |
||
12 | |||
13 | /** |
||
14 | * Class GithubRepoCommand. |
||
15 | * |
||
16 | * @package Acacha\Llum\Console |
||
17 | */ |
||
18 | class GithubRepoCommand extends LlumCommand |
||
19 | { |
||
20 | |||
21 | use GithubCommand; |
||
22 | |||
23 | /** |
||
24 | * Github api service class. |
||
25 | * |
||
26 | * @var GithubAPI |
||
27 | */ |
||
28 | protected $api; |
||
29 | |||
30 | /** |
||
31 | * Llum rc file parser. |
||
32 | * |
||
33 | * @var LlumRCParser |
||
34 | */ |
||
35 | protected $parser; |
||
36 | |||
37 | /** |
||
38 | * Command name. |
||
39 | * |
||
40 | * @var string |
||
41 | */ |
||
42 | protected $commandName = 'github:repo'; |
||
43 | |||
44 | /** |
||
45 | * Command description. |
||
46 | * |
||
47 | * @var string |
||
48 | */ |
||
49 | protected $commandDescription = 'Creates a github repo'; |
||
50 | |||
51 | /** |
||
52 | * Method to execute. |
||
53 | * |
||
54 | * @var string |
||
55 | */ |
||
56 | protected $method = 'githubCreateRepo'; |
||
57 | |||
58 | /** |
||
59 | * GithubRepoCommand constructor. |
||
60 | * @param GithubAPI $api |
||
61 | * @param LlumRCParser $parser |
||
62 | */ |
||
63 | public function __construct(GithubAPI $api, LlumRCParser $parser) |
||
64 | { |
||
65 | parent::__construct(); |
||
66 | $this->api = $api; |
||
67 | $this->parser = $parser; |
||
68 | } |
||
69 | |||
70 | |||
71 | /** |
||
72 | * Github create repo command. |
||
73 | * |
||
74 | * @param InputInterface $input |
||
75 | * @param OutputInterface $output |
||
76 | */ |
||
77 | public function githubCreateRepo(InputInterface $input, OutputInterface $output) |
||
78 | { |
||
79 | $this->api->setCredentials($this->getCredentials($output)); |
||
0 ignored issues
–
show
|
|||
80 | $name = $this->repoName($input); |
||
81 | try { |
||
82 | $this->api->createRepo($name,$this->repoDescription($input)); |
||
83 | } catch (ServerException $se) { |
||
84 | //TODO |
||
85 | $output->writeln('<error>Server exception thrown</error>'); |
||
86 | die(); |
||
0 ignored issues
–
show
The method
githubCreateRepo() contains an exit expression.
An exit expression should only be used in rare cases. For example, if you write a short command line script. In most cases however, using an ![]() |
|||
87 | } catch (ClientException $ce) { |
||
88 | $this->showError( $ce , $output ); |
||
89 | } |
||
90 | $output->writeln('<info>Repository ' . $name . ' created</info>'); |
||
91 | } |
||
92 | |||
93 | |||
94 | |||
95 | /** |
||
96 | * Show error. |
||
97 | * @param ClientException $ce |
||
98 | * @param OutputInterface $output |
||
99 | */ |
||
100 | protected function showError(ClientException $ce, OutputInterface $output) |
||
101 | { |
||
102 | if ($ce->getResponse()->getStatusCode() == 422) { |
||
103 | $output->writeln('<error>Repository already exists</error>'); |
||
104 | die(); |
||
0 ignored issues
–
show
The method
showError() contains an exit expression.
An exit expression should only be used in rare cases. For example, if you write a short command line script. In most cases however, using an ![]() |
|||
105 | } |
||
106 | $output->writeln('<error>Client Request exception thrown</error>'); |
||
107 | die(); |
||
0 ignored issues
–
show
The method
showError() contains an exit expression.
An exit expression should only be used in rare cases. For example, if you write a short command line script. In most cases however, using an ![]() |
|||
108 | } |
||
109 | |||
110 | |||
111 | /** |
||
112 | * Get credentials. |
||
113 | * |
||
114 | * @param OutputInterface $input |
||
0 ignored issues
–
show
There is no parameter named
$input . Was it maybe removed?
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. Consider the following example. The parameter /**
* @param array $germany
* @param array $island
* @param array $italy
*/
function finale($germany, $island) {
return "2:1";
}
The most likely cause is that the parameter was removed, but the annotation was not. ![]() |
|||
115 | * @return array |
||
116 | */ |
||
117 | View Code Duplication | public function getCredentials(OutputInterface $output) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
118 | { |
||
119 | $credentials = $this->parser->getCredentials(); |
||
120 | if ( is_null($credentials)) { |
||
121 | $this->showErrorRunLlumInitFirst($output,"Credentials"); |
||
122 | }; |
||
123 | return $credentials; |
||
124 | } |
||
125 | |||
126 | /** |
||
127 | * Obtain repo name. |
||
128 | * |
||
129 | * @param InputInterface $input |
||
130 | * @return mixed|string |
||
131 | */ |
||
132 | protected function repoName(InputInterface $input) { |
||
133 | $name = $input->getArgument('name'); |
||
134 | return isset($name) ? $name : basename(getcwd()); |
||
135 | } |
||
136 | |||
137 | /** |
||
138 | * Obtain repo description. |
||
139 | * |
||
140 | * @param InputInterface $input |
||
141 | * @return mixed|string |
||
142 | */ |
||
143 | protected function repoDescription(InputInterface $input) { |
||
144 | $description = $input->getArgument('description'); |
||
145 | return isset($description) ? $description : ""; |
||
146 | } |
||
147 | |||
148 | /** |
||
149 | * Configure command. |
||
150 | */ |
||
151 | public function configure() |
||
152 | { |
||
153 | parent::configure(); |
||
154 | |||
155 | $this |
||
156 | // configure an argument |
||
157 | ->addArgument('name', InputArgument::OPTIONAL, 'Repository name') |
||
158 | ->addArgument('description', InputArgument::OPTIONAL, 'Repository description') |
||
159 | ; |
||
160 | } |
||
161 | |||
162 | } |
This check looks at variables that are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.