Issues (83)

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.

DependencyInjection/QueueExtension.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
namespace SfCod\QueueBundle\DependencyInjection;
4
5
use Psr\Log\LoggerInterface;
6
use SfCod\QueueBundle\Base\JobResolverInterface;
7
use SfCod\QueueBundle\Command\RetryCommand;
8
use SfCod\QueueBundle\Command\RunJobCommand;
9
use SfCod\QueueBundle\Command\WorkCommand;
10
use SfCod\QueueBundle\Failer\FailedJobProviderInterface;
11
use SfCod\QueueBundle\Handler\ExceptionHandler;
12
use SfCod\QueueBundle\Handler\ExceptionHandlerInterface;
13
use SfCod\QueueBundle\Service\JobProcess;
14
use SfCod\QueueBundle\Service\JobQueue;
15
use SfCod\QueueBundle\Service\JobResolver;
16
use SfCod\QueueBundle\Service\QueueManager;
17
use SfCod\QueueBundle\Worker\Worker;
18
use Symfony\Component\DependencyInjection\ContainerBuilder;
19
use Symfony\Component\DependencyInjection\Definition;
20
use Symfony\Component\DependencyInjection\Reference;
21
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
22
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
23
24
/**
25
 * Class SfcodQueueExtension
26
 *
27
 * @author Alexey Orlov <[email protected]>
28
 * @author Virchenko Maksim <[email protected]>
29
 *
30
 * @package SfCod\QueueBundle\DependencyInjection
31
 */
32
class QueueExtension extends Extension
33
{
34
    /**
35
     * Loads a specific configuration.
36
     *
37
     * @param array $config
38
     * @param ContainerBuilder $container
39
     *
40
     * @throws \ReflectionException
41
     */
42
    public function load(array $config, ContainerBuilder $container)
43
    {
44
        $configuration = new QueueConfiguration();
45
46
        $config = $this->processConfiguration($configuration, $config);
47
48
        $jobs = $this->grabJobs($config, $container);
0 ignored issues
show
Deprecated Code introduced by
The method SfCod\QueueBundle\Depend...ueExtension::grabJobs() has been deprecated with message: will be removed some day, use services with tag "sfcod.jobqueue.job"

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
49
        foreach ($jobs as $job) {
50
            $definition = new Definition($job);
51
            $definition
52
                ->setAutowired(true)
53
                ->setAutoconfigured(true)
54
                ->setPublic(true)
55
                ->addTag('sfcod.jobqueue.job');
56
            $container->setDefinition($job, $definition);
57
        }
58
59
        $this->createJobQueue($config, $container);
60
        $this->createWorker($config, $container);
61
        $this->createJobProcess($config, $container);
62
        $this->createCommands($config, $container);
63
        $this->createManager($config, $container);
64
    }
65
66
    /**
67
     * Get extension alias
68
     *
69
     * @return string
70
     */
71
    public function getAlias()
72
    {
73
        return 'sfcod_queue';
74
    }
75
76
    /**
77
     * @deprecated will be removed some day, use services with tag "sfcod.jobqueue.job"
78
     *
79
     * @param array $config
80
     * @param ContainerBuilder $container
81
     *
82
     * @return array
83
     */
84
    private function grabJobs(array $config, ContainerBuilder $container): array
85
    {
86
        $jobs = [];
87
        foreach ($config['namespaces'] as $key => $namespace) {
88
            $alias = $container->getParameter('kernel.root_dir') . '/../' . str_replace('\\', DIRECTORY_SEPARATOR, trim($namespace, '\\'));
89
90
            foreach (glob(sprintf('%s/**.php', $alias)) as $file) {
91
                $className = sprintf('%s\%s', $namespace, basename($file, '.php'));
92
                if (method_exists($className, 'fire')) {
93
                    $jobs[] = $className;
94
                }
95
            }
96
        }
97
98
        return $jobs;
99
    }
100
101
    /**
102
     * Create command
103
     *
104
     * @param array $config
105
     * @param ContainerBuilder $container
106
     */
107
    private function createCommands(array $config, ContainerBuilder $container)
0 ignored issues
show
The parameter $config is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
108
    {
109
        $work = new Definition(WorkCommand::class);
110
        $work->setArguments([
111
            new Reference(Worker::class),
112
        ]);
113
        $work->addTag('console.command');
114
115
        $retry = new Definition(RetryCommand::class);
116
        $retry->setArguments([
117
            new Reference(JobQueue::class),
118
            new Reference(FailedJobProviderInterface::class),
119
        ]);
120
        $retry->addTag('console.command');
121
122
        $runJob = new Definition(RunJobCommand::class);
123
        $runJob->setArguments([
124
            new Reference(Worker::class),
125
        ]);
126
        $runJob->addTag('console.command');
127
128
        $container->addDefinitions([
129
            WorkCommand::class => $work,
130
            RetryCommand::class => $retry,
131
            RunJobCommand::class => $runJob,
132
        ]);
133
    }
134
135
    /**
136
     * Create queue manager
137
     *
138
     * @param array $config
139
     * @param ContainerBuilder $container
140
     *
141
     * @throws \Exception
142
     */
143
    private function createManager(array $config, ContainerBuilder $container)
144
    {
145
        $resolver = new Definition(JobResolverInterface::class);
146
        $resolver->setClass(JobResolver::class);
147
148
        $manager = new Definition(QueueManager::class);
149
150
        foreach ($config['drivers'] as $name => $service) {
151
            $manager->addMethodCall('addConnector', [
152
                $name,
153
                new Reference(ltrim($service, '@')),
154
            ]);
155
        }
156
157
        foreach ($config['connections'] as $name => $params) {
158
            $manager->addMethodCall('addConnection', [
159
                $params,
160
                $name,
161
            ]);
162
        }
163
164
        $container->addDefinitions([
165
            JobResolverInterface::class => $resolver,
166
            QueueManager::class => $manager,
167
        ]);
168
    }
169
170
    /**
171
     * Create job queue
172
     *
173
     * @param array $config
174
     * @param ContainerBuilder $container
175
     */
176
    private function createJobQueue(array $config, ContainerBuilder $container)
0 ignored issues
show
The parameter $config is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
177
    {
178
        $jobQueue = new Definition(JobQueue::class);
179
        $jobQueue->setPublic(true);
180
        $jobQueue->setArguments([
181
            new Reference(QueueManager::class),
182
        ]);
183
184
        $container->setDefinition(JobQueue::class, $jobQueue);
185
    }
186
187
    /**
188
     * Create worker
189
     *
190
     * @param array $config
191
     * @param ContainerBuilder $container
192
     */
193
    private function createWorker(array $config, ContainerBuilder $container)
0 ignored issues
show
The parameter $config is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
194
    {
195
        $worker = new Definition(Worker::class);
196
        $worker
197
            ->setArguments([
198
                new Reference(QueueManager::class),
199
                new Reference(JobProcess::class),
200
                new Reference(FailedJobProviderInterface::class),
201
                new Reference(ExceptionHandlerInterface::class),
202
                new Reference(EventDispatcherInterface::class),
203
            ]);
204
205
        $exceptionHandler = new Definition(ExceptionHandlerInterface::class);
206
        $exceptionHandler
207
            ->setClass(ExceptionHandler::class)
208
            ->setArguments([
209
                new Reference(LoggerInterface::class),
210
            ]);
211
212
        $container->addDefinitions([
213
            Worker::class => $worker,
214
            ExceptionHandlerInterface::class => $exceptionHandler,
215
        ]);
216
    }
217
218
    /**
219
     * Create job process
220
     *
221
     * @param array $config
222
     * @param ContainerBuilder $container
223
     */
224
    private function createJobProcess(array $config, ContainerBuilder $container)
0 ignored issues
show
The parameter $config is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
225
    {
226
        $jobProcess = new Definition(JobProcess::class);
227
        $jobProcess->setArguments([
228
            'console',
229
            sprintf('%s/bin', $container->getParameter('kernel.project_dir')),
230
            $container->getParameter('kernel.environment'),
231
        ]);
232
233
        $container->setDefinition(JobProcess::class, $jobProcess);
234
    }
235
}
236