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 (41)

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.

Tests/Functional/ScheduleCaseTest.php (4 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 file is part of the Global Trading Technologies Ltd workflow-extension-bundle package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * (c) fduch <[email protected]>
9
 * @date 28.07.16
10
 */
11
12
namespace Gtt\Bundle\WorkflowExtensionsBundle\Tests\Functional;
13
14
use Doctrine\Bundle\DoctrineBundle\Command\Proxy\CreateSchemaDoctrineCommand;
15
use Doctrine\Bundle\FixturesBundle\Command\LoadDataFixturesDoctrineCommand;
16
use Doctrine\ORM\EntityManager;
17
use Gtt\Bundle\WorkflowExtensionsBundle\Tests\Functional\Configuration\ScheduleCase\Fixtures\ClientBundle\ClientBundle;
18
use Gtt\Bundle\WorkflowExtensionsBundle\Tests\Functional\Configuration\ScheduleCase\Fixtures\ClientBundle\Entity\Client;
19
use Gtt\Bundle\WorkflowExtensionsBundle\Tests\Functional\Configuration\ScheduleCase\Fixtures\Event;
20
use JMS\JobQueueBundle\Command\RunCommand;
21
use Symfony\Bundle\FrameworkBundle\Console\Application;
22
use Symfony\Component\Console\Command\Command;
23
use Symfony\Component\Console\Input\InputOption;
24
use Symfony\Component\Console\Tester\CommandTester;
25
use Symfony\Component\DependencyInjection\ContainerInterface;
26
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
27
28
class ScheduleCaseTest extends TestCase
29
{
30
    /**
31
     * WebClient emulator
32
     *
33
     * @var \Symfony\Bundle\FrameworkBundle\Client
34
     */
35
    protected $client;
36
37
    /**
38
     * @var Application
39
     */
40
    protected $app;
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public function setUp()
46
    {
47
        $this->initApplication();
48
49
        $this->initDbSchema($this->client->getContainer());
0 ignored issues
show
It seems like $this->client->getContainer() can be null; however, initDbSchema() 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...
50
51
        // load fixtures
52
        $fixturesBundle = new ClientBundle();
53
        $fixturesPath = $fixturesBundle->getPath() . '/DataFixtures/ORM';
54
        $this->loadFixtures($this->client->getContainer(), $fixturesPath);
0 ignored issues
show
It seems like $this->client->getContainer() can be null; however, loadFixtures() 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...
55
    }
56
57
    public function initApplication()
58
    {
59
        if (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers())) {
60
            self::markTestSkipped('This test requires SQLite support in your environment');
61
        }
62
63
        parent::setUp();
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (setUp() instead of initApplication()). Are you sure this is correct? If so, you might want to change this to $this->setUp().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
64
65
        $this->client = $this->createClient(
66
            array(
67
                "app_name"    => "ScheduleCaseTest",
68
                "test_case"   => "ScheduleCase",
69
                "root_config" => "config.yml",
70
                "config_dir"  => __DIR__ . "/Configuration",
71
                "root_dir"    => __DIR__ . "/Configuration/ScheduleCase",
72
                "environment" => "test",
73
                "debug"       => false
74
            )
75
        );
76
        $this->app = new Application($this->client->getKernel());
77
        // add jms-job-id option to the application in order to be able to run scheduler
78
        $this->app->getDefinition()->addOption(
79
            new InputOption('--jms-job-id', null, InputOption::VALUE_REQUIRED, 'The ID of the Job.')
80
        );
81
        $this->app->setAutoExit(false);
82
        $this->app->setCatchExceptions(false);
83
84
        return $this->app;
85
    }
86
87
    /**
88
     * @param ContainerInterface $container
89
     * @param string $em
90
     */
91
    protected function initDbSchema(ContainerInterface $container, $em = 'default')
0 ignored issues
show
The parameter $container 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...
92
    {
93
        $schemaCreateCommand = new CreateSchemaDoctrineCommand();
94
        $this->runConsoleCommand($schemaCreateCommand, ["--em" => $em]);
95
    }
96
97
    /**
98
     * @param ContainerInterface $container
99
     * @param array|string|false $fixturesPath
100
     * @param string $em
101
     * @param bool|true $append
102
     * @return array
103
     */
104
    protected function loadFixtures(ContainerInterface $container, $fixturesPath = false, $em = 'default', $append = true)
105
    {
106
        $fixtureLoadCommand = new LoadDataFixturesDoctrineCommand();
107
        $fixtureLoadCommand->setContainer($container);
108
        $params = array(
109
            "--em" => $em,
110
            "--append" => $append
111
        );
112
        if ($fixturesPath) {
113
            $params["--fixtures"] = $fixturesPath;
114
        }
115
116
        $this->runConsoleCommand($fixtureLoadCommand, $params);
117
    }
118
119
    /**
120
     * @large
121
     * @group functional
122
     */
123
    public function testScheduleWorks()
124
    {
125
        $container = $this->client->getContainer();
126
        /** @var EventDispatcherInterface $eventDispatcher */
127
        $eventDispatcher = $container->get('event_dispatcher');
128
129
        /** @var EntityManager $clientEm */
130
        $clientEm   = $container->get("doctrine")->getManagerForClass(Client::class);
131
        $clientRepo = $clientEm->getRepository(Client::class);
132
        /** @var Client $subject */
133
        $subject = $clientRepo->findOneBy(['name' => "Johnny"]);
134
        $event = new Event($subject);
135
136
        // simply check that client can be activated (also sleeping transition should be scheduled (+1s) inside)
137
        $eventDispatcher->dispatch('activating.event', $event);
138
        self::assertEquals('active', $subject->getStatus());
139
140
        // sleep for a while (wait 2 sec to avoid "the same second" collision)
141
        // and run scheduler with 1-sec runtime to check that sleeping transition is executed
142
        sleep(2);
143
        $this->runScheduler(1);
144
        $clientEm->refresh($subject);
145
        self::assertEquals('sleeping', $subject->getStatus());
146
147
        $eventDispatcher->dispatch('prolong.event', $event);
148
149
        // sleep for a while (in order to execute scheduler in the time when closing transition should be applied without prolong.event fired)
150
        // and run scheduler with 1-sec runtime to check that closed transition is not executed due to prolongation
151
        usleep(0.5*1e6);
152
        $this->runScheduler(1);
153
        $clientEm->refresh($subject);
154
        self::assertEquals('sleeping', $subject->getStatus());
155
156
        // sleep for a while (some time we waste during waiting that scheduler finish his work so no need to wait so long)
157
        // and run scheduler with 1-sec runtime to check that closed transition is executed
158
        $this->runScheduler(1);
159
        $clientEm->refresh($subject);
160
        self::assertEquals('closed', $subject->getStatus());
161
    }
162
163
    protected function runScheduler($runtime = 1)
164
    {
165
        $schedulerCommand = new RunCommand();
166
        $this->runConsoleCommand(
167
            $schedulerCommand,
168
            [
169
                '--max-runtime' => $runtime,
170
                // set worker name explicitly in order to avoid errors caused by 50 characters name restrictions on
171
                // testing envs like travis
172
                '--worker-name' => uniqid("worker_")
173
            ]
174
        );
175
    }
176
177
    private function runConsoleCommand(Command $command, array $params = [])
178
    {
179
        $command->setApplication($this->app);
180
        // use CommandTester to simple command running
181
        $commandRunner = new CommandTester($command);
182
        return $commandRunner->execute($params);
183
    }
184
}