Issues (101)

Security Analysis    not enabled

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/Commands/InstallCommand.php (8 issues)

Severity

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 Consigliere\Components\Commands;
4
5
use Illuminate\Console\Command as ComponentCommand;
6
use Consigliere\Components\Json;
7
use Consigliere\Components\Process\Installer;
8
use Symfony\Component\Console\Input\InputArgument;
9
use Symfony\Component\Console\Input\InputOption;
10
11
class InstallCommand extends ComponentCommand
12
{
13
    /**
14
     * The console command name.
15
     *
16
     * @var string
17
     */
18
    protected $name = 'component:install';
19
20
    /**
21
     * The console command description.
22
     *
23
     * @var string
24
     */
25
    protected $description = 'Install the specified component by given package name (vendor/name).';
26
27
    /**
28
     * Create a new command instance.
29
     */
30
    public function __construct()
31
    {
32
        parent::__construct();
33
    }
34
35
    /**
36
     * Execute the console command.
37
     *
38
     * @return mixed
39
     */
40
    public function fire()
41
    {
42
        if (is_null($this->argument('name'))) {
43
            $this->installFromFile();
44
45
            return;
46
        }
47
48
        $this->install(
49
            $this->argument('name'),
0 ignored issues
show
It seems like $this->argument('name') targeting Illuminate\Console\Command::argument() can also be of type array; however, Consigliere\Components\C...stallCommand::install() does only seem to accept string, 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...
50
            $this->argument('version'),
0 ignored issues
show
It seems like $this->argument('version') targeting Illuminate\Console\Command::argument() can also be of type array; however, Consigliere\Components\C...stallCommand::install() does only seem to accept string, 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...
51
            $this->option('type'),
0 ignored issues
show
It seems like $this->option('type') targeting Illuminate\Console\Command::option() can also be of type array; however, Consigliere\Components\C...stallCommand::install() does only seem to accept string, 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...
52
            $this->option('tree')
0 ignored issues
show
$this->option('tree') is of type string|array, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
53
        );
54
    }
55
56
    /**
57
     * Install components from components.json file.
58
     */
59
    protected function installFromFile()
60
    {
61
        if (!file_exists($path = base_path('components.json'))) {
62
            $this->error("File 'components.json' does not exist in your project root.");
63
64
            return;
65
        }
66
67
        $components = Json::make($path);
68
69
        $dependencies = $components->get('require', []);
70
71
        foreach ($dependencies as $component) {
72
            $component = collect($component);
73
74
            $this->install(
75
                $component->get('name'),
76
                $component->get('version'),
77
                $component->get('type')
78
            );
79
        }
80
    }
81
82
    /**
83
     * Install the specified component.
84
     *
85
     * @param string $name
86
     * @param string $version
87
     * @param string $type
88
     * @param bool $tree
89
     */
90
    protected function install($name, $version = 'dev-master', $type = 'composer', $tree = false)
91
    {
92
        $installer = new Installer(
93
            $name,
94
            $version,
95
            $type ?: $this->option('type'),
0 ignored issues
show
It seems like $type ?: $this->option('type') can also be of type array; however, Consigliere\Components\P...nstaller::__construct() does only seem to accept string|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
96
            $tree ?: $this->option('tree')
97
        );
98
99
        $installer->setRepository($this->laravel['components']);
100
101
        $installer->setConsole($this);
0 ignored issues
show
$this is of type this<Consigliere\Compone...ommands\InstallCommand>, but the function expects a object<Consigliere\Components\Process\Command>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
102
103
        if ($timeout = $this->option('timeout')) {
104
            $installer->setTimeout($timeout);
0 ignored issues
show
$timeout is of type string|array, but the function expects a integer.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
105
        }
106
107
        if ($path = $this->option('path')) {
108
            $installer->setPath($path);
0 ignored issues
show
It seems like $path defined by $this->option('path') on line 107 can also be of type array; however, Consigliere\Components\P...ss\Installer::setPath() does only seem to accept string, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
109
        }
110
111
        $installer->run();
112
113
        if (!$this->option('no-update')) {
114
            $this->call('component:update', [
115
                'component' => $installer->getComponentName(),
116
            ]);
117
        }
118
    }
119
120
    /**
121
     * Get the console command arguments.
122
     *
123
     * @return array
124
     */
125
    protected function getArguments()
126
    {
127
        return [
128
            ['name', InputArgument::OPTIONAL, 'The name of component will be installed.'],
129
            ['version', InputArgument::OPTIONAL, 'The version of component will be installed.'],
130
        ];
131
    }
132
133
    /**
134
     * Get the console command options.
135
     *
136
     * @return array
137
     */
138
    protected function getOptions()
139
    {
140
        return [
141
            ['timeout', null, InputOption::VALUE_OPTIONAL, 'The process timeout.', null],
142
            ['path', null, InputOption::VALUE_OPTIONAL, 'The installation path.', null],
143
            ['type', null, InputOption::VALUE_OPTIONAL, 'The type of installation.', null],
144
            ['tree', null, InputOption::VALUE_NONE, 'Install the component as a git subtree', null],
145
            ['no-update', null, InputOption::VALUE_NONE, 'Disables the automatic update of the dependencies.', null],
146
        ];
147
    }
148
}
149