Issues (20)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/Console/GithubRepoCommand.php (6 issues)

Upgrade to new PHP Analysis Engine

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
It seems like $this->getCredentials($output) targeting Acacha\Llum\Console\Gith...mmand::getCredentials() can also be of type null; however, Acacha\Llum\Github\GithubAPI::setCredentials() does only seem to accept array, maybe add an additional type check?

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.

Loading history...
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
Coding Style Compatibility introduced by
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 exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
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
Coding Style Compatibility introduced by
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 exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
105
        }
106
        $output->writeln('<error>Client Request exception thrown</error>');
107
        die();
0 ignored issues
show
Coding Style Compatibility introduced by
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 exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
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 $italy is not defined by the method finale(...).

/**
 * @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.

Loading history...
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.

Loading history...
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
}