Issues (99)

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/ChildishServer.php (2 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
namespace Childish;
3
4
use PDO;
5
use Childish\database\DatabaseManager;
6
use Childish\connection\ConnectionFactory;
7
use Childish\support\Container;
8
use Childish\support\Fluent;
9
10
/**
11
 * ChildishServer
12
 *
13
 * @author    Pu ShaoWei <[email protected]>
14
 * @date      2017/12/6
15
 * @package   App\db
16
 * @version   1.0
17
 */
18
class ChildishServer
19
{
20
    /**
21
     * @var \Childish\database\DatabaseManager $manager
22
     */
23
    protected $manager;
24
25
    /**
26
     * The current globally used instance.
27
     *
28
     * @var ChildishServer
29
     */
30
    protected static $instance;
31
32
    /**
33
     * @var \Childish\support\Container $container
34
     */
35
    protected $container;
36
37
    /**
38
     * ChildishServer constructor.
39
     */
40
    public function __construct()
41
    {
42
        $this->setupContainer(new Container);
43
        $this->setupDefaultConfiguration();
44
        $this->setupManager();
45
    }
46
47
    /**
48
     * setupContainer
49
     *
50
     * @param \Childish\support\Container $container
51
     */
52
    protected function setupContainer(Container $container)
53
    {
54
        $this->container = $container;
55
        if (!$this->container->bound('config')) {
56
            $this->container->instance('config', new Fluent);
57
        }
58
    }
59
60
    /**
61
     * Make this capsule instance available globally.
62
     *
63
     * @return void
64
     */
65
    public function setAsGlobal()
66
    {
67
        static::$instance = $this;
68
    }
69
70
    /**
71
     * Get the IoC container instance.
72
     *
73
     * @return \Childish\support\Container $container
74
     */
75
    public function getContainer()
76
    {
77
        return $this->container;
78
    }
79
80
    /**
81
     * Setup the default database configuration options.
82
     *
83
     * @return void
84
     */
85
    protected function setupDefaultConfiguration()
86
    {
87
        $this->container['config']['database.fetch'] = PDO::FETCH_OBJ;
88
89
        $this->container['config']['database.default'] = 'default';
90
    }
91
92
    /**
93
     * Build the database manager instance.
94
     *
95
     * @return void
96
     */
97
    protected function setupManager()
98
    {
99
        $factory       = new ConnectionFactory($this->container);
100
        $this->manager = new DatabaseManager($this->container, $factory);
101
    }
102
103
    /**
104
     * Get a connection instance from the global manager.
105
     *
106
     * @param  string $connection
107
     * @return \Childish\connection\Connection
108
     */
109
    public static function connection($connection = null)
110
    {
111
        return static::$instance->getConnection($connection);
0 ignored issues
show
It seems like $connection defined by parameter $connection on line 109 can also be of type string; however, Childish\ChildishServer::getConnection() does only seem to accept null, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and 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...
112
    }
113
114
    /**
115
     * Get a fluent query builder instance.
116
     *
117
     * @param  string $table
118
     * @param  string $connection
119
     * @return  \Childish\query\Builder;
0 ignored issues
show
The doc-type \Childish\query\Builder; could not be parsed: Expected "|" or "end of type", but got ";" at position 23. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
120
     */
121
    public static function table($table, $connection = null)
122
    {
123
        return static::$instance->connection($connection)->table($table);
124
    }
125
126
    /**
127
     * @param  string $name
128
     * @return \\Connection
129
     */
130
    /**
131
     * Get a registered connection instance.
132
     *
133
     * @param null $name
134
     * @return \Childish\connection\Connection
135
     */
136
    public function getConnection($name = null)
137
    {
138
        return $this->manager->connection($name);
139
    }
140
141
    /**
142
     * Register a connection with the manager.
143
     *
144
     * @param  array  $config
145
     * @param  string $name
146
     * @return void
147
     */
148
    public function addConnection(array $config, $name = 'default')
149
    {
150
        $connections = $this->container['config']['database.connections'];
151
152
        $connections[$name] = $config;
153
154
        $this->container['config']['database.connections'] = $connections;
155
    }
156
157
    /**
158
     * Set the fetch mode for the database connections.
159
     *
160
     * @param  int $fetchMode
161
     * @return $this
162
     */
163
    public function setFetchMode($fetchMode)
164
    {
165
        $this->container['config']['database.fetch'] = $fetchMode;
166
167
        return $this;
168
    }
169
170
    /**
171
     * Get the database manager instance.
172
     *
173
     * @return mixed
174
     */
175
    public function getDatabaseManager()
176
    {
177
        return $this->manager;
178
    }
179
180
    /**
181
     * bootEloquent
182
     *
183
     * @return void
184
     */
185
    public function bootEloquent()
186
    {
187
        ChildishModel::setConnectionResolver($this->manager);
188
    }
189
190
    /**
191
     * Dynamically pass methods to the default connection.
192
     *
193
     * @param  string $method
194
     * @param  array  $parameters
195
     * @return mixed
196
     */
197
    public static function __callStatic($method, $parameters)
198
    {
199
        return static::connection()->$method(...$parameters);
200
    }
201
}