Issues (1131)

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

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
namespace Agavi\Database;
3
4
// +---------------------------------------------------------------------------+
5
// | This file is part of the Agavi package.                                   |
6
// | Copyright (c) 2005-2011 the Agavi Project.                                |
7
// | Based on the Mojavi3 MVC Framework, Copyright (c) 2003-2005 Sean Kerr.    |
8
// |                                                                           |
9
// | For the full copyright and license information, please view the LICENSE   |
10
// | file that was distributed with this source code. You can also view the    |
11
// | LICENSE file online at http://www.agavi.org/LICENSE.txt                   |
12
// |   vi: set noexpandtab:                                                    |
13
// |   Local Variables:                                                        |
14
// |   indent-tabs-mode: t                                                     |
15
// |   End:                                                                    |
16
// +---------------------------------------------------------------------------+
17
use Agavi\Config\Config;
18
use Agavi\Config\ConfigCache;
19
use Agavi\Core\Context;
20
use Agavi\Exception\DatabaseException;
21
use Agavi\Exception\InitializationException;
22
23
/**
24
 * AgaviDatabaseManager allows you to setup your database connectivity before
25
 * the request is handled. This eliminates the need for a filter to manage
26
 * database connections.
27
 *
28
 * @package    agavi
29
 * @subpackage database
30
 *
31
 * @author     David Zülke <[email protected]>
32
 * @author     Sean Kerr <[email protected]>
33
 * @copyright  Authors
34
 * @copyright  The Agavi Project
35
 *
36
 * @since      0.9.0
37
 *
38
 * @version    $Id$
39
 */
40
class DatabaseManager
41
{
42
    /**
43
     * @var        string The name of the default database.
44
     */
45
    protected $defaultDatabaseName = null;
46
    
47
    /**
48
     * @var        array An array of AgaviDatabases.
49
     */
50
    protected $databases = array();
51
52
    /**
53
     * @var        Context A Context instance.
54
     */
55
    protected $context = null;
56
57
    /**
58
     * Retrieve the current application context.
59
     *
60
     * @return     Context The current Context instance.
61
     *
62
     * @author     David Zülke <[email protected]>
63
     * @since      0.11.0
64
     */
65
    final public function getContext()
66
    {
67
        return $this->context;
68
    }
69
70
    /**
71
     * Retrieve the database connection associated with this Database
72
     * implementation.
73
     *
74
     * @param      string $nme A database name.
0 ignored issues
show
There is no parameter named $nme. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
75
     *
76
     * @return     mixed A Database instance.
77
     *
78
     * @throws     DatabaseException If the requested database name does not exist.
79
     *
80
     * @author     David Zülke <[email protected]>
81
     * @author     Sean Kerr <[email protected]>
82
     * @since      0.9.0
83
     */
84
    public function getDatabase($name = null)
85
    {
86
        if ($name === null) {
87
            $name = $this->defaultDatabaseName;
88
        }
89
        
90
        if (isset($this->databases[$name])) {
91
            return $this->databases[$name];
92
        }
93
94
        // nonexistent database name
95
        $error = 'Database "%s" does not exist';
96
        $error = sprintf($error, $name);
97
        throw new DatabaseException($error);
98
    }
99
    
100
    /**
101
     * Retrieve the name of the given database instance.
102
     *
103
     * @param      Database $database The database to fetch the name of.
104
     *
105
     * @return     string The name of the database, or false if it was not found.
106
     *
107
     * @author     David Zülke <[email protected]>
108
     * @since      0.11.0
109
     */
110
    public function getDatabaseName(Database $database)
111
    {
112
        return array_search($database, $this->databases, true);
113
    }
114
115
    /**
116
     * Returns the name of the default database.
117
     *
118
     * @return     string The name of the default database.
119
     *
120
     * @author     David Zülke <[email protected]>
121
     * @since      0.11.0
122
     */
123
    public function getDefaultDatabaseName()
124
    {
125
        return $this->defaultDatabaseName;
126
    }
127
128
    /**
129
     * Initialize this DatabaseManager.
130
     *
131
     * @param      Context $context    A Context instance.
132
     * @param      array   $parameters An array of initialization parameters.
133
     *
134
     * @throws     InitializationException If an error occurs while initializing this DatabaseManager.
135
     *
136
     * @author     David Zülke <[email protected]>
137
     * @author     Sean Kerr <[email protected]>
138
     * @since      0.9.0
139
     */
140
    public function initialize(Context $context, array $parameters = array())
141
    {
142
        $this->context = $context;
143
144
        // load database configuration
145
        require(ConfigCache::checkConfig(Config::get('core.config_dir') . '/databases.xml'));
146
    }
147
148
    /**
149
     * Do any necessary startup work after initialization.
150
     *
151
     * This method is not called directly after initialize().
152
     *
153
     * @author     David Zülke <[email protected]>
154
     * @since      0.11.0
155
     */
156
    public function startup()
157
    {
158
        /** @var Database $database */
159
        foreach ($this->databases as $database) {
160
            $database->startup();
161
        }
162
    }
163
164
    /**
165
     * Execute the shutdown procedure.
166
     *
167
     * @throws     <b>AgaviDatabaseException</b> If an error occurs while shutting
168
     *                                           down this DatabaseManager.
169
     *
170
     * @author     Sean Kerr <[email protected]>
171
     * @since      0.9.0
172
     */
173
    public function shutdown()
174
    {
175
        // loop through databases and shutdown connections
176
        foreach ($this->databases as $database) {
177
            $database->shutdown();
178
        }
179
    }
180
}
181