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/Console/QueueCreatorCommand.php (2 issues)

Labels
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\Console;
15
16
use Illuminate\Console\Command;
17
use Illuminate\Database\DatabaseManager;
18
use Symfony\Component\Console\Input\InputOption;
19
use Symfony\Component\Console\Input\InputArgument;
20
use Ytake\LaravelCouchbase\Database\CouchbaseConnection;
21
22
/**
23
 * Class QueueCreatorCommand
24
 *
25
 * @codeCoverageIgnore
26
 *
27
 * @author Yuuki Takezawa<[email protected]>
28
 */
29
class QueueCreatorCommand extends Command
30
{
31
    /** @var string */
32
    protected $name = 'couchbase:create-queue-index';
33
34
    /** @var string */
35
    protected $description = 'Create primary index, secondary indexes for the queue jobs couchbase bucket.';
36
37
    /** @var DatabaseManager */
38
    protected $databaseManager;
39
40
    /** @var string */
41
    protected $defaultDatabase = 'couchbase';
42
43
    const PRIMARY_KEY = '#job_queue_primary';
44
45
    /** @var array<string, string[]> */
46
    protected $secondaryIndexes = [
47
        'idx_job_queue'       => [ // index name
48
            'queue', // fields
49
        ],
50
        'idx_job_identifier'  => [
51
            'id',
52
        ],
53
        'idx_job_queue_cover' => [
54
            'queue',
55
            'reserved_at',
56
            'available_at',
57
            'id',
58
        ],
59
    ];
60
61
    /**
62
     * IndexFinderCommand constructor.
63
     *
64
     * @param DatabaseManager $databaseManager
65
     */
66
    public function __construct(DatabaseManager $databaseManager)
67
    {
68
        $this->databaseManager = $databaseManager;
69
        parent::__construct();
70
    }
71
72
    /**
73
     * @return string[]
74
     */
75
    protected function getArguments()
76
    {
77
        return [
78
            ['bucket', InputArgument::OPTIONAL, 'Represents a bucket connection.', 'jobs'],
79
        ];
80
    }
81
82
    /**
83
     * Get the console command options.
84
     *
85
     * @return array
86
     */
87
    protected function getOptions()
88
    {
89
        return [
90
            ['database', 'db', InputOption::VALUE_REQUIRED, 'The database connection to use.', $this->defaultDatabase],
91
            [
92
                'ignore',
93
                'ig',
94
                InputOption::VALUE_NONE,
95
                'if a primary index already exists, an exception will be thrown unless this is set to true.',
96
            ],
97
            [
98
                'defer',
99
                null,
100
                InputOption::VALUE_NONE,
101
                'true to defer building of the index until buildN1qlDeferredIndexes()}is called (or a direct call to the corresponding query service API)',
102
            ],
103
        ];
104
    }
105
106
    /**
107
     * Execute the console command
108
     */
109
    public function handle()
110
    {
111
        /** @var \Illuminate\Database\Connection|CouchbaseConnection $connection */
112
        $connection = $this->databaseManager->connection($this->option('database'));
0 ignored issues
show
It seems like $this->option('database') targeting Illuminate\Console\Command::option() can also be of type array; however, Illuminate\Database\DatabaseManager::connection() does only seem to accept string|null, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
113
        if ($connection instanceof CouchbaseConnection) {
114
            $bucket = $connection->openBucket($this->argument('bucket'));
0 ignored issues
show
It seems like $this->argument('bucket') targeting Illuminate\Console\Command::argument() can also be of type array; however, Ytake\LaravelCouchbase\D...onnection::openBucket() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
115
            $primary = self::PRIMARY_KEY;
116
            try {
117
                $bucket->manager()->createN1qlPrimaryIndex(
118
                    $primary,
119
                    $this->option('ignore'),
120
                    $this->option('defer')
121
                );
122
                $this->info("created PRIMARY INDEX [{$primary}] for [{$this->argument('bucket')}] bucket.");
123
            } catch (\Exception $e) {
124
                $this->error($e->getMessage());
125
            }
126
            foreach ($this->secondaryIndexes as $name => $fields) {
127
                try {
128
                    $bucket->manager()->createN1qlIndex(
129
                        $name,
130
                        $fields,
131
                        '',
132
                        $this->option('ignore'),
133
                        $this->option('defer')
134
                    );
135
                    $field = implode(",", $fields);
136
                    $this->info("created SECONDARY INDEX [{$name}] fields [{$field}], for [{$this->argument('bucket')}] bucket.");
137
                } catch (\Exception $e) {
138
                    $this->error($e->getMessage());
139
                }
140
            }
141
        }
142
143
        return;
144
    }
145
}
146