Issues (11)

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/DBAL/Statement.php (2 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 BsbDoctrineReconnect\DBAL;
4
5
use Doctrine\DBAL\DBALException;
6
use Doctrine\DBAL\Driver\Statement as DriverStatement;
7
use IteratorAggregate;
8
use PDO;
9
10
/**
11
 * Class Statement
12
 *
13
 * @package BsbDoctrineReconnect\DBAL
14
 */
15
class Statement implements IteratorAggregate, DriverStatement
16
{
17
    /**
18
     * @var string
19
     */
20
    private $sql;
21
22
    /**
23
     * @var \Doctrine\DBAL\Statement
24
     */
25
    private $stmt;
26
27
    /**
28
     * @var Connection
29
     */
30
    private $conn;
31
32
    /**
33
     * @var array binding values
34
     */
35
    private $values = [];
36
37
    /**
38
     * @var array binding parameters
39
     */
40
    private $params = [];
41
42
    /**
43
     * @param            string $sql
44
     * @param Connection        $conn
45
     */
46
    public function __construct($sql, Connection $conn)
47
    {
48
        $this->sql  = $sql;
49
        $this->conn = $conn;
50
51
        $this->createStatement();
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57
    private function createStatement()
58
    {
59
        $this->stmt = $this->conn->prepareUnwrapped($this->sql);
0 ignored issues
show
Deprecated Code introduced by
The method BsbDoctrineReconnect\DBA...ion::prepareUnwrapped() has been deprecated.

This method has been deprecated.

Loading history...
60
61
        foreach ($this->values as $args) {
62
            $this->bindValue($args[0], $args[1], $args[2]);
63
        }
64
65
        foreach ($this->params as $args) {
66
            $this->bindParam($args[0], $args[1], $args[2]);
67
        }
68
    }
69
70
    /**
71
     * @param null $params
72
     * @return bool|null
73
     * @throws DBALException
74
     */
75
    public function execute($params = null)
76
    {
77
        $stmt    = null;
78
        $attempt = 0;
79
        $retry   = true;
80
81
        while ($retry) {
82
            $retry = false;
83
84
            try {
85
                $stmt = $this->stmt->execute($params);
86
            } catch (DBALException $e) {
87 View Code Duplication
                if ($this->conn->validateReconnectAttempt($e, $attempt)) {
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...
88
                    $this->conn->close();
89
                    $this->createStatement();
90
                    $attempt++;
91
                    $retry = true;
92
                } else {
93
                    throw $e;
94
                }
95
            }
96
        }
97
98
        return $stmt;
99
    }
100
101
    /**
102
     * @param mixed $param
103
     * @param mixed $value
104
     * @param null  $type
105
     * @return bool
106
     */
107
    public function bindValue($param, $value, $type = null)
108
    {
109
        $this->values[$param] = [$param, $value, $type];
110
111
        return $this->stmt->bindValue($param, $value, $type);
112
    }
113
114
    /**
115
     * @param mixed    $column
116
     * @param mixed    $variable
117
     * @param int|null $type
118
     * @param null     $length
119
     * @return bool
120
     */
121
    public function bindParam($column, &$variable, $type = PDO::PARAM_STR, $length = null)
122
    {
123
        $this->values[$column] = [$column, &$variable, $type];
124
125
        return $this->stmt->bindParam($column, $variable, $type);
126
    }
127
128
    /**
129
     * @return bool
130
     */
131
    public function closeCursor()
132
    {
133
        return $this->stmt->closeCursor();
134
    }
135
136
    /**
137
     * @return int
138
     */
139
    public function columnCount()
140
    {
141
        return $this->stmt->columnCount();
142
    }
143
144
    /**
145
     * @return string
146
     */
147
    public function errorCode()
148
    {
149
        return $this->stmt->errorCode();
150
    }
151
152
    /**
153
     * @return array
154
     */
155
    public function errorInfo()
156
    {
157
        return $this->stmt->errorInfo();
158
    }
159
160
    /**
161
     * @param int|null $fetchStyle
162
     * @return mixed
163
     */
164
    public function fetch($fetchStyle = PDO::FETCH_BOTH)
165
    {
166
        return $this->stmt->fetch($fetchStyle);
167
    }
168
169
    /**
170
     * @param int|null $fetchStyle
171
     * @return array
172
     */
173
    public function fetchAll($fetchStyle = PDO::FETCH_BOTH)
174
    {
175
        return $this->stmt->fetchAll($fetchStyle);
176
    }
177
178
    /**
179
     * @param int $columnIndex
180
     * @return mixed
181
     */
182
    public function fetchColumn($columnIndex = 0)
183
    {
184
        return $this->stmt->fetchColumn($columnIndex);
185
    }
186
187
    /**
188
     * @return int
189
     */
190
    public function rowCount()
191
    {
192
        return $this->stmt->rowCount();
193
    }
194
195
    /**
196
     * {@inheritdoc}
197
     */
198
    public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
199
    {
200
        // This thin wrapper is necessary to shield against the weird signature
201
        // of PDOStatement::setFetchMode(): even if the second and third
202
        // parameters are optional, PHP will not let us remove it from this
203
        // declaration.
204
        if ($arg2 === null && $arg3 === null) {
205
            return parent::setFetchMode($fetchMode);
206
        }
207
208
        if ($arg3 === null) {
209
            return parent::setFetchMode($fetchMode, $arg2);
210
        }
211
212
        return parent::setFetchMode($fetchMode, $arg2, $arg3);
213
    }
214
215
    /**
216
     * Required by interface IteratorAggregate.
217
     *
218
     * {@inheritdoc}
219
     */
220
    public function getIterator()
221
    {
222
        return $this->stmt;
223
    }
224
}
225