GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (917)

Security Analysis    not enabled

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/Database/DatabaseManager.php (9 issues)

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
namespace Nip\Database;
4
5
use InvalidArgumentException;
6
use Nip\Application;
7
use Nip\Database\Connections\Connection;
8
use Nip\Database\Connections\ConnectionFactory;
9
use Nip_Helper_Arrays;
10
11
/**
12
 * Class DatabaseManager
13
 * @package Nip\Database
14
 */
15
class DatabaseManager
16
{
17
18
    /**
19
     * @var Application
20
     */
21
    protected $application;
22
23
    /**
24
     * The database connection factory instance.
25
     *
26
     * @var ConnectionFactory
27
     */
28
    protected $factory;
29
30
    protected $connections = [];
31
32
    /**
33
     * DatabaseManager constructor.
34
     * @param Application $application
35
     * @param ConnectionFactory $factory
36
     */
37
    public function __construct(Application $application, ConnectionFactory $factory)
38
    {
39
        $this->application = $application;
40
        $this->factory = $factory;
41
    }
42
43
    /**
44
     * Get a database connection instance.
45
     *
46
     * @param  string $name
47
     * @return Connection
48
     */
49
    public function connection($name = null)
50
    {
51
        list($database, $type) = $this->parseConnectionName($name);
52
        $name = $name ?: $database;
53
54
        // If we haven't created this connection, we'll create it based on the config
55
        // provided in the application. Once we've created the connections we will
56
        // set the "fetch mode" for PDO which determines the query return types.
57
        if (!isset($this->connections[$name])) {
58
            $this->connections[$name] = $this->configure(
59
                $connection = $this->makeConnection($name),
60
                $type
61
            );
62
        }
63
        return $this->connections[$name];
64
    }
65
66
    /**
67
     * Parse the connection into an array of the name and read / write type.
68
     *
69
     * @param  string $name
70
     * @return string
71
     */
72
    protected function parseConnectionName($name)
73
    {
74
        $name = $name ?: $this->getDefaultConnection();
75
        return $name;
76
    }
77
78
    /**
79
     * Get the default connection name.
80
     *
81
     * @return string
82
     */
83
    public function getDefaultConnection()
84
    {
85
        return $this->application->get('config')->get('database.default');
86
    }
87
88
    /**
89
     * Prepare the database connection instance.
90
     *
91
     * @param  Connection $connection
92
     * @param  string $type
93
     * @return Connection
94
     */
95
    protected function configure(Connection $connection, $type)
0 ignored issues
show
The parameter $type 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...
96
    {
97
//        $connection = $this->setPdoForType($connection, $type);
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
98
        // First we'll set the fetch mode and a few other dependencies of the database
99
        // connection. This method basically just configures and prepares it to get
100
        // used by the application. Once we're finished we'll return it back out.
0 ignored issues
show
Unused Code Comprehensibility introduced by
41% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
101
//        if ($this->app->bound('events')) {
102
//            $connection->setEventDispatcher($this->app['events']);
103
//        }
104
        // Here we'll set a reconnector callback. This reconnector can be any callable
105
        // so we will set a Closure to reconnect from this manager with the name of
106
        // the connection, which will allow us to reconnect from the connections.
0 ignored issues
show
Unused Code Comprehensibility introduced by
39% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
107
//        $connection->setReconnector(function ($connection) {
108
//            $this->reconnect($connection->getName());
109
//        });
110
        return $connection;
111
    }
112
113
    /**
114
     * Make the database connection instance.
115
     *
116
     * @param  string $name
117
     * @return Connection
118
     */
119
    protected function makeConnection($name)
120
    {
121
        $config = $this->configuration($name);
122
123
        // First we will check by the connection name to see if an extension has been
124
        // registered specifically for that connection. If it has we will call the
125
        // Closure and pass it the config allowing it to resolve the connection.
0 ignored issues
show
Unused Code Comprehensibility introduced by
42% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
126
//        if (isset($this->extensions[$name])) {
127
//            return call_user_func($this->extensions[$name], $config, $name);
128
//        }
129
130
        // Next we will check to see if an extension has been registered for a driver
131
        // and will call the Closure if so, which allows us to have a more generic
132
        // resolver for the drivers themselves which applies to all connections.
0 ignored issues
show
Unused Code Comprehensibility introduced by
46% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
133
//        if (isset($this->extensions[$driver = $config['driver']])) {
134
//            return call_user_func($this->extensions[$driver], $config, $name);
135
//        }
136
        return $this->factory->make($config, $name);
137
    }
138
139
    /**
140
     * Get the configuration for a connection.
141
     *
142
     * @param  string $name
143
     * @return array
144
     *
145
     * @throws \InvalidArgumentException
146
     */
147
    protected function configuration($name)
148
    {
149
        $name = $name ?: $this->getDefaultConnection();
150
151
        // To get the database connection configuration, we will just pull each of the
152
        // connection configurations and get the configurations for the given name.
153
        // If the configuration doesn't exist, we'll throw an exception and bail.
154
155
        $connections = config('database.connections');
156
        if (is_null($config = Nip_Helper_Arrays::get($connections, $name))) {
157
            throw new InvalidArgumentException("Database [$name] not configured.");
158
        }
159
        return $config;
160
    }
161
162
    /**
163
     * @param $config
164
     * @return Connection
165
     */
166
    public function newConnectionFromConfig($config)
167
    {
168
        $connection = $this->createNewConnection(
0 ignored issues
show
The method createNewConnection() does not exist on Nip\Database\DatabaseManager. Did you maybe mean connection()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
169
            $config->adapter,
170
            $config->host,
171
            $config->user,
172
            $config->password,
173
            $config->name
174
        );
175
        return $connection;
176
    }
177
178
    /**
179
     * @return array
180
     */
181
    public function getConnections(): array
182
    {
183
        return $this->connections;
184
    }
185
186
    /**
187
     * @return Connection
188
     */
189
    public function newConnection()
190
    {
191
        return new \Nip\Database\Connection();
192
    }
193
194
    /**
195
     * @param $connection
196
     */
197
    public function initNewConnection($connection)
0 ignored issues
show
The parameter $connection 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...
198
    {
199
//        if ($this->getBootstrap()->getDebugBar()->isEnabled()) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
69% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
200
//            $this->getBootstrap()->getDebugBar()->initDatabaseAdapter($connection->getAdapter());
201
//        }
202
    }
203
204
//    /**
205
//     * @return Bootstrap
206
//     */
207
//    public function getBootstrap()
208
//    {
209
//        return $this->bootstrap;
210
//    }
211
//
212
//    /**
213
//     * @param Bootstrap $bootstrap
214
//     */
215
//    public function setBootstrap($bootstrap)
216
//    {
217
//        $this->bootstrap = $bootstrap;
218
//    }
219
}
220