Issues (25)

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.

src/JobManager.php (2 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
namespace Workana\AsyncJobs;
3
4
use Bernard\Driver;
5
use Bernard\Serializer;
6
use Bernard\QueueFactory\PersistentFactory;
7
use Interop\Container\ContainerInterface;
8
use Symfony\Component\EventDispatcher\EventDispatcher;
9
use Normalt\Normalizer\AggregateNormalizer;
10
use Workana\AsyncJobs\Dispatcher\AsyncJobDispatcher;
11
use Bernard\Normalizer\EnvelopeNormalizer;
12
use Workana\AsyncJobs\Doctrine\QueueableEntityNormalizer;
13
use Workana\AsyncJobs\Normalizer\AsyncActionNormalizer;
14
use Workana\AsyncJobs\Normalizer\ParameterNormalizer;
15
use Workana\AsyncJobs\Normalizer\ScalarNormalizer;
16
use Workana\AsyncJobs\Normalizer\SerializableEventNormalizer;
17
18
/**
19
 * Job Manager
20
 *
21
 * @author Carlos Frutos <[email protected]>
22
 */
23
class JobManager
24
{
25
    /**
26
     * @var Driver
27
     */
28
    private $driver;
29
30
    /**
31
     * @var Configuration
32
     */
33
    private $config;
34
35
    /**
36
     * @var ContainerInterface
37
     */
38
    private $container;
39
40
    /**
41
     * @var EventDispatcherInterface
42
     */
43
    private $eventDispatcher;
44
45
    /**
46
     * @var Bernard\QueueFactory
47
     */
48
    private $queueFactory;
49
50
    /**
51
     * @var Bernard\Router
52
     */
53
    private $router;
54
55
    /**
56
     * @var JobDispatcher
57
     */
58
    private $jobDispatcher;
59
60
    /**
61
     * Creates a new job manager
62
     *
63
     * @param Configuration $config
64
     * @param ContainerInterface $container
65
     */
66
    public function __construct(Configuration $config, ContainerInterface $container)
67
    {
68
        $this->driver = $container->get($config->getDriverClass());
69
        $this->config = $config;
70
        $this->container = $container;
71
        $this->eventDispatcher = new EventDispatcher();
0 ignored issues
show
Documentation Bug introduced by
It seems like new \Symfony\Component\E...tcher\EventDispatcher() of type object<Symfony\Component...atcher\EventDispatcher> is incompatible with the declared type object<Workana\AsyncJobs...entDispatcherInterface> of property $eventDispatcher.

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...
72
73
        $serializer = $this->createSerializer();
74
        $this->queueFactory = new PersistentFactory($this->driver, $serializer);
0 ignored issues
show
Documentation Bug introduced by
It seems like new \Bernard\QueueFactor...s->driver, $serializer) of type object<Bernard\QueueFactory\PersistentFactory> is incompatible with the declared type object<Workana\AsyncJobs\Bernard\QueueFactory> of property $queueFactory.

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...
75
76
        $this->router = $this->container->get($config->getRouterClass());
77
        $this->jobDispatcher = $this->createDispatcher();
78
    }
79
80
    /**
81
     * @return JobDispatcher
82
     */
83
    private function createDispatcher()
84
    {
85
        if ($this->config->isSync()) {
86
            throw new \Exception('Not implemented yed: sync mode');
87
        } else {
88
            return new AsyncJobDispatcher($this);
89
        }
90
    }
91
92
    /**
93
     * Creates serializer based on declared normalizers
94
     *
95
     * @return Serializer
96
     */
97
    private function createSerializer()
98
    {
99
        $normalizerClasses = array_merge([
100
            EnvelopeNormalizer::class,
101
            SerializableEventNormalizer::class,
102
            AsyncActionNormalizer::class,
103
            ParameterNormalizer::class,
104
            ScalarNormalizer::class
105
        ], $this->config->getNormalizerClasses());
106
107
        if ($this->config->isUsingDoctrine()) {
108
            $normalizerClasses[] = QueueableEntityNormalizer::class;
109
        }
110
111
        $normalizers = array_map([$this->container, 'get'], $normalizerClasses);
112
        $aggregate = new AggregateNormalizer($normalizers);
113
114
        return new Serializer($aggregate);
115
    }
116
117
    /**
118
     * Creates a new worker builder
119
     *
120
     * @return WorkerBuilder
121
     */
122
    public function createWorkerBuilder()
123
    {
124
        return new WorkerBuilder($this);
125
    }
126
127
    /**
128
     * Dispatch a job
129
     */
130
    public function dispatch(Job $job)
131
    {
132
        $this->jobDispatcher->dispatch($job);
133
    }
134
135
    /**
136
     * @return Configuration
137
     */
138
    public function getConfiguration()
139
    {
140
        return $this->config;
141
    }
142
143
    /**
144
     * Get driver
145
     *
146
     * @return Driver
147
     */
148
    public function getDriver()
149
    {
150
        return $this->driver;
151
    }
152
153
    /**
154
     * @return ContainerInterface
155
     */
156
    public function getContainer()
157
    {
158
        return $this->container;
159
    }
160
161
    /**
162
     * @return \Symfony\Component\EventDispatcher\EventDispatcherInterface
163
     */
164
    public function getEventDispatcher()
165
    {
166
        return $this->eventDispatcher;
167
    }
168
169
    /**
170
     * @return \Bernard\QueueFactory
171
     */
172
    public function getQueueFactory()
173
    {
174
        return $this->queueFactory;
175
    }
176
177
    /**
178
     * @return \Bernard\Router
179
     */
180
    public function getRouter()
181
    {
182
        return $this->router;
183
    }
184
}