Issues (53)

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/Admin/Tests/AbstractDatabaseTest.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
/**
4
 * admin
5
 *
6
 * @category    Tollwerk
7
 * @package     Tollwerk\Admin
8
 * @subpackage  Tollwerk\Admin\Tests
9
 * @author      Joschi Kuphal <[email protected]> / @jkphl
10
 * @copyright   Copyright © 2018 Joschi Kuphal <[email protected]> / @jkphl
11
 * @license     http://opensource.org/licenses/MIT The MIT License (MIT)
12
 */
13
14
/***********************************************************************************
15
 *  The MIT License (MIT)
16
 *
17
 *  Copyright © 2018 Joschi Kuphal <[email protected]> / @jkphl
18
 *
19
 *  Permission is hereby granted, free of charge, to any person obtaining a copy of
20
 *  this software and associated documentation files (the "Software"), to deal in
21
 *  the Software without restriction, including without limitation the rights to
22
 *  use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
23
 *  the Software, and to permit persons to whom the Software is furnished to do so,
24
 *  subject to the following conditions:
25
 *
26
 *  The above copyright notice and this permission notice shall be included in all
27
 *  copies or substantial portions of the Software.
28
 *
29
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30
 *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
31
 *  FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
32
 *  COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
33
 *  IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
34
 *  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35
 ***********************************************************************************/
36
37
namespace Tollwerk\Admin\Tests;
38
39
use Doctrine\DBAL\DriverManager;
40
use PHPUnit_Extensions_Database_DB_IDatabaseConnection;
41
use Tollwerk\Admin\Infrastructure\App;
42
43
/**
44
 * Abstract database test case
45
 *
46
 * @package Tollwerk\Admin
47
 * @subpackage Tollwerk\Admin\Tests
48
 */
49
abstract class AbstractDatabaseTest extends \PHPUnit_Extensions_Database_TestCase
50
{
51
    /**
52
     * PDO instance
53
     *
54
     * @var null
55
     */
56
    private static $pdo = null;
57
    /**
58
     * DBAL instance
59
     *
60
     * @var null
61
     */
62
    private static $dbal = null;
63
64
    // only instantiate PHPUnit_Extensions_Database_DB_IDatabaseConnection once per test
65
    /**
66
     * Connection
67
     *
68
     * @var PHPUnit_Extensions_Database_DB_IDatabaseConnection
69
     */
70
    private $conn = null;
71
72
    /**
73
     * Returns the test database connection.
74
     *
75
     * @return PHPUnit_Extensions_Database_DB_IDatabaseConnection Database connection
76
     */
77
    final protected function getConnection()
78
    {
79
        if ($this->conn === null) {
80
            $dbparams = App::getConfig('doctrine.dbparams');
81
82
            if (self::$pdo == null) {
83
                $dsn = 'mysql:dbname='.$dbparams['dbname'].';host='.$dbparams['host'];
84
                self::$pdo = new \PDO($dsn, $dbparams['user'], $dbparams['password']);
0 ignored issues
show
Documentation Bug introduced by
It seems like new \PDO($dsn, $dbparams... $dbparams['password']) of type object<PDO> is incompatible with the declared type null of property $pdo.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
85
            }
86
            $this->conn = $this->createDefaultDBConnection(self::$pdo, $dbparams['dbname']);
0 ignored issues
show
It seems like self::$pdo can be null; however, createDefaultDBConnection() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
87
        }
88
89
        return $this->conn;
90
    }
91
92
    /**
93
     * Return the PDO instance
94
     *
95
     * @return \PDO PDO instance
96
     */
97
    protected function getPdo()
98
    {
99
        return $this->getConnection()->getConnection();
100
    }
101
102
    /**
103
     * Return the DBAL connection
104
     *
105
     * @return \Doctrine\DBAL\Connection
106
     */
107
    protected function getDbal()
108
    {
109
        if (self::$dbal === null) {
110
            self::$dbal = DriverManager::getConnection(array('pdo' => $this->getPdo()));
0 ignored issues
show
Documentation Bug introduced by
It seems like \Doctrine\DBAL\DriverMan...o' => $this->getPdo())) of type object<Doctrine\DBAL\Connection> is incompatible with the declared type null of property $dbal.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
111
        }
112
113
        return self::$dbal;
114
    }
115
116
    /**
117
     * Return the absolute path to a fixture file
118
     *
119
     * @param string $fixture Fixture file name
120
     * @return string Absolute fixture file
121
     */
122
    protected function getFixture($fixture)
123
    {
124
        return __DIR__.DIRECTORY_SEPARATOR.'Fixture'.DIRECTORY_SEPARATOR.$fixture;
125
    }
126
127
    /**
128
     * Create and return a dataset with certain replacements
129
     *
130
     * @param string $fixture Fixture file name
131
     * @return \PHPUnit_Extensions_Database_DataSet_ReplacementDataSet Data set
132
     */
133
    protected function getFixtureDataSet($fixture)
134
    {
135
        $dataSet = $this->createFlatXMLDataSet($this->getFixture($fixture));
136
        $replacementDataSet = new \PHPUnit_Extensions_Database_DataSet_ReplacementDataSet($dataSet);
137
        $replacementDataSet->addFullReplacement('##NULL##', null);
138
        return $replacementDataSet;
139
    }
140
}
141