Issues (98)

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.

code/Core/Support/Parser.php (8 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
use Symfony\Component\Console\Input\InputArgument;
4
use Symfony\Component\Console\Input\InputOption;
5
6
/**
7
 * Class Parser.
8
 *
9
 * Shameless copy/paste from Taylor Otwell's Laravel
10
 */
11
class CommandParser
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
12
{
13
    /**
14
     * Parse the given console command definition into an array.
15
     *
16
     * @param string $expression
17
     *
18
     * @throws \InvalidArgumentException
19
     *
20
     * @return array
21
     */
22
    public static function parse($expression)
23
    {
24
        if (trim($expression) === '') {
25
            throw new InvalidArgumentException('Console command definition is empty.');
26
        }
27
28
        preg_match('/[^\s]+/', $expression, $matches);
29
30
        if (isset($matches[0])) {
31
            $name = $matches[0];
32
        } else {
33
            throw new InvalidArgumentException('Unable to determine command name from signature.');
34
        }
35
36
        preg_match_all('/\{\s*(.*?)\s*\}/', $expression, $matches);
37
38
        $tokens = isset($matches[1]) ? $matches[1] : [];
39
40
        if (count($tokens)) {
41
            return array_merge([$name], static::parameters($tokens));
42
        }
43
44
        return [$name, [], []];
45
    }
46
47
    /**
48
     * Extract all of the parameters from the tokens.
49
     *
50
     * @param array $tokens
51
     *
52
     * @return array
53
     */
54
    protected static function parameters(array $tokens)
55
    {
56
        $arguments = [];
57
58
        $options = [];
59
60
        foreach ($tokens as $token) {
61
            if (!Str::startsWith($token, '--')) {
62
                $arguments[] = static::parseArgument($token);
63
            } else {
64
                $options[] = static::parseOption(ltrim($token, '-'));
65
            }
66
        }
67
68
        return [$arguments, $options];
69
    }
70
71
    /**
72
     * Parse an argument expression.
73
     *
74
     * @param string $token
75
     *
76
     * @return \Symfony\Component\Console\Input\InputArgument
77
     */
78
    protected static function parseArgument($token)
79
    {
80
        $description = null;
81
82 View Code Duplication
        if (Str::contains($token, ' : ')) {
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...
83
            list($token, $description) = explode(' : ', $token, 2);
84
85
            $token = trim($token);
86
87
            $description = trim($description);
88
        }
89
90
        switch (true) {
0 ignored issues
show
Bug Best Practice introduced by
It seems like you are loosely comparing preg_match('/(.+)\\=(.+)/', $token, $matches) of type integer to the boolean true. If you are specifically checking for non-zero, consider using something more explicit like > 0 or !== 0 instead.
Loading history...
91
            case Str::endsWith($token, '?*'):
92
                return new InputArgument(trim($token, '?*'), InputArgument::IS_ARRAY, $description);
93
94
            case Str::endsWith($token, '*'):
95
                return new InputArgument(trim($token, '*'), InputArgument::IS_ARRAY | InputArgument::REQUIRED, $description);
96
97
            case Str::endsWith($token, '?'):
98
                return new InputArgument(trim($token, '?'), InputArgument::OPTIONAL, $description);
99
100
            case preg_match('/(.+)\=(.+)/', $token, $matches):
101
                return new InputArgument($matches[1], InputArgument::OPTIONAL, $description, $matches[2]);
0 ignored issues
show
The variable $matches seems only to be defined at a later point. Did you maybe move this code here without moving the variable definition?

This error can happen if you refactor code and forget to move the variable initialization.

Let’s take a look at a simple example:

function someFunction() {
    $x = 5;
    echo $x;
}

The above code is perfectly fine. Now imagine that we re-order the statements:

function someFunction() {
    echo $x;
    $x = 5;
}

In that case, $x would be read before it is initialized. This was a very basic example, however the principle is the same for the found issue.

Loading history...
102
103
            default:
104
                return new InputArgument($token, InputArgument::REQUIRED, $description);
105
        }
106
    }
107
108
    /**
109
     * Parse an option expression.
110
     *
111
     * @param string $token
112
     *
113
     * @return \Symfony\Component\Console\Input\InputOption
114
     */
115
    protected static function parseOption($token)
116
    {
117
        $description = null;
118
119 View Code Duplication
        if (Str::contains($token, ' : ')) {
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...
120
            list($token, $description) = explode(' : ', $token);
121
            $token = trim($token);
122
            $description = trim($description);
123
        }
124
125
        $shortcut = null;
126
127
        $matches = preg_split('/\s*\|\s*/', $token, 2);
128
129
        if (isset($matches[1])) {
130
            $shortcut = $matches[0];
131
            $token = $matches[1];
132
        }
133
134
        switch (true) {
0 ignored issues
show
Bug Best Practice introduced by
It seems like you are loosely comparing preg_match('/(.+)\\=(.+)/', $token, $matches) of type integer to the boolean true. If you are specifically checking for non-zero, consider using something more explicit like > 0 or !== 0 instead.
Loading history...
135 View Code Duplication
            case Str::endsWith($token, '='):
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...
136
                return new InputOption(trim($token, '='), $shortcut, InputOption::VALUE_OPTIONAL, $description);
137
138 View Code Duplication
            case Str::endsWith($token, '=*'):
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...
139
                return new InputOption(trim($token, '=*'), $shortcut, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, $description);
140
141
            case preg_match('/(.+)\=(.+)/', $token, $matches):
142
                return new InputOption($matches[1], $shortcut, InputOption::VALUE_OPTIONAL, $description, $matches[2]);
143
144
            default:
145
                return new InputOption($token, $shortcut, InputOption::VALUE_NONE, $description);
146
        }
147
    }
148
}
149