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/Schedule/ActionSchedulerTest.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
 * 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   09.08.16
10
 */
11
12
namespace Gtt\Bundle\WorkflowExtensionsBundle\Tests\Schedule;
13
14
use Carbon\Carbon;
15
use Doctrine\Common\Persistence\ObjectManager;
16
use Gtt\Bundle\WorkflowExtensionsBundle\Command\ExecuteActionCommand;
17
use Gtt\Bundle\WorkflowExtensionsBundle\Entity\Repository\ScheduledJobRepository;
18
use Gtt\Bundle\WorkflowExtensionsBundle\Entity\ScheduledJob;
19
use Gtt\Bundle\WorkflowExtensionsBundle\Schedule\ActionScheduler;
20
use Gtt\Bundle\WorkflowExtensionsBundle\Schedule\ValueObject\ScheduledAction;
21
use Gtt\Bundle\WorkflowExtensionsBundle\WorkflowContext;
22
use JMS\JobQueueBundle\Entity\Job;
23
use Psr\Log\LoggerInterface;
24
use Symfony\Component\Workflow\Workflow;
25
26
class ActionSchedulerTest extends \PHPUnit_Framework_TestCase
27
{
28
    public function tearDown()
29
    {
30
        parent::tearDown();
31
        Carbon::setTestNow();
32
    }
33
34
    /**
35
     * @dataProvider scheduledActionProvider
36
     */
37
    public function testSchedulerSchedulesCorrectJob(ScheduledAction $action, $alreadyScheduled)
38
    {
39
        /** @var WorkflowContext $workflowContext */
40
        list($workflowContext, $repository, $em) = $this->setupSchedulerContext();
41
42
        Carbon::setTestNow(Carbon::now());
43
        $now             = Carbon::now();
44
45
        $executeJobAfter = clone $now;
46
        $executeJobAfter->add($action->getOffset());
47
48
        if ($action->isReschedulable()) {
49
            if ($alreadyScheduled) {
50
                // expecting rescheduling
51
                $actionJob    = new Job('command', ['--some' => 'args']);
52
                $scheduledJob = new ScheduledJob($actionJob);
53
54
                $expectedActionJob = clone $actionJob;
55
                $expectedActionJob->setExecuteAfter($executeJobAfter);
56
57
                $repository->expects(self::once())->method('findScheduledJobToReschedule')->willReturn($scheduledJob);
58
                $em->expects(self::once())->method('persist')->with(self::equalTo($expectedActionJob));
59 View Code Duplication
            } else {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
60
                // expecting the new one
61
                $repository->expects(self::once())->method('findScheduledJobToReschedule')->willReturn(null);
62
                $this->configureEmToExpectNewJobCreation($em, $action, $workflowContext, $executeJobAfter);
63
            }
64 View Code Duplication
        } else {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
65
            // non-reschedulable action - expecting creation of the new job
66
            $repository->expects(self::never())->method('findScheduledJobToReschedule')->willReturn(null);
67
            $this->configureEmToExpectNewJobCreation($em, $action, $workflowContext, $executeJobAfter);
68
        }
69
70
        $scheduler = new ActionScheduler($em, $this->getMock(LoggerInterface::class));
71
        $scheduler->scheduleAction($workflowContext, $action);
72
    }
73
74
    public function scheduledActionProvider()
75
    {
76
        return [
77
            [new ScheduledAction('a1', [], 'PT1S'), true],
78
            [new ScheduledAction('a1', [], 'PT1S'), false],
79
            [new ScheduledAction('a1', [], 'PT1S', true), true],
80
            [new ScheduledAction('a1', [], 'PT1S', true), false]
81
        ];
82
    }
83
84
    private function configureEmToExpectNewJobCreation(ObjectManager $em, ScheduledAction $action, WorkflowContext $workflowContext, \DateTime $executeJobAfter)
85
    {
86
        $expectedActionJob = new Job(
87
            ExecuteActionCommand::COMMAND_NAME,
88
            [
89
                '--action='       . $action->getName(),
90
                '--arguments='    . json_encode($action->getArguments()),
91
                '--workflow='     . $workflowContext->getWorkflow()->getName(),
92
                '--subjectClass=' . get_class($workflowContext->getSubject()),
93
                '--subjectId='    . $workflowContext->getSubjectId()
94
            ]
95
        );
96
97
        $expectedActionJob->setExecuteAfter($executeJobAfter);
98
99
        /** @var $em \PHPUnit_Framework_MockObject_MockObject|ObjectManager */
100
        $em->expects(self::exactly(2))->method('persist')->withConsecutive(
0 ignored issues
show
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Doctrine\Common\Persistence\ObjectManager.

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...
101
            self::equalTo($expectedActionJob),
102
            self::equalTo(new ScheduledJob($expectedActionJob, $action->isReschedulable()))
103
        );
104
    }
105
106
    /**
107
     * @return array
108
     */
109
    private function setupSchedulerContext()
110
    {
111
        $subject = new \StdClass();
112
        $subjectId = '1';
113
114
        $workflow = $this->getMockBuilder(Workflow::class)->disableOriginalConstructor()->getMock();
115
        $workflow->expects(self::any())->method('getName')->willReturn('w1');
116
117
        $workflowContext = new WorkflowContext($workflow, $subject, $subjectId);
118
119
        $repository = $this->getMockBuilder(ScheduledJobRepository::class)->disableOriginalConstructor()->getMock();
120
121
        $em = $this->getMockBuilder(ObjectManager::class)->disableOriginalConstructor()->getMock();
122
        $em->expects(self::once())->method('getRepository')->with(ScheduledJob::class)->willReturn($repository);
123
124
        return [$workflowContext, $repository, $em];
125
    }
126
}
127