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/Schema/Blueprint.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
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
5
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
6
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
7
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
8
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
9
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
10
 * THE SOFTWARE.
11
 */
12
13
namespace Ytake\LaravelCouchbase\Schema;
14
15
use Ytake\LaravelCouchbase\Database\CouchbaseConnection;
16
17
/**
18
 * Class Blueprint
19
 *
20
 * @author Yuuki Takezawa<[email protected]>
21
 */
22
class Blueprint extends \Illuminate\Database\Schema\Blueprint
23
{
24
    use NotSupportedTrait;
25
26
    /** @var  CouchbaseConnection */
27
    protected $connection;
28
29
    /** @var string[] */
30
    protected $options = [
31
        'bucketType'   => 'couchbase',
32
        'saslPassword' => '',
33
        'flushEnabled' => true,
34
    ];
35
36
    /**
37
     * @param CouchbaseConnection $connection
38
     */
39 8
    public function connector(CouchbaseConnection $connection)
40
    {
41 8
        $this->connection = $connection;
42 8
    }
43
44
    /**
45
     * @param array $options
46
     */
47
    public function setOptions(array $options)
48
    {
49
        $this->options = array_merge($this->options, $options);
0 ignored issues
show
Documentation Bug introduced by
It seems like array_merge($this->options, $options) of type array is incompatible with the declared type array<integer,string> of property $options.

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...
50
    }
51
52
    /**
53
     * @return bool
54
     */
55 8
    public function create()
56
    {
57 8
        $this->connection->manager()->createBucket($this->table, $this->options);
58 8
    }
59
60
    /**
61
     * {@inheritdoc}
62
     */
63
    public function drop()
64
    {
65
        $this->connection->manager()->removeBucket($this->table);
66
    }
67
68
    /**
69
     * drop for N1QL primary index
70
     *
71
     * @param string $index
72
     * @param bool   $ignoreIfNotExist
73
     *
74
     * @return mixed
75
     */
76 4
    public function dropPrimary($index = null, $ignoreIfNotExist = false)
77
    {
78 4
        $this->connection->openBucket($this->getTable())
79 4
            ->manager()->dropN1qlPrimaryIndex($this->detectIndexName($index), $ignoreIfNotExist);
80 2
    }
81
82
    /**
83
     * drop for N1QL secondary index
84
     *
85
     * @param string $index
86
     * @param bool   $ignoreIfNotExist
87
     *
88
     * @return mixed
89
     */
90 4
    public function dropIndex($index, $ignoreIfNotExist = false)
91
    {
92 4
        $this->connection->openBucket($this->getTable())
93 4
            ->manager()->dropN1qlIndex($index, $ignoreIfNotExist);
94 2
    }
95
96
    /**
97
     * Specify the primary index for the current bucket.
98
     *
99
     * @param string|null $name
100
     * @param boolean     $ignoreIfExist  if a primary index already exists, an exception will be thrown unless this is
101
     *                                    set to true.
102
     * @param boolean     $defer          true to defer building of the index until buildN1qlDeferredIndexes()}is
103
     *                                    called (or a direct call to the corresponding query service API).
104
     */
105 8
    public function primaryIndex($name = null, $ignoreIfExist = false, $defer = false)
106
    {
107 8
        $this->connection->openBucket($this->getTable())
108 8
            ->manager()->createN1qlPrimaryIndex(
109 8
                $this->detectIndexName($name),
110 8
                $ignoreIfExist,
111 8
                $defer
112
            );
113 8
    }
114
115
    /**
116
     * Specify a secondary index for the current bucket.
117
     *
118
     * @param array   $columns            the JSON fields to index.
119
     * @param string  $name               the name of the index.
120
     * @param string  $whereClause        the WHERE clause of the index.
121
     * @param boolean $ignoreIfExist      if a secondary index already exists with that name, an exception will be
122
     *                                    thrown unless this is set to true.
123
     * @param boolean $defer              true to defer building of the index until buildN1qlDeferredIndexes() is
124
     *                                    called (or a direct call to the corresponding query service API).
125
     *
126
     * @return mixed
127
     */
128 4
    public function index($columns, $name = null, $whereClause = '', $ignoreIfExist = false, $defer = false)
129
    {
130 4
        $name = (is_null($name)) ? $this->getTable() . "_secondary_index" : $name;
131
132 4
        return $this->connection->openBucket($this->getTable())
133 4
            ->manager()->createN1qlIndex(
134 4
                $name,
135 4
                $columns,
136 4
                $whereClause,
137 4
                $ignoreIfExist,
138 4
                $defer
139
            );
140
    }
141
142
    /**
143
     * Get the table the blueprint describes.
144
     *
145
     * @return string
146
     */
147 8
    public function getTable()
148
    {
149 8
        return $this->table;
150
    }
151
152
    /**
153
     * @param $index
154
     *
155
     * @return string
156
     */
157 8
    protected function detectIndexName($index)
158
    {
159 8
        $index = (is_null($index)) ? "" : $index;
160
161 8
        return $index;
162
    }
163
}
164