Issues (57)

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.

Service/GearmanCacheWrapper.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
/**
4
 * Gearman Bundle for Symfony2 / Symfony3
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 *
9
 * Feel free to edit as you please, and have fun.
10
 *
11
 * @author Marc Morera <[email protected]>
12
 */
13
14
namespace Mkk\GearmanBundle\Service;
15
16
use Doctrine\Common\Cache\Cache;
17
use Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface;
18
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
19
20
/**
21
 * Gearman cache loader class
22
 *
23
 * This class has responsability of loading all gearman data structure
24
 * and cache it if needed.
25
 *
26
 * Also provides this data to external services
27
 */
28
class GearmanCacheWrapper implements CacheClearerInterface, CacheWarmerInterface
29
{
30
    /**
31
     * @var GearmanParser
32
     *
33
     * Gearman file parser
34
     */
35
    private $gearmanParser;
36
37
    /**
38
     * @var Cache
39
     *
40
     * Cache instance
41
     */
42
    private $cache;
43
44
    /**
45
     * @var string
46
     *
47
     * Cache id
48
     */
49
    private $cacheId;
50
51
    /**
52
     * @var array
53
     *
54
     * WorkerCollection with all workers and jobs available
55
     */
56
    private $workerCollection;
57
58
    /**
59
     * Construct method
60
     *
61
     * @param GearmanParser $gearmanParser Gearman Parser
62
     * @param Cache         $cache         Cache instance
63
     * @param string        $cacheId       Cache id
64
     */
65 8
    public function __construct(
66
        GearmanParser $gearmanParser,
67
        Cache $cache,
68
        $cacheId
69
    )
70
    {
71 8
        $this->gearmanParser = $gearmanParser;
72 8
        $this->cache = $cache;
73 8
        $this->cacheId = $cacheId;
74 8
    }
75
76
    /**
77
     * Return gearman file parser
78
     *
79
     * @return GearmanParser
80
     */
81 3
    public function getGearmanParser()
82
    {
83 3
        return $this->gearmanParser;
84
    }
85
86
    /**
87
     * Return cache
88
     *
89
     * @return Cache Cache
90
     */
91 4
    public function getCache()
92
    {
93 4
        return $this->cache;
94
    }
95
96
    /**
97
     * Return cache id
98
     *
99
     * @return string Cache id
100
     */
101 4
    public function getCacheId()
102
    {
103 4
        return $this->cacheId;
104
    }
105
106
    /**
107
     * Return workerCollection
108
     *
109
     * @return array all available workers
110
     */
111 3
    public function getWorkers()
112
    {
113 3
        return $this->workerCollection;
114
    }
115
116
    /**
117
     * loads Gearman cache, only if is not loaded yet
118
     *
119
     * @param Cache  $cache   Cache instance
120
     * @param string $cacheId Cache id
121
     *
122
     * @return GearmanCacheWrapper self Object
123
     */
124 8
    public function load(Cache $cache, $cacheId)
125
    {
126 8
        if ($cache->contains($cacheId)) {
127
128
            /**
129
             * Cache contains gearman structure
130
             */
131 6
            $this->workerCollection = $cache->fetch($cacheId);
0 ignored issues
show
Documentation Bug introduced by
It seems like $cache->fetch($cacheId) of type * is incompatible with the declared type array of property $workerCollection.

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...
132
133
        } else {
134
135
            /**
136
             * Cache is empty.
137
             *
138
             * Full structure must be generated and cached
139
             */
140 3
            $this->workerCollection = $this
141 3
                ->getGearmanParser()
142 3
                ->load()
143 3
                ->toArray();
144
145 3
            $cache->save($cacheId, $this->workerCollection);
146
        }
147
148 8
        return $this;
149
    }
150
151
    /**
152
     * flush all cache
153
     *
154
     * @param Cache  $cache   Cache instance
155
     * @param string $cacheId Cache id
156
     *
157
     * @return GearmanCacheWrapper self Object
158
     */
159 2
    public function flush(Cache $cache, $cacheId)
160
    {
161 2
        $cache->delete($cacheId);
162
163 2
        return $this;
164
    }
165
166
    /**
167
     * Cache clear implementation
168
     *
169
     * @param string $cacheDir The cache directory
170
     *
171
     * @return GearmanCacheWrapper self Object
172
     */
173 2
    public function clear($cacheDir)
174
    {
175 2
        $this->flush($this->getCache(), $this->getCacheId());
176
177 2
        return $this;
178
    }
179
180
    /**
181
     * Warms up the cache.
182
     *
183
     * @param string $cacheDir The cache directory
184
     *
185
     * @return GearmanCacheWrapper self Object
186
     */
187 2
    public function warmUp($cacheDir)
188
    {
189 2
        $this->load($this->getCache(), $this->getCacheId());
190
191 2
        return $this;
192
    }
193
194
    /**
195
     * Checks whether this warmer is optional or not.
196
     *
197
     * Optional warmers can be ignored on certain conditions.
198
     *
199
     * A warmer should return true if the cache can be
200
     * generated incrementally and on-demand.
201
     *
202
     * As GearmanBundle loads cache incrementaly so is optional
203
     *
204
     * @return Boolean true if the warmer is optional, false otherwise
205
     */
206 1
    public function isOptional()
207
    {
208 1
        return true;
209
    }
210
}
211