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

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.

src/Jobs/DoormanQueuedJobTask.php (7 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
namespace Symbiote\QueuedJobs\Jobs;
4
5
use AsyncPHP\Doorman\Cancellable;
6
use AsyncPHP\Doorman\Expires;
7
use AsyncPHP\Doorman\Process;
8
use AsyncPHP\Doorman\Task;
9
use InvalidArgumentException;
10
use Symbiote\QueuedJobs\DataObjects\QueuedJobDescriptor;
11
use Symbiote\QueuedJobs\Services\QueuedJob;
12
13
class DoormanQueuedJobTask implements Task, Expires, Process, Cancellable
14
{
15
    /**
16
     * @var int
17
     */
18
    protected $id;
19
20
    /**
21
     * @var QueuedJobDescriptor
22
     */
23
    protected $descriptor;
24
25
    /**
26
     * Reload descriptor from DB
27
     */
28
    protected function refreshDescriptor()
29
    {
30
        if ($this->descriptor) {
31
            $this->descriptor = QueuedJobDescriptor::get()->byID($this->descriptor->ID);
0 ignored issues
show
Documentation Bug introduced by
It seems like \Symbiote\QueuedJobs\Dat...($this->descriptor->ID) can also be of type object<SilverStripe\ORM\DataObject>. However, the property $descriptor is declared as type object<Symbiote\QueuedJo...ts\QueuedJobDescriptor>. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
32
        }
33
    }
34
35
    /**
36
     * @inheritdoc
37
     *
38
     * @return null|int
39
     */
40
    public function getId()
41
    {
42
        return $this->id;
43
    }
44
45
    /**
46
     * @inheritdoc
47
     *
48
     * @param int $id
49
     *
50
     * @return $this
51
     */
52
    public function setId($id)
53
    {
54
        $this->id = $id;
55
56
        return $this;
57
    }
58
59
    /**
60
     * @return QueuedJobDescriptor
61
     */
62
    public function getDescriptor()
63
    {
64
        return $this->descriptor;
65
    }
66
67
    /**
68
     * @param QueuedJobDescriptor $descriptor
69
     */
70
    public function __construct(QueuedJobDescriptor $descriptor)
71
    {
72
        $this->descriptor = $descriptor;
73
    }
74
75
    /**
76
     * @inheritdoc
77
     *
78
     * @return string
79
     */
80
    public function serialize()
81
    {
82
        return serialize(array(
83
            'descriptor' => $this->descriptor->ID,
84
        ));
85
    }
86
87
    /**
88
     * @inheritdoc
89
     *
90
     * @throws InvalidArgumentException
91
     * @param string
92
     */
93
    public function unserialize($serialized)
94
    {
95
        $data = unserialize($serialized);
96
97
        if (!isset($data['descriptor'])) {
98
            throw new InvalidArgumentException('Malformed data');
99
        }
100
101
        $descriptor = QueuedJobDescriptor::get()
102
            ->filter('ID', $data['descriptor'])
103
            ->first();
104
105
        if (!$descriptor) {
106
            throw new InvalidArgumentException('Descriptor not found');
107
        }
108
109
        $this->descriptor = $descriptor;
110
    }
111
112
    /**
113
     * @return string
114
     */
115
    public function getHandler()
116
    {
117
        return 'DoormanQueuedJobHandler';
118
    }
119
120
    /**
121
     * @return array
122
     */
123
    public function getData()
124
    {
125
        return array(
126
            'descriptor' => $this->descriptor,
127
        );
128
    }
129
130
    /**
131
     * @return bool
132
     */
133
    public function ignoresRules()
134
    {
135
        if ($this->descriptor->hasMethod('ignoreRules')) {
136
            return $this->descriptor->ignoreRules();
0 ignored issues
show
Documentation Bug introduced by
The method ignoreRules does not exist on object<Symbiote\QueuedJo...ts\QueuedJobDescriptor>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
137
        }
138
139
        return false;
140
    }
141
142
    /**
143
     * @return bool
144
     */
145
    public function stopsSiblings()
146
    {
147
        if ($this->descriptor->hasMethod('stopsSiblings')) {
148
            return $this->descriptor->stopsSiblings();
0 ignored issues
show
Documentation Bug introduced by
The method stopsSiblings does not exist on object<Symbiote\QueuedJo...ts\QueuedJobDescriptor>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
149
        }
150
151
        return false;
152
    }
153
154
    /**
155
     * @inheritdoc
156
     *
157
     * @return int
158
     */
159
    public function getExpiresIn()
160
    {
161
        if ($this->descriptor->hasMethod('getExpiresIn')) {
162
            return $this->descriptor->getExpiresIn();
0 ignored issues
show
Documentation Bug introduced by
The method getExpiresIn does not exist on object<Symbiote\QueuedJo...ts\QueuedJobDescriptor>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
163
        }
164
165
        return -1;
166
    }
167
168
    /**
169
     * @inheritdoc
170
     *
171
     * @param int $startedAt
172
     * @return bool
173
     */
174
    public function shouldExpire($startedAt)
175
    {
176
        if ($this->descriptor->hasMethod('shouldExpire')) {
177
            return $this->descriptor->shouldExpire($startedAt);
0 ignored issues
show
Documentation Bug introduced by
The method shouldExpire does not exist on object<Symbiote\QueuedJo...ts\QueuedJobDescriptor>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
178
        }
179
180
        return true;
181
    }
182
183
    /**
184
     * @inheritdoc
185
     *
186
     * @return bool
187
     */
188 View Code Duplication
    public function canRunTask()
0 ignored issues
show
This method seems to be duplicated in 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...
189
    {
190
        $this->refreshDescriptor();
191
        return in_array(
192
            $this->descriptor->JobStatus,
193
            array(
194
                QueuedJob::STATUS_NEW,
195
                QueuedJob::STATUS_INIT,
196
                QueuedJob::STATUS_WAIT
197
            )
198
        );
199
    }
200
201
    /**
202
     * @inheritdoc
203
     *
204
     * @return bool
205
     */
206 View Code Duplication
    public function isCancelled()
0 ignored issues
show
This method seems to be duplicated in 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...
207
    {
208
        $this->refreshDescriptor();
209
210
        // Treat completed jobs as cancelled when it comes to how Doorman handles picking up jobs to run
211
        $cancelledStates = [
212
            QueuedJob::STATUS_CANCELLED,
213
            QueuedJob::STATUS_COMPLETE,
214
        ];
215
216
        return in_array($this->descriptor->JobStatus, $cancelledStates, true);
217
    }
218
}
219