GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (120)

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/Task/ShellTask.php (3 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
 * See class comment
4
 *
5
 * PHP Version 5
6
 *
7
 * @category   Netresearch
8
 * @package    Netresearch\Kite
9
 * @subpackage Task
10
 * @author     Christian Opitz <[email protected]>
11
 * @license    http://www.netresearch.de Netresearch Copyright
12
 * @link       http://www.netresearch.de
13
 */
14
15
namespace Netresearch\Kite\Task;
16
use Netresearch\Kite\Exception;
17
18
/**
19
 * Executes a command locally and returns the output
20
 *
21
 * @category   Netresearch
22
 * @package    Netresearch\Kite
23
 * @subpackage Task
24
 * @author     Christian Opitz <[email protected]>
25
 * @license    http://www.netresearch.de Netresearch Copyright
26
 * @link       http://www.netresearch.de
27
 */
28
class ShellTask extends \Netresearch\Kite\Task
29
{
30
    /**
31
     * Configure the options
32
     *
33
     * @return array
34
     */
35
    protected function configureVariables()
36
    {
37
        return array(
0 ignored issues
show
The expression return array('command' =...::configureVariables(); seems to be an array, but some of its elements' types (string) are incompatible with the return type of the parent method Netresearch\Kite\Task::configureVariables of type array<string,array>.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
38
            'command' => array(
39
                'type' => 'string|array',
40
                'label' => 'Command(s) to execute',
41
                'required' => true,
42
            ),
43
            'cwd' => array(
44
                'type' => 'string',
45
                'label' => 'The directory to change to before running the command'
46
            ),
47
            'argv' => array(
48
                'type' => 'array|string',
49
                'label' => 'String with all options and arguments for the command or an array in the same format as $argv. '
50
                    . 'Attention: Values won\'t be escaped!'
51
            ),
52
            'options' => array(
53
                'type' => 'array',
54
                'default' => array(),
55
                'label' => 'Array with options: Elements with numeric keys or bool true values will be --switches.'
56
            ),
57
            'arguments' => array(
58
                'type' => 'array',
59
                'default' => array(),
60
                'label' => 'Arguments to pass to the cmd'
61
            ),
62
            'optArg' => array(
63
                'type' => 'array|string',
64
                'label' => 'Arguments and options in one array. '
65
                    . 'When array, elements with numeric keys will be added as {@see arguments} and elements with string keys will be added as {@see options}. '
66
                    . 'When string, {@see argv} will be set to this value'
67
            ),
68
            'errorMessage' => array(
69
                'type' => 'string',
70
                'label' => 'Message to display when the command failed'
71
            ),
72
            'processSettings' => array(
73
                'type' => 'array',
74
                'default' => array(),
75
                'label' => 'Settings for symfony process class'
76
            ),
77
            '--',
78
        ) + parent::configureVariables();
79
    }
80
81
    /**
82
     * Handle arguments, options and optArg
83
     *
84
     * @param string $option Option name
85
     * @param mixed  $value  Option value
86
     *
87
     * @return void
88
     */
89
    public function offsetSet($option, $value)
90
    {
91
        if ($option === 'processSettings') {
92
            $value = array_merge($this->offsetGet('processSettings'), $value);
93
        }
94
        if (in_array($option, array('arguments', 'options', 'optArg'), true)) {
95
            if ($value === null) {
96
                if ($option === 'optArg' || $option === 'options') {
97
                    parent::offsetSet('options', array());
98
                }
99
                if ($option === 'optArg' || $option === 'arguments') {
100
                    parent::offsetSet('arguments', array());
101
                }
102
                return;
103
            }
104
            if ($option === 'optArg' && is_string($value)) {
105
                parent::offsetSet('argv', $value);
106
                return;
107
            }
108
            $arguments = $this->get('arguments');
109
            $options = $this->get('options');
110
            if ($option == 'arguments') {
111
                $arguments = array_merge($arguments, $value);
112
            } elseif ($option == 'options') {
113 View Code Duplication
                foreach ($value as $k => $v) {
0 ignored issues
show
This code seems to be duplicated across 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...
114
                    if (is_numeric($k)) {
115
                        $options[$v] = true;
116
                    } else {
117
                        $options[$k] = $v;
118
                    }
119
                }
120
            } elseif ($option == 'optArg') {
121 View Code Duplication
                foreach ($value as $k => $v) {
0 ignored issues
show
This code seems to be duplicated across 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...
122
                    if (is_numeric($k)) {
123
                        $arguments[] = $v;
124
                    } else {
125
                        $options[$k] = $v;
126
                    }
127
                }
128
            }
129
            parent::offsetSet('arguments', $arguments);
130
            parent::offsetSet('options', $options);
131
            return;
132
        }
133
        parent::offsetSet($option, $value);
134
    }
135
136
    /**
137
     * Execute the command
138
     *
139
     * @return mixed
140
     */
141
    protected function executeCommand()
142
    {
143
        $process = $this->console->createProcess($this->getCommand(), $this->get('cwd'));
144
        $process->setDryRun(!$this->shouldExecute());
145
        foreach ($this->get('processSettings') as $key => $value) {
146
            $process->{'set' . ucfirst($key)}($value);
147
        }
148
        return $process->run();
149
    }
150
151
    /**
152
     * Get the command with options and arguments
153
     *
154
     * @return string
155
     */
156
    protected function getCommand()
157
    {
158
        $cmd = $this->get('command');
159
        $argv = $this->get('argv');
160
        $options = $this->get('options');
161
        $arguments = $this->get('arguments');
162
        if (is_array($cmd)) {
163
            if ($argv || $options || $arguments) {
164
                throw new Exception('Can not use argv, options or arguments on multiple commands');
165
            }
166
            $cmd = $this->expand(implode('; ', $cmd));
167
        } else {
168
            if ($argv) {
169
                if ($options || $arguments) {
170
                    throw new Exception('Can not combine argv with options or arguments');
171
                }
172
                $cmd .= ' ' . (is_array($argv) ? implode(' ', $argv) : $argv);
173
            } else {
174
                $cmd .= $this->renderOptions($options);
175
                $cmd .= $this->renderArguments($arguments);
176
            }
177
        }
178
179
        return $cmd;
180
    }
181
182
    /**
183
     * Render options as options for the command
184
     *
185
     * @param array $options The options
186
     *
187
     * @return string
188
     */
189
    protected function renderOptions(array $options)
190
    {
191
        $optionString = '';
192
        foreach ($options as $option => $value) {
193
            $value = $this->expand($value);
194
            if ($value === false) {
195
                continue;
196
            }
197
            $l = strlen($option);
198
            $optionString .= ' ';
199
            if ($option[0] !== '-') {
200
                $optionString .= ($l === 1) ? '-' : '--';
201
            }
202
            $optionString .= $option;
203
            if ($value !== true) {
204
                if ($l > 1 && ($option[0] !== '-' || $option[1] === '-')) {
205
                    $optionString .= '=';
206
                } else {
207
                    $optionString .= ' ';
208
                }
209
                $optionString .= escapeshellarg($value);
210
            }
211
        }
212
        return $optionString;
213
    }
214
215
    /**
216
     * Render arguments for the command
217
     *
218
     * @param array $arguments The arguments
219
     *
220
     * @return string
221
     */
222
    protected function renderArguments(array $arguments)
223
    {
224
        $argumentString = '';
225
        foreach ($arguments as $argument) {
226
            $value = $this->expand($argument);
227
            $argumentString .= ' ' . escapeshellarg($value);
228
        }
229
        return $argumentString;
230
    }
231
232
    /**
233
     * Run the command
234
     *
235
     * @return string
236
     */
237
    public function run()
238
    {
239
        $this->preview();
240
        $res = $this->execute();
241
        return $res;
242
    }
243
244
    /**
245
     * Execute the command
246
     *
247
     * @return string
248
     */
249
    public function execute()
250
    {
251
        return $this->executeCommand();
252
    }
253
}
254
?>
255