Issues (43)

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/Service/Runner/MigrationRunner.php (6 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
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 *
15
 * This software consists of voluntary contributions made by many individuals
16
 * and is licensed under the MIT license. For more information, see
17
 * <http://www.doctrine-project.org>.
18
 */
19
20
namespace Baleen\Migrations\Service\Runner;
21
22
use Baleen\Migrations\Exception\Service\Runner\RunnerException;
23
use Baleen\Migrations\Service\MigrationBus\MigrationBus;
24
use Baleen\Migrations\Service\MigrationBus\MigrationBusInterface;
25
use Baleen\Migrations\Migration\OptionsInterface;
26
use Baleen\Migrations\Service\Runner\Event\Migration\MigrateAfterEvent;
27
use Baleen\Migrations\Service\Runner\Event\Migration\MigrateBeforeEvent;
28
use Baleen\Migrations\Common\Event\Context\CollectionContext;
29
use Baleen\Migrations\Common\Event\Context\CollectionContextInterface;
30
use Baleen\Migrations\Common\Event\Context\ContextInterface;
31
use Baleen\Migrations\Common\Event\Context\HasContextTrait;
32
use Baleen\Migrations\Common\Event\Publisher\HasInternalPublisherTrait;
33
use Baleen\Migrations\Common\Event\PublisherInterface;
34
use Baleen\Migrations\Delta\DeltaInterface;
35
36
/**
37
 * Class MigrationRunner
38
 *
39
 * A Runner that emits domain events using an Emitter
40
 *
41
 * @author Gabriel Somoza <[email protected]>
42
 */
43
final class MigrationRunner implements MigrationRunnerInterface
44
{
45
    use HasInternalPublisherTrait;
46
    use HasContextTrait;
47
48
    /**
49
     * MigrationRunner constructor.
50
     *
51
     * @param PublisherInterface $publisher
0 ignored issues
show
Should the type for parameter $publisher not be null|PublisherInterface?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
52
     * @param CollectionContextInterface $context
0 ignored issues
show
Should the type for parameter $context not be null|CollectionContextInterface?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
53
     */
54 29
    public function __construct(
55
        PublisherInterface $publisher = null,
56
        CollectionContextInterface $context = null
57
    ) {
58 29
        if (null === $context) {
59 23
            $context = CollectionContext::createWithProgress(1, 1);
60 23
        }
61 29
        $this->setContext($context);
62
63 29
        $this->setPublisher($publisher);
64 29
    }
65
66
    /**
67
     * Runs a single version using the specified options
68
     *
69
     * @param DeltaInterface $version
70
     * @param OptionsInterface $options
71
     *
72
     * @return false|MigrateAfterEvent
73
     *
74
     * @throws RunnerException
75
     */
76 23
    public function run(DeltaInterface $version, OptionsInterface $options)
77
    {
78 23
        if (!$this->shouldMigrate($version, $options)) {
79 14
            if ($options->isExceptionOnSkip()) {
80 2
                throw new RunnerException(sprintf(
81 2
                    'Cowardly refusing to run %s() on a delta that is already "%s" (ID: %s).',
82 2
                    $options->getDirection(),
83 2
                    $options->getDirection(),
84 2
                    $version->getId()
85 2
                ));
86
            }
87
88 12
            return false; // skip
89
        }
90
91
        // Dispatch MIGRATE_BEFORE
92 13
        $this->getPublisher()->publish(new MigrateBeforeEvent($version, $options, $this->getContext()));
0 ignored issues
show
$this->getContext() is of type object<Baleen\Migrations...ntext\ContextInterface>, but the function expects a null|object<Baleen\Migra...ectionContextInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
93
94 13
        $version->migrate($options); // state will be changed
95
96
        // Dispatch MIGRATE_AFTER
97 13
        $event = new MigrateAfterEvent($version, $options, $this->getContext());
0 ignored issues
show
$this->getContext() is of type object<Baleen\Migrations...ntext\ContextInterface>, but the function expects a null|object<Baleen\Migra...ectionContextInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
98 13
        $this->getPublisher()->publish($event);
99
100 13
        return $event;
101
    }
102
103
    /**
104
     * Returns true if the operation is forced, or if the direction is the opposite to the state of the migration.
105
     *
106
     * @param DeltaInterface $version
107
     * @param OptionsInterface $options
108
     *
109
     * @return bool
110
     */
111 23
    protected function shouldMigrate(DeltaInterface $version, OptionsInterface $options)
112
    {
113 23
        return $options->isForced()
114 23
        || ($options->getDirection()->isUp() ^ $version->isMigrated()); // direction is opposite to state
115
    }
116
117
    /**
118
     * @inheritdoc
119
     */
120 18
    final public function withContext(ContextInterface $context) {
0 ignored issues
show
Unnecessary FINAL modifier in FINAL class
Loading history...
121 18
        return new static($this->getPublisher(), $context);
0 ignored issues
show
$context is of type object<Baleen\Migrations...ntext\ContextInterface>, but the function expects a null|object<Baleen\Migra...ectionContextInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
122
    }
123
}
124