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/GithubInitCommand.php (1 issue)

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\Parser\LlumRCParser;
6
use Symfony\Component\Console\Input\InputArgument;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
10
/**
11
 * Class GithubInitCommand.
12
 *
13
 * @package Acacha\Llum\Console
14
 */
15
class GithubInitCommand extends LlumCommand
16
{
17
18
    use GithubCommand;
19
20
    /**
21
     * Symfony console output.
22
     *
23
     * @var OutputInterface
24
     */
25
    protected $output;
26
27
    /**
28
     * Llum rc file parser.
29
     *
30
     * @var LlumRCParser
31
     */
32
    protected $parser;
33
34
    /**
35
     * Command name.
36
     *
37
     * @var string
38
     */
39
    protected $commandName = 'github:init';
40
41
    /**
42
     * Command description.
43
     *
44
     * @var string
45
     */
46
    protected $commandDescription = 'Initializes current folder as a new git project';
47
48
    /**
49
     * Method to execute.
50
     *
51
     * @var string
52
     */
53
    protected $method = 'gitHubInitRepo';
54
55
    /**
56
     * GithubInitCommand constructor.
57
     *
58
     * @param LlumRCParser $parser
59
     */
60
    public function __construct(LlumRCParser $parser)
61
    {
62
        parent::__construct();
63
        $this->parser = $parser;
64
    }
65
66
    /**
67
     * Github init repo command.
68
     *
69
     * @param InputInterface $input
70
     * @param OutputInterface $output
71
     */
72
    public function gitHubInitRepo(InputInterface $input, OutputInterface $output)
73
    {
74
        $this->output = $output;
75
        $this->runGitInit();
76
        $this->runGitAdd();
77
        $this->runGitCommit();
78
        $this->runGitCreateRepo();
79
        $this->runGitRemoteAddOrigin($this->getRepoURL($input,$output));
80
        $this->runGitPull();
81
        $this->runGitPush();
82
    }
83
84
85
    /**
86
     * Get github repo URL.
87
     *
88
     * @param OutputInterface $output
89
     * @param InputInterface $input
90
     * @return string
91
     */
92
    public function getRepoURL(InputInterface $input, OutputInterface $output)
93
    {
94
        return '[email protected]:' . $this->gitHubUsername($input,$output) . '/' . $this->repoName($input) . '.git';
95
    }
96
97
    /**
98
     * Obtain repo name.
99
     *
100
     * @param InputInterface $input
101
     * @return mixed|string
102
     */
103
    protected function repoName(InputInterface $input) {
104
        $name = $input->getArgument('name');
105
        return isset($name) ? $name : basename(getcwd());
106
    }
107
108
109
    /**
110
     * Get github username.
111
     *
112
     * @param InputInterface $input
113
     * @param OutputInterface $output
114
     * @return array|mixed
115
     */
116
    protected function gitHubUsername(InputInterface $input, OutputInterface $output)
117
    {
118
        $username = $input->getArgument('github_username');
119
        return isset($username) ? $username : $this->getGithubUserNameFromConfig($output);
120
    }
121
122
    /**
123
     * Get github username from llum config.
124
     *
125
     * @param OutputInterface $output
126
     * @return array
127
     */
128 View Code Duplication
    protected function getGithubUserNameFromConfig(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...
129
    {
130
        $username = $this->parser->getGitHubUsername();
131
        if (is_null($username)) {
132
            $this->showErrorRunLlumInitFirst($output,'username');
133
        }
134
        return $username;
135
    }
136
137
    /**
138
     * Run git init command.
139
     */
140
    protected function runGitInit(){
141
        $this->showMessageRunningCommand($this->output,'git init');
142
        passthru('git init');
143
    }
144
145
    /**
146
     * Run git add command.
147
     */
148
    protected function runGitAdd(){
149
        $this->showMessageRunningCommand($this->output,'git add .');
150
        passthru('git add .');
151
    }
152
153
    /**
154
     * Run git commit command.
155
     */
156
    protected function runGitCommit(){
157
        $this->showMessageRunningCommand($this->output,'git commit -a -m "Initial version"');
158
        passthru('git commit -a -m "Initial version"');
159
    }
160
161
    /**
162
     * Run llum github:repo command.
163
     */
164
    protected function runGitCreateRepo()
165
    {
166
        $this->showMessageRunningCommand($this->output,'llum github:repo');
167
        passthru('llum github:repo');
168
    }
169
170
    /**
171
     * Run git remote add origin.
172
     *
173
     * @param $url
174
     */
175
    protected function runGitRemoteAddOrigin($url){
176
        $this->showMessageRunningCommand($this->output,'git remote add origin ' . $url);
177
        passthru('git remote add origin ' . $url);
178
    }
179
180
    /**
181
     * Run git pull.
182
     */
183
    protected function runGitPull(){
184
        $this->showMessageRunningCommand($this->output,'git pull origin master');
185
        passthru('git pull origin master');
186
    }
187
188
    /**
189
     * Run git push.
190
     */
191
    protected function runGitPush(){
192
        $this->showMessageRunningCommand($this->output,'git push origin master');
193
        passthru('git push origin master');
194
    }
195
196
    /**
197
     * Configure command.
198
     */
199
    public function configure()
200
    {
201
        parent::configure();
202
203
        $this
204
            // configure an argument
205
            ->addArgument('name', InputArgument::OPTIONAL, 'Repository name')
206
            ->addArgument('github_username', InputArgument::OPTIONAL, 'Github username')
207
        ;
208
    }
209
}