Issues (211)

Security Analysis    not enabled

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/QueuedJobsAdminTest.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
use SilverStripe\Dev\FunctionalTest;
4
use SilverStripe\Forms\FieldList;
5
use Symbiote\QueuedJobs\Controllers\QueuedJobsAdmin;
6
use Symbiote\QueuedJobs\Jobs\PublishItemsJob;
7
8
/**
9
 * Tests for the QueuedJobsAdmin ModelAdmin clas
10
 *
11
 * @coversDefaultClass \Symbiote\QueuedJobs\Controllers\QueuedJobsAdmin
12
 * @package queuedjobs
13
 * @author  Robbie Averill <[email protected]>
14
 */
15
class QueuedJobsAdminTest extends FunctionalTest
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
16
{
17
    /**
18
     * {@inheritDoc}
19
     * @var string
20
     */
21
    // protected static $fixture_file = 'QueuedJobsAdminTest.yml';
0 ignored issues
show
Unused Code Comprehensibility introduced by
46% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
22
23
    /**
24
     * @var QueuedJobsAdmin
25
     */
26
    protected $admin;
27
28
    /**
29
     * Get a test class, and mock the job queue for it
30
     *
31
     * {@inheritDoc}
32
     */
33
    public function setUp()
34
    {
35
        parent::setUp();
36
        $this->admin = new QueuedJobsAdmin;
37
38
        // Compatible with both PHPUnit 3 and PHPUnit 5+
39
        $mockQueue = method_exists($this, 'createMock') ? $this->createMock('Symbiote\\QueuedJobs\\Services\\QueuedJobService') : $this->getMock('Symbiote\\QueuedJobs\\Services\\QueuedJobService');
40
        $this->admin->jobQueue = $mockQueue;
41
42
        $this->logInWithPermission('ADMIN');
43
        $this->admin->doInit();
44
    }
45
46
    /**
47
     * Ensure that the JobParams field is added as a Textarea
48
     */
49
    public function testConstructorParamsShouldBeATextarea()
50
    {
51
        $fields = $this->admin->getEditForm('foo', new FieldList)->Fields();
0 ignored issues
show
new \SilverStripe\Forms\FieldList() is of type object<SilverStripe\Forms\FieldList>, but the function expects a object<Symbiote\QueuedJo...rollers\FieldList>|null.

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...
52
        $this->assertInstanceOf('SilverStripe\\Forms\\TextareaField', $fields->fieldByName('JobParams'));
53
    }
54
55
    /**
56
     * Ensure that when a multi-line value is entered for JobParams, it is split by new line and each value
57
     * passed to the constructor of the JobType that is created by the reflection in createjob()
58
     *
59
     * @covers ::createjob
60
     */
61
    public function testCreateJobWithConstructorParams()
62
    {
63
        $this->admin->jobQueue
64
            ->expects($this->once())
65
            ->method('queueJob')
66
            ->with($this->callback(function ($job) {
67
                return $job instanceof PublishItemsJob && $job->rootID === 'foo123';
0 ignored issues
show
The property rootID does not exist on object<Symbiote\QueuedJobs\Jobs\PublishItemsJob>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
68
            }));
69
70
        $form = $this->admin->getEditForm('foo', new FieldList);
0 ignored issues
show
new \SilverStripe\Forms\FieldList() is of type object<SilverStripe\Forms\FieldList>, but the function expects a object<Symbiote\QueuedJo...rollers\FieldList>|null.

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...
71
        $form->Fields()->fieldByName('JobParams')->setValue(implode(PHP_EOL, ['foo123', 'bar']));
72
        $form->Fields()->fieldByName('JobType')->setValue(PublishItemsJob::class);
73
74
        $this->admin->createjob($form->getData(), $form);
75
    }
76
}
77