GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (13)

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/Loader/DoctrineOrmLoader.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
/*
4
 * This file is part of the Hautelook\AliceBundle package.
5
 *
6
 * (c) Baldur Rensch <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Hautelook\AliceBundle\Loader;
13
14
use Doctrine\DBAL\Sharding\PoolingShardConnection;
15
use Doctrine\ORM\EntityManagerInterface;
16
use Fidry\AliceDataFixtures\Bridge\Doctrine\Persister\ObjectManagerPersister;
17
use Fidry\AliceDataFixtures\Bridge\Doctrine\Purger\Purger;
18
use Fidry\AliceDataFixtures\Loader\FileResolverLoader;
19
use Fidry\AliceDataFixtures\Loader\PurgerLoader;
20
use Fidry\AliceDataFixtures\LoaderInterface;
21
use Fidry\AliceDataFixtures\Persistence\PersisterAwareInterface;
22
use Fidry\AliceDataFixtures\Persistence\PurgeMode;
23
use Fidry\AliceDataFixtures\Persistence\Purger\NullPurger;
24
use Hautelook\AliceBundle\BundleResolverInterface;
25
use Hautelook\AliceBundle\FixtureLocatorInterface;
26
use Hautelook\AliceBundle\LoaderInterface as AliceBundleLoaderInterface;
27
use Hautelook\AliceBundle\LoggerAwareInterface;
28
use Hautelook\AliceBundle\Resolver\File\KernelFileResolver;
29
use InvalidArgumentException;
30
use LogicException;
31
use Nelmio\Alice\IsAServiceTrait;
32
use Psr\Log\LoggerInterface;
33
use Psr\Log\NullLogger;
34
use Symfony\Bundle\FrameworkBundle\Console\Application;
35
use Symfony\Component\HttpKernel\KernelInterface;
36
37
final class DoctrineOrmLoader implements AliceBundleLoaderInterface, LoggerAwareInterface
38
{
39
    use IsAServiceTrait;
40
41
    private $bundleResolver;
42
    private $fixtureLocator;
43
    /** @var LoaderInterface|PersisterAwareInterface */
44
    private $purgeLoader;
45
    /** @var LoaderInterface|PersisterAwareInterface */
46
    private $appendLoader;
47
    private $logger;
48
49
    public function __construct(
50
        BundleResolverInterface $bundleResolver,
51
        FixtureLocatorInterface $fixtureLocator,
52
        LoaderInterface $purgeLoader,
53
        LoaderInterface $appendLoader,
54
        LoggerInterface $logger = null
55
    ) {
56
        $this->bundleResolver = $bundleResolver;
57
        $this->fixtureLocator = $fixtureLocator;
58
59
        if (false === $purgeLoader instanceof PersisterAwareInterface) {
60
            throw new InvalidArgumentException(
61
                sprintf(
62
                    'Expected loader to be an instance of "%s".',
63
                    PersisterAwareInterface::class
64
                )
65
            );
66
        }
67
68
        if (false === $appendLoader instanceof PersisterAwareInterface) {
69
            throw new InvalidArgumentException(
70
                sprintf(
71
                    'Expected loader to be an instance of "%s".',
72
                    PersisterAwareInterface::class
73
                )
74
            );
75
        }
76
77
        $this->purgeLoader = $purgeLoader;
78
        $this->appendLoader = $appendLoader;
79
        $this->logger = $logger ?? new NullLogger();
80
    }
81
82
    /**
83
     * @inheritdoc
84
     */
85
    public function withLogger(LoggerInterface $logger): self
86
    {
87
        return new self($this->bundleResolver, $this->fixtureLocator, $this->purgeLoader, $logger);
0 ignored issues
show
It seems like $this->purgeLoader can also be of type object<Fidry\AliceDataFi...ersisterAwareInterface>; however, Hautelook\AliceBundle\Lo...rmLoader::__construct() does only seem to accept object<Fidry\AliceDataFixtures\LoaderInterface>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
88
    }
89
90
    /**
91
     * @inheritdoc
92
     */
93
    public function load(
94
        Application $application,
95
        EntityManagerInterface $manager,
96
        array $bundles,
97
        string $environment,
98
        bool $append,
99
        bool $purgeWithTruncate,
100
        string $shard = null
101
    ) {
102
        $bundles = $this->bundleResolver->resolveBundles($application, $bundles);
103
        $fixtureFiles = $this->fixtureLocator->locateFiles($bundles, $environment);
104
105
        $this->logger->info('fixtures found', ['files' => $fixtureFiles]);
106
107
        if (null !== $shard) {
108
            $this->connectToShardConnection($manager, $shard);
109
        }
110
111
        $fixtures = $this->loadFixtures(
112
            $this->purgeLoader,
0 ignored issues
show
It seems like $this->purgeLoader can also be of type object<Fidry\AliceDataFi...ersisterAwareInterface>; however, Hautelook\AliceBundle\Lo...mLoader::loadFixtures() does only seem to accept object<Fidry\AliceDataFixtures\LoaderInterface>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
113
            $manager,
114
            $fixtureFiles,
115
            $application->getKernel()->getContainer()->getParameterBag()->all(),
0 ignored issues
show
The method getParameterBag() does not exist on Symfony\Component\Depend...tion\ContainerInterface. Did you maybe mean getParameter()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
116
            $append,
117
            $purgeWithTruncate
118
        );
119
120
        $this->logger->info('fixtures loaded');
121
122
        return $fixtures;
123
    }
124
125
    private function connectToShardConnection(EntityManagerInterface $manager, string $shard)
126
    {
127
        $connection = $manager->getConnection();
128
        if ($connection instanceof PoolingShardConnection) {
129
            $connection->connect($shard);
130
131
            return;
132
        }
133
134
        throw new InvalidArgumentException(
135
            sprintf(
136
                'Could not establish a shard connection for the shard "%s". The connection must be an instance'
137
                .' of "%s", got "%s" instead.',
138
                $shard,
139
                PoolingShardConnection::class,
140
                get_class($connection)
141
            )
142
        );
143
    }
144
145
    /**
146
     * @param LoaderInterface|PersisterAwareInterface $loader
147
     * @param EntityManagerInterface                  $manager
148
     * @param string[]                                $files
149
     * @param array                                   $parameters
150
     * @param bool                                    $append
151
     * @param bool|null                               $purgeWithTruncate
152
     *
153
     * @return object[]
154
     */
155
    private function loadFixtures(
156
        LoaderInterface $loader,
0 ignored issues
show
The parameter $loader 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...
157
        EntityManagerInterface $manager,
158
        array $files,
159
        array $parameters,
160
        bool $append,
161
        bool $purgeWithTruncate
162
    ) {
163
        if ($append && $purgeWithTruncate) {
164
            throw new LogicException(
165
                'Cannot append loaded fixtures and at the same time purge the database. Choose one.'
166
            );
167
        }
168
169
        $persister = new ObjectManagerPersister($manager);
170
171
        if (true === $append) {
172
            $loader = $this->appendLoader->withPersister($persister);
0 ignored issues
show
The method withPersister does only exist in Fidry\AliceDataFixtures\...PersisterAwareInterface, but not in Fidry\AliceDataFixtures\LoaderInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
173
174
            return $loader->load($files, $parameters);
175
        }
176
177
        $loader = $this->purgeLoader->withPersister($persister);
178
179
        $purgeMode = (true === $purgeWithTruncate)
180
            ? PurgeMode::createTruncateMode()
181
            : PurgeMode::createDeleteMode()
182
        ;
183
184
        return $loader->load($files, $parameters, [], $purgeMode);
185
    }
186
}
187