Issues (46)

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.

lib/Doctrine/Migrations/AbstractMigration.php (5 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
declare(strict_types=1);
4
5
namespace Doctrine\Migrations;
6
7
use Doctrine\DBAL\Connection;
8
use Doctrine\DBAL\DBALException;
9
use Doctrine\DBAL\Platforms\AbstractPlatform;
10
use Doctrine\DBAL\Schema\AbstractSchemaManager;
11
use Doctrine\DBAL\Schema\Schema;
12
use Doctrine\Migrations\Exception\AbortMigration;
13
use Doctrine\Migrations\Exception\IrreversibleMigration;
14
use Doctrine\Migrations\Exception\MigrationException;
15
use Doctrine\Migrations\Exception\SkipMigration;
16
use Doctrine\Migrations\Query\Query;
17
use Psr\Log\LoggerInterface;
18
use function sprintf;
19
20
/**
21
 * The AbstractMigration class is for end users to extend from when creating migrations. Extend this class
22
 * and implement the required up() and down() methods.
23
 */
24
abstract class AbstractMigration
25
{
26
    /** @var Connection */
27
    protected $connection;
28
29
    /** @var AbstractSchemaManager */
30
    protected $sm;
31
32
    /** @var AbstractPlatform */
33
    protected $platform;
34
35
    /** @var LoggerInterface */
36
    private $logger;
37
38
    /** @var Query[] */
39
    private $plannedSql = [];
40
41 31
    public function __construct(Connection $connection, LoggerInterface $logger)
42
    {
43 31
        $this->connection = $connection;
44 31
        $this->sm         = $this->connection->getSchemaManager();
45 31
        $this->platform   = $this->connection->getDatabasePlatform();
46 31
        $this->logger     = $logger;
47 31
    }
48
49
    /**
50
     * Indicates the transactional mode of this migration.
51
     *
52
     * If this function returns true (default) the migration will be executed
53
     * in one transaction, otherwise non-transactional state will be used to
54
     * execute each of the migration SQLs.
55
     *
56
     * Extending class should override this function to alter the return value.
57
     */
58 15
    public function isTransactional() : bool
59
    {
60 15
        return true;
61
    }
62
63 5
    public function getDescription() : string
64
    {
65 5
        return '';
66
    }
67
68 3
    public function warnIf(bool $condition, string $message = 'Unknown Reason') : void
69
    {
70 3
        if (! $condition) {
71 1
            return;
72
        }
73
74 2
        $this->logger->warning($message, ['migration' => $this]);
75 2
    }
76
77
    /**
78
     * @throws AbortMigration
79
     */
80 11
    public function abortIf(bool $condition, string $message = 'Unknown Reason') : void
81
    {
82 11
        if ($condition) {
83 4
            throw new AbortMigration($message);
84
        }
85 7
    }
86
87
    /**
88
     * @throws SkipMigration
89
     */
90 10
    public function skipIf(bool $condition, string $message = 'Unknown Reason') : void
91
    {
92 10
        if ($condition) {
93 2
            throw new SkipMigration($message);
94
        }
95 8
    }
96
97
    /**
98
     * @throws MigrationException|DBALException
99
     */
100 10
    public function preUp(Schema $schema) : void
0 ignored issues
show
The parameter $schema is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
101
    {
102 10
    }
103
104
    /**
105
     * @throws MigrationException|DBALException
106
     */
107 7
    public function postUp(Schema $schema) : void
0 ignored issues
show
The parameter $schema is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
108
    {
109 7
    }
110
111
    /**
112
     * @throws MigrationException|DBALException
113
     */
114 2
    public function preDown(Schema $schema) : void
0 ignored issues
show
The parameter $schema is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
115
    {
116 2
    }
117
118
    /**
119
     * @throws MigrationException|DBALException
120
     */
121 2
    public function postDown(Schema $schema) : void
0 ignored issues
show
The parameter $schema is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
122
    {
123 2
    }
124
125
    /**
126
     * @throws MigrationException|DBALException
127
     */
128
    abstract public function up(Schema $schema) : void;
129
130
    /**
131
     * @throws MigrationException|DBALException
132
     */
133 1
    public function down(Schema $schema) : void
0 ignored issues
show
The parameter $schema is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
134
    {
135 1
        $this->abortIf(true, sprintf('No down() migration implemented for "%s"', static::class));
136
    }
137
138
    /**
139
     * @param mixed[] $params
140
     * @param mixed[] $types
141
     */
142 11
    protected function addSql(
143
        string $sql,
144
        array $params = [],
145
        array $types = []
146
    ) : void {
147 11
        $this->plannedSql[] = new Query($sql, $params, $types);
148 11
    }
149
150
    /**
151
     * @return Query[]
152
     */
153 12
    public function getSql() : array
154
    {
155 12
        return $this->plannedSql;
156
    }
157
158 1
    protected function write(string $message) : void
159
    {
160 1
        $this->logger->notice($message, ['migration' => $this]);
161 1
    }
162
163
    /**
164
     * @throws IrreversibleMigration
165
     */
166 2
    protected function throwIrreversibleMigrationException(?string $message = null) : void
167
    {
168 2
        if ($message === null) {
169 1
            $message = 'This migration is irreversible and cannot be reverted.';
170
        }
171
172 2
        throw new IrreversibleMigration($message);
173
    }
174
}
175