Issues (39)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  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.
  Header Injection
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/Crate/DBAL/Driver/PDOCrate/PDOConnection.php (4 issues)

1
<?php
2
3
/**
4
 * Licensed to CRATE Technology GmbH("Crate") under one or more contributor
5
 * license agreements.  See the NOTICE file distributed with this work for
6
 * additional information regarding copyright ownership.  Crate licenses
7
 * this file to you under the Apache License, Version 2.0 (the "License");
8
 * you may not use this file except in compliance with the License.  You may
9
 * obtain a copy of the License at
10
 *
11
 * http://www.apache.org/licenses/LICENSE-2.0
12
 *
13
 * Unless required by applicable law or agreed to in writing, software
14
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
16
 * License for the specific language governing permissions and limitations
17
 * under the License.
18
 *
19
 * However, if you have executed another commercial license agreement
20
 * with Crate these terms will supersede the license and you may use the
21
 * software solely pursuant to the terms of the relevant commercial agreement.
22
 */
23
24
namespace Crate\DBAL\Driver\PDOCrate;
25
26
use Crate\PDO\PDOCrateDB;
27
use Crate\PDO\PDOStatement;
28
use Doctrine\DBAL\Driver\Connection as ConnectionInterface;
29
use Doctrine\DBAL\Driver\PDO\Exception;
30
use Doctrine\DBAL\Driver\Result as ResultInterface;
31
use Doctrine\DBAL\ParameterType;
32
use PDO;
33
use PDOException;
34
35
class PDOConnection implements ConnectionInterface
36
{
37
    private PDOCrateDB $connection;
38
39
    /**
40
     * @param string $dsn
41
     * @param string $user
42
     * @param string $password
43
     * @param array|null $options
44
     */
45 22
    public function __construct($dsn, $user = null, $password = null, ?array $options = null)
46
    {
47 22
        $this->connection = new PDOCrateDB($dsn, $user, $password, $options);
0 ignored issues
show
It seems like $password can also be of type string; however, parameter $passwd of Crate\PDO\PDOCrateDB::__construct() does only seem to accept null, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

47
        $this->connection = new PDOCrateDB($dsn, $user, /** @scrutinizer ignore-type */ $password, $options);
Loading history...
It seems like $user can also be of type string; however, parameter $username of Crate\PDO\PDOCrateDB::__construct() does only seem to accept null, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

47
        $this->connection = new PDOCrateDB($dsn, /** @scrutinizer ignore-type */ $user, $password, $options);
Loading history...
48 22
        $this->connection->setAttribute(PDO::ATTR_STATEMENT_CLASS, [PDOStatement::class, []]);
49 22
        $this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
50
    }
51
52 2
    public function getServerVersion(): string
53
    {
54
        try {
55 2
            return $this->connection->getServerVersion();
56
        } catch (PDOException $exception) {
57
            throw Exception::new($exception);
58
        }
59
    }
60
61 4
    public function getNativeConnection(): PDOCrateDB
62
    {
63 4
        return $this->connection;
64
    }
65
66
    /**
67
     * {@inheritDoc}
68
     *
69
     * References:
70
     * - https://github.com/doctrine/dbal/issues/2025
71
     * - https://github.com/doctrine/dbal/pull/517
72
     * - https://github.com/doctrine/dbal/pull/373
73
     */
74 108
    public function prepare($sql, $options = []): CrateStatement
75
    {
76
        try {
77 108
            return new CrateStatement($this->connection, $sql, $options);
78
        } catch (PDOException $exception) {
79
            throw Exception::new($exception);
80
        }
81
    }
82
83
    /**
84
     * {@inheritDoc}
85
     */
86 90
    public function exec($sql): int
87
    {
88
        try {
89 90
            return $this->connection->exec($sql);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->connection->exec($sql) could return the type false which is incompatible with the type-hinted return integer. Consider adding an additional type-check to rule them out.
Loading history...
90 8
        } catch (PDOException $exception) {
91 8
            throw Exception::new($exception);
92
        }
93
    }
94
95 68
    public function query(string $sql): ResultInterface
96
    {
97 68
        $stmt = $this->prepare($sql);
98 68
        return $stmt->execute();
99
    }
100
101 4
    public function quote($value, $type = ParameterType::STRING): string
102
    {
103
        try {
104 4
            return $this->connection->quote($value, $type);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->connection->quote($value, $type) could return the type boolean|null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
105
        } catch (PDOException $exception) {
106
            throw Exception::new($exception);
107
        }
108
    }
109
110
    public function lastInsertId($name = null): string
111
    {
112
        try {
113
            return $this->connection->lastInsertId($name);
114
        } catch (PDOException $exception) {
115
            throw Exception::new($exception);
116
        }
117
    }
118
119 6
    public function beginTransaction()
120
    {
121
        try {
122 6
            return $this->connection->beginTransaction();
123
        } catch (PDOException $exception) {
124
            throw Exception::new($exception);
125
        }
126
    }
127
128 2
    public function commit()
129
    {
130
        try {
131 2
            return $this->connection->commit();
132
        } catch (PDOException $exception) {
133
            throw Exception::new($exception);
134
        }
135
    }
136
137 2
    public function rollBack()
138
    {
139
        try {
140 2
            return $this->connection->rollBack();
141 2
        } catch (PDOException $exception) {
142 2
            throw Exception::new($exception);
143
        }
144
    }
145
}
146