Issues (24)

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/Jade/Provider/DoctrineCacheServiceProvider.php (3 issues)

Severity

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
 * This file is part of the jade/jade package.
5
 *
6
 * (c) Slince <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Jade\Provider;
13
14
use Doctrine\Common\Cache\ArrayCache;
15
use Doctrine\Common\Cache\RedisCache;
16
use Doctrine\Common\Cache\ApcuCache;
17
use Doctrine\Common\Cache\XcacheCache;
18
use Doctrine\Common\Cache\MemcachedCache;
19
use Doctrine\Common\Cache\FilesystemCache;
20
use Doctrine\Common\Cache\MongoDBCache;
21
use Jade\Container;
22
use Jade\ContainerInterface;
23
use Jade\ServiceProviderInterface;
24
25
class DoctrineCacheServiceProvider implements ServiceProviderInterface
26
{
27
    public function register(ContainerInterface $container)
28
    {
29
        $container['cache.default_options'] = [
30
            'driver'    => 'array',
31
            'namespace' => null,
32
        ];
33
34
        $container['caches.options.initializer'] = $container->protect(function () use ($container) {
35
            static $initialized = false;
36
37
            if ($initialized) {
38
                return;
39
            }
40
41
            $initialized = true;
42
43
            if (!isset($container['caches.options'])) {
44
                $container['caches.options'] = [
45
                    'default' => $container['cache.options'] ?? [],
46
                ];
47
            }
48
49
            $container['caches.options'] = array_map(function ($options) use ($container) {
50
                return array_replace($container['cache.default_options'], is_array($options)
51
                    ? $options
52
                    : ['driver' => $options]
53
                );
54
            }, $container['caches.options']);
55
56
            if (!isset($container['caches.default'])) {
57
                $container['caches.default'] = array_keys(
58
                    array_slice($container['caches.options'], 0, 1)
59
                )[0];
60
            }
61
        });
62
63
        $container['caches'] = function (ContainerInterface $container) {
64
            $container['caches.options.initializer']();
65
66
            $caches = new Container();
67
            foreach ($container['caches.options'] as $name => $options) {
68
                $caches[$name] = function () use ($container, $options) {
69
                    $cache = $container['cache_factory']($options['driver'], $options);
70
71
                    if (isset($options['namespace'])) {
72
                        $cache->setNamespace($options['namespace']);
73
                    }
74
75
                    return $cache;
76
                };
77
            }
78
79
            return $caches;
80
        };
81
82
        $container['cache_factory.filesystem'] = $container->protect(function ($options) {
83
            if (empty($options['cache_dir'])
84
                || false === is_dir($options['cache_dir'])
85
            ) {
86
                throw new \InvalidArgumentException(
87
                    'You must specify "cache_dir" for Filesystem.'
88
                );
89
            }
90
91
            return new FilesystemCache($options['cache_dir']);
92
        });
93
94
        $container['cache_factory.array'] = $container->protect(function ($options) {
0 ignored issues
show
The parameter $options 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...
95
            return new ArrayCache();
96
        });
97
98
        $container['cache_factory.apcu'] = $container->protect(function ($options) {
0 ignored issues
show
The parameter $options 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...
99
            return new ApcuCache();
100
        });
101
102
        $container['cache_factory.mongodb'] = $container->protect(function ($options) {
103
            if (empty($options['server'])
104
                || empty($options['name'])
105
                || empty($options['collection'])
106
            ) {
107
                throw new \InvalidArgumentException(
108
                    'You must specify "server", "name" and "collection" for MongoDB.'
109
                );
110
            }
111
112
            $client = new \MongoClient($options['server']);
113
            $db = new \MongoDB($client, $options['name']);
114
            $collection = new \MongoCollection($db, $options['collection']);
115
116
            return new MongoDBCache($collection);
117
        });
118
119
        $container['cache_factory.redis'] = $container->protect(function ($options) {
120
            if (empty($options['host']) || empty($options['port'])) {
121
                throw new \InvalidArgumentException('You must specify "host" and "port" for Redis.');
122
            }
123
124
            $redis = new \Redis();
125
            $redis->connect($options['host'], $options['port']);
126
127
            if (isset($options['password'])) {
128
                $redis->auth($options['password']);
129
            }
130
131
            $cache = new RedisCache();
132
            $cache->setRedis($redis);
133
134
            return $cache;
135
        });
136
137
        $container['cache_factory.xcache'] = $container->protect(function ($options) {
138
139
            if (empty($options['host']) || empty($options['port'])) {
140
                throw new \InvalidArgumentException('You must specify "host" and "port" for Memcached.');
141
            }
142
143
            $memcached = new \Memcached();
144
            $memcached->addServer($options['host'], $options['port']);
145
146
            $cache = new MemcachedCache();
147
            $cache->setMemcached($memcached);
148
149
            return $cache;
150
        });
151
152
        $container['cache_factory.xcache'] = $container->protect(function ($options) {
0 ignored issues
show
The parameter $options 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...
153
            return new XcacheCache();
154
        });
155
156
        $container['cache_factory'] = $container->protect(function ($driver, $options) use ($container) {
157
            if (isset($container['cache_factory.' . $driver])) {
158
                return $container['cache_factory.' . $driver]($options);
159
            }
160
161
            throw new \RuntimeException();
162
        });
163
164
        // shortcuts for the "first" cache
165
        $container['cache'] = function (Container $container) {
166
            $caches = $container['caches'];
167
168
            return $caches[$container['caches.default']];
169
        };
170
    }
171
}