Issues (10)

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/traits/CollectionTrait.php (1 issue)

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 flipbox\queue\jobs\traits;
4
5
use craft\helpers\ArrayHelper;
6
use flipbox\queue\helpers\JobHelper;
7
use flipbox\queue\jobs\JobInterface;
8
use yii\base\Exception;
9
10
trait CollectionTrait
11
{
12
13
    use JobTrait;
14
15
    /**
16
     * @var JobInterface[]
17
     */
18
    protected $jobs;
19
20
    /**
21
     * @param string $class
22
     * @return array
23
     */
24
    protected function jobConfig(string $class): array
25
    {
26
        return [
27
            'class' => $class
28
        ];
29
    }
30
31
    /**
32
     * @param array $jobs
33
     * @return static
34
     */
35
    public function setJobs(array $jobs = [])
36
    {
37
        $this->jobs = null;
0 ignored issues
show
Documentation Bug introduced by
It seems like null of type null is incompatible with the declared type array<integer,object<fli...eue\jobs\JobInterface>> of property $jobs.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
38
39
        return $this->addJobs($jobs);
40
    }
41
42
    /**
43
     * @param array $jobs
44
     * @return static
45
     */
46
    protected function addJobs(array $jobs = [])
47
    {
48
        foreach ($jobs as $key => $job) {
49
            if (is_numeric($key) || empty($key)) {
50
                $key = null;
51
            }
52
            $this->addJob($key, $job);
53
        }
54
55
        return $this;
56
    }
57
58
    /**
59
     * @param $key
60
     * @param $job
61
     * @return static
62
     */
63
    public function addJob($key, $job)
64
    {
65
        if (is_string($job)) {
66
            $job = $this->jobConfig($job);
67
        }
68
69
        if (!$job instanceof JobInterface) {
70
            $job = JobHelper::create($job);
71
        }
72
73
        $this->jobs[$key] = $job;
74
75
        return $this;
76
    }
77
78
    /**
79
     * @return JobInterface[]
80
     */
81
    public function getJobs()
82
    {
83
        return $this->jobs;
84
    }
85
86
    /**
87
     * @param $identifier
88
     * @return JobInterface
89
     */
90
    public function findJob($identifier)
91
    {
92
        return ArrayHelper::getValue($this->jobs, $identifier);
93
    }
94
95
    /**
96
     * @param $identifier
97
     * @return JobInterface
98
     * @throws Exception
99
     */
100
    public function getJob($identifier)
101
    {
102
        if (!$job = $this->findJob($identifier)) {
103
            throw new Exception("Job not found.");
104
        }
105
106
        return $job;
107
    }
108
109
    /**
110
     * @param $identifier
111
     * @param array $config
112
     * @return JobInterface
113
     */
114
    public function createJob($identifier, array $config = [])
115
    {
116
        $config['class'] = $this->getJob($identifier);
117
118
        return JobHelper::create($config);
119
    }
120
}
121