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/Support/Migrations/NameParser.php (3 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\Support\Migrations;
4
5
class NameParser
6
{
7
    /**
8
     * The migration name.
9
     *
10
     * @var string
11
     */
12
    protected $name;
13
14
    /**
15
     * The array data.
16
     *
17
     * @var array
18
     */
19
    protected $data = [];
20
21
    /**
22
     * The available schema actions.
23
     *
24
     * @var array
25
     */
26
    protected $actions
27
        = [
28
            'create' => [
29
                'create',
30
                'make',
31
            ],
32
            'delete' => [
33
                'delete',
34
                'remove',
35
            ],
36
            'add'    => [
37
                'add',
38
                'update',
39
                'append',
40
                'insert',
41
            ],
42
            'drop'   => [
43
                'destroy',
44
                'drop',
45
            ],
46
        ];
47
48
    /**
49
     * The constructor.
50
     *
51
     * @param string $name
52
     */
53
    public function __construct($name)
54
    {
55
        $this->name = $name;
56
        $this->data = $this->fetchData();
57
    }
58
59
    /**
60
     * Get original migration name.
61
     *
62
     * @return string
63
     */
64
    public function getOriginalName()
65
    {
66
        return $this->name;
67
    }
68
69
    /**
70
     * Get schema type or action.
71
     *
72
     * @return string
73
     */
74
    public function getAction()
75
    {
76
        return head($this->data);
77
    }
78
79
    /**
80
     * Get the table will be used.
81
     *
82
     * @return string
83
     */
84
    public function getTableName()
85
    {
86
        $matches = array_reverse($this->getMatches());
87
88
        return array_shift($matches);
89
    }
90
91
    /**
92
     * Get matches data from regex.
93
     *
94
     * @return array
95
     */
96
    public function getMatches()
97
    {
98
        preg_match($this->getPattern(), $this->name, $matches);
99
100
        return $matches;
101
    }
102
103
    /**
104
     * Get name pattern.
105
     *
106
     * @return string
107
     */
108
    public function getPattern()
109
    {
110
        switch ($action = $this->getAction()) {
111
            case 'add':
112
            case 'append':
113
            case 'update':
114
            case 'insert':
115
                return "/{$action}_(.*)_to_(.*)_table/";
116
                break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
117
118
            case 'delete':
119
            case 'remove':
120
            case 'alter':
121
                return "/{$action}_(.*)_from_(.*)_table/";
122
                break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
123
124
            default:
125
                return "/{$action}_(.*)_table/";
126
                break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
127
        }
128
    }
129
130
    /**
131
     * Fetch the migration name to an array data.
132
     *
133
     * @return array
134
     */
135
    protected function fetchData()
136
    {
137
        return explode('_', $this->name);
138
    }
139
140
    /**
141
     * Get the array data.
142
     *
143
     * @return array
144
     */
145
    public function getData()
146
    {
147
        return $this->data;
148
    }
149
150
    /**
151
     * Determine whether the given type is same with the current schema action or type.
152
     *
153
     * @param $type
154
     *
155
     * @return bool
156
     */
157
    public function is($type)
158
    {
159
        return $type === $this->getAction();
160
    }
161
162
    /**
163
     * Determine whether the current schema action is a adding action.
164
     *
165
     * @return bool
166
     */
167
    public function isAdd()
168
    {
169
        return in_array($this->getAction(), $this->actions['add']);
170
    }
171
172
    /**
173
     * Determine whether the current schema action is a deleting action.
174
     *
175
     * @return bool
176
     */
177
    public function isDelete()
178
    {
179
        return in_array($this->getAction(), $this->actions['delete']);
180
    }
181
182
    /**
183
     * Determine whether the current schema action is a creating action.
184
     *
185
     * @return bool
186
     */
187
    public function isCreate()
188
    {
189
        return in_array($this->getAction(), $this->actions['create']);
190
    }
191
192
    /**
193
     * Determine whether the current schema action is a dropping action.
194
     *
195
     * @return bool
196
     */
197
    public function isDrop()
198
    {
199
        return in_array($this->getAction(), $this->actions['drop']);
200
    }
201
}
202