Issues (44)

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/Dialect/MysqlDialect.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
namespace Graze\DataDb\Dialect;
4
5
use Graze\DataDb\TableNodeInterface;
6
7
class MysqlDialect extends AbstractDialect
8
{
9
    /**
10
     * @return string
11
     */
12
    public function getIdentifierQuote()
13
    {
14
        return '`';
15
    }
16
17
    /**
18
     * @param TableNodeInterface $old
19
     * @param TableNodeInterface $new
20
     *
21
     * @return array
22
     */
23 View Code Duplication
    public function getCreateTableLike(TableNodeInterface $old, TableNodeInterface $new)
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...
24
    {
25
        return [
26
            $this->format(
27
                'CREATE TABLE {new:schema|q}.{new:table|q} LIKE {old:schema|q}.{old:table|q}',
28
                ['old' => $old, 'new' => $new,]
29
            ),
30
            [],
31
        ];
32
    }
33
34
    /**
35
     * @param TableNodeInterface $source
36
     * @param TableNodeInterface $join
37
     * @param string             $on
38
     * @param string|null        $where
39
     *
40
     * @return array
41
     */
42
    public function getDeleteTableJoinSoftDelete(
43
        TableNodeInterface $source,
44
        TableNodeInterface $join,
45
        $on,
46
        $where = null
47
    ) {
48
        return [
49
            $this->format(
50
                'UPDATE {source:schema|q}.{source:table|q}
51
                JOIN {join:schema|q}.{join:table|q}
52
                ON {on}
53
                SET{softUpdated}
54
                    {source:softDeleted|q} = CURRENT_TIMESTAMP
55
                {where}',
56
                [
57
                    'source'      => $source,
58
                    'join'        => $join,
59
                    'on'          => $on,
60
                    'softUpdated' => ($source->getSoftUpdated() ?
61
                        $this->format(
62
                            ' {source:softUpdated|q} = CURRENT_TIMESTAMP,',
63
                            ['source' => $source]
64
                        ) : ''
65
                    ),
66
                    'where'       => ($where ? 'WHERE ' . $where : ''),
67
                ]
68
            ),
69
            [],
70
        ];
71
    }
72
73
    /**
74
     * @param TableNodeInterface $source
75
     * @param TableNodeInterface $join
76
     * @param string             $on
77
     * @param string|null        $where
78
     *
79
     * @return array
80
     */
81 View Code Duplication
    public function getDeleteTableJoin(
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...
82
        TableNodeInterface $source,
83
        TableNodeInterface $join,
84
        $on,
85
        $where = null
86
    ) {
87
        return [
88
            $this->format(
89
                'DELETE {source:schema|q}.{source:table|q}
90
                FROM {source:schema|q}.{source:table|q}
91
                JOIN {join:schema|q}.{join:table|q}
92
                ON {on}
93
                {where}',
94
                [
95
                    'source' => $source,
96
                    'join'   => $join,
97
                    'on'     => $on,
98
                    'where'  => ($where ? 'WHERE ' . $where : ''),
99
                ]
100
            ),
101
            [],
102
        ];
103
    }
104
105
    /**
106
     * @param TableNodeInterface $table
107
     * @param string|null        $where
108
     *
109
     * @return array [sql, bind]
110
     */
111
    public function getDeleteFromTableSoftDelete(TableNodeInterface $table, $where = null)
112
    {
113
        return [
114
            $this->format(
115
                'UPDATE {table:schema|q}.{table:table|q}
116
                    SET{softUpdated}
117
                        {table:softDeleted|q} = CURRENT_TIMESTAMP
118
                    {where}',
119
                [
120
                    'table'       => $table,
121
                    'softUpdated' => ($table->getSoftUpdated() ?
122
                        $this->format(' {table:softUpdated|q} = CURRENT_TIMESTAMP,', ['table' => $table]) :
123
                        ''),
124
                    'where'       => ($where ? 'WHERE ' . $where : ''),
125
                ]
126
            ),
127
            [],
128
        ];
129
    }
130
131
    /**
132
     * @param TableNodeInterface $table
133
     * @param array              $columns
134
     * @param array              $primary
135
     * @param array              $index
136
     *
137
     * @return array
138
     */
139
    public function getCreateTable(TableNodeInterface $table, array $columns, array $primary, array $index)
140
    {
141
        $allColumns = array_merge($columns, $primary, $index);
142
143
        return [
144
            $this->format(
145
                "CREATE TABLE {table:schema|q}.{table:table|q} (\n  {allColumns}\n)",
146
                [
147
                    'table'      => $table,
148
                    'allColumns' => implode(",\n  ", $allColumns),
149
                ]
150
            ),
151
            [],
152
        ];
153
    }
154
155
    /**
156
     * @param array $column
157
     *
158
     * @return string
159
     */
160 View Code Duplication
    public function getColumnDefinition(array $column)
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...
161
    {
162
        return $this->format(
163
            '{column|q} {type} {notnull}',
164
            array_merge($column, ['notnull' => $column['nullable'] ? 'NULL' : 'NOT NULL'])
165
        );
166
    }
167
168
    /**
169
     * @param array $key
170
     *
171
     * @return string
172
     */
173
    public function getPrimaryKeyDefinition(array $key)
174
    {
175
        return $this->format('PRIMARY KEY ({column|q})', $key);
176
    }
177
178
    /**
179
     * @param array $index
180
     *
181
     * @return string
182
     */
183
    public function getIndexDefinition(array $index)
184
    {
185
        return $this->format('KEY {column|q} ({column|q})', $index);
186
    }
187
188
    /**
189
     * @param TableNodeInterface $table
190
     *
191
     * @return array [sql, bind]
192
     */
193
    public function getDescribeTable(TableNodeInterface $table)
194
    {
195
        return [$this->format('DESCRIBE {table:schema|q}.{table:table|q}', ['table' => $table]), []];
196
    }
197
198
    /**
199
     * @param TableNodeInterface $table
200
     *
201
     * @return array [sql, bind]
202
     */
203
    public function getCreateSyntax(TableNodeInterface $table)
204
    {
205
        return [
206
            $this->format('SHOW CREATE TABLE {table:schema|q}.{table:table|q}', ['table' => $table]),
207
            [],
208
        ];
209
    }
210
}
211