Issues (50)

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

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
declare(strict_types=1);
3
4
/**
5
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
8
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
9
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
10
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
11
 * THE SOFTWARE.
12
 */
13
14
namespace Ytake\LaravelCouchbase;
15
16
use Illuminate\Cache\Repository;
17
use Illuminate\Database\DatabaseManager;
18
use Illuminate\Queue\QueueManager;
19
use Illuminate\Session\CacheBasedSessionHandler;
20
use Illuminate\Support\ServiceProvider;
21
use Ytake\LaravelCouchbase\Cache\CouchbaseStore;
22
use Ytake\LaravelCouchbase\Cache\MemcachedBucketStore;
23
use Ytake\LaravelCouchbase\Database\Connectable;
24
use Ytake\LaravelCouchbase\Database\CouchbaseConnection;
25
use Ytake\LaravelCouchbase\Database\CouchbaseConnector;
26
use Ytake\LaravelCouchbase\Queue\CouchbaseConnector as QueueConnector;
27
28
/**
29
 * Class CouchbaseServiceProvider.
30
 *
31
 * @codeCoverageIgnore
32
 *
33
 * @author Yuuki Takezawa<[email protected]>
34
 */
35
class CouchbaseServiceProvider extends ServiceProvider
36
{
37
    /**
38
     * Bootstrap  application services.
39
     */
40
    public function boot()
41
    {
42
        $this->registerCouchbaseBucketCacheDriver();
43
        $this->registerMemcachedBucketCacheDriver();
44
        $this->registerCouchbaseQueueDriver();
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    public function register()
51
    {
52
        $configPath = __DIR__ . '/config/couchbase.php';
53
        $this->mergeConfigFrom($configPath, 'couchbase');
54
        $this->publishes([$configPath => config_path('couchbase.php')], 'couchbase');
55
        $this->registerCouchbaseComponent();
56
    }
57
58
    protected function registerCouchbaseComponent()
59
    {
60
        $this->app->singleton(Connectable::class, function () {
61
            return new CouchbaseConnector();
62
        });
63
64
        $this->app->singleton('couchbase.memcached.connector', function () {
65
            return new MemcachedConnector();
66
        });
67
68
        // add couchbase session driver
69
        $this->app['session']->extend('couchbase', function ($app) {
70
            $minutes = $app['config']['session.lifetime'];
71
72
            return new CacheBasedSessionHandler(clone $this->app['cache']->driver('couchbase'), $minutes);
73
        });
74
75
        // add couchbase session driver
76
        $this->app['session']->extend('couchbase-memcached', function ($app) {
77
            $minutes = $app['config']['session.lifetime'];
78
79
            return new CacheBasedSessionHandler(clone $this->app['cache']->driver('couchbase-memcached'), $minutes);
80
        });
81
82
        // add couchbase extension
83
        $this->app['db']->extend('couchbase', function (array $config, $name) {
84
            /* @var \Couchbase\Cluster $cluster */
85
            return new CouchbaseConnection($config, $name);
86
        });
87
    }
88
89
    /**
90
     * register 'couchbase' cache driver.
91
     * for bucket type couchbase.
92
     */
93
    protected function registerCouchbaseBucketCacheDriver(): void
94
    {
95
        $this->app['cache']->extend('couchbase', function ($app, $config) {
96
            /** @var \Couchbase\Cluster $cluster */
97
            $cluster = $app['db']->connection($config['driver'])->getCouchbase();
98
            $password = (isset($config['bucket_password'])) ? $config['bucket_password'] : '';
99
100
            return new Repository(
101
                new CouchbaseStore(
102
                    $cluster,
103
                    $config['bucket'],
104
                    $password,
105
                    $app['config']->get('cache.prefix')
106
                )
107
            );
108
        });
109
    }
110
111
    /**
112
     * register 'couchbase' cache driver.
113
     * for bucket type memcached.
114
     */
115
    protected function registerMemcachedBucketCacheDriver(): void
116
    {
117
        $this->app['cache']->extend('couchbase-memcached', function ($app, $config) {
118
            $prefix = $app['config']['cache.prefix'];
119
            $credential = $config['sasl'] ?? [];
120
            $memcachedBucket = $this->app['couchbase.memcached.connector']
121
                ->connect($config['servers']);
122
123
            return new Repository(
124
                new MemcachedBucketStore(
0 ignored issues
show
Deprecated Code introduced by
The class Ytake\LaravelCouchbase\Cache\MemcachedBucketStore has been deprecated.

This class, trait or interface has been deprecated.

Loading history...
125
                    $memcachedBucket,
126
                    strval($prefix),
127
                    $config['servers'],
128
                    $credential
129
                )
130
            );
131
        });
132
    }
133
134
    /**
135
     * register custom queue 'couchbase' driver
136
     */
137
    protected function registerCouchbaseQueueDriver(): void
138
    {
139
        /** @var QueueManager $queueManager */
140
        $queueManager = $this->app['queue'];
141
        $queueManager->addConnector('couchbase', function () {
142
            /** @var DatabaseManager $databaseManager */
143
            $databaseManager = $this->app['db'];
144
145
            return new QueueConnector($databaseManager);
146
        });
147
    }
148
}
149