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/config/SettingConfigHandler.class.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
// | This file is part of the Agavi package.                                   |
5
// | Copyright (c) 2005-2011 the Agavi Project.                                |
6
// | Based on the Mojavi3 MVC Framework, Copyright (c) 2003-2005 Sean Kerr.    |
7
// |                                                                           |
8
// | For the full copyright and license information, please view the LICENSE   |
9
// | file that was distributed with this source code. You can also view the    |
10
// | LICENSE file online at http://www.agavi.org/LICENSE.txt                   |
11
// |   vi: set noexpandtab:                                                    |
12
// |   Local Variables:                                                        |
13
// |   indent-tabs-mode: t                                                     |
14
// |   End:                                                                    |
15
// +---------------------------------------------------------------------------+
16
17
namespace Agavi\Config;
18
19
use Agavi\Config\Util\Dom\XmlConfigDomDocument;
20
use Agavi\Config\Util\Dom\XmlConfigDomElement;
21
use Agavi\Exception\ConfigurationException;
22
use Agavi\Util\Toolkit;
23
24
/**
25
 * SettingConfigHandler handles the settings.xml file
26
 *
27
 * @package    agavi
28
 * @subpackage config
29
 *
30
 * @author     David Zülke <[email protected]>
31
 * @author     Dominik del Bondio <[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 SettingConfigHandler extends XmlConfigHandler
41
{
42
    const XML_NAMESPACE = 'http://agavi.org/agavi/config/parts/settings/1.1';
43
    
44
    /**
45
     * Execute this configuration handler.
46
     *
47
     * @param      XmlConfigDomDocument $document The document to parse.
48
     *
49
     * @return     string Data to be written to a cache file.
50
     *
51
     * @throws     <b>ConfigurationException</b> If a requested configuration
52
     *                                           file does not exist or is not
53
     *                                           readable.
54
     * @throws     <b>ParseException</b> If a requested configuration file is
55
     *                                   improperly formatted.
56
     *
57
     * @author     David Zülke <[email protected]>
58
     * @author     Dominik del Bondio <[email protected]>
59
     * @author     Sean Kerr <[email protected]>
60
     * @since      0.9.0
61
     */
62
    public function execute(XmlConfigDomDocument $document)
63
    {
64
        // set up our default namespace
65
        $document->setDefaultNamespace(self::XML_NAMESPACE, 'settings');
66
        
67
        // init our data array
68
        $data = array();
69
        
70
        $prefix = 'core.';
71
        
72
        foreach ($document->getConfigurationElements() as $cfg) {
73
            // let's do our fancy work
74
            if ($cfg->has('system_controllers')) {
75
                foreach ($cfg->get('system_controllers') as $controller) {
76
                    $name = $controller->getAttribute('name');
77
                    $data[sprintf('controllers.%s_module', $name)] = $controller->getChild('module')->getValue();
78
                    $data[sprintf('controllers.%s_controller', $name)] = $controller->getChild('controller')->getValue();
79
                }
80
            }
81
            
82
            // loop over <setting> elements; there can be many of them
83
            /** @var XmlConfigDomElement $setting */
84 View Code Duplication
            foreach ($cfg->get('settings') as $setting) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
85
                $localPrefix = $prefix;
86
                
87
                // let's see if this buddy has a <settings> parent with valuable information
88
                if ($setting->parentNode->localName == 'settings') {
89
                    if ($setting->parentNode->hasAttribute('prefix')) {
90
                        $localPrefix = $setting->parentNode->getAttribute('prefix');
91
                    }
92
                }
93
                
94
                $settingName = $localPrefix . $setting->getAttribute('name');
95
                if ($setting->hasAgaviParameters()) {
96
                    $data[$settingName] = $setting->getAgaviParameters();
97
                } else {
98
                    $data[$settingName] = $setting->getLiteralValue();
99
                }
100
            }
101
            
102
            if ($cfg->has('exception_templates')) {
103
                foreach ($cfg->get('exception_templates') as $exception_template) {
104
                    $tpl = Toolkit::expandDirectives($exception_template->getValue());
105
                    if (!is_readable($tpl)) {
106
                        throw new ConfigurationException('Exception template "' . $tpl . '" does not exist or is unreadable');
107
                    }
108
                    if ($exception_template->hasAttribute('context')) {
109
                        foreach (array_map('trim', explode(' ', $exception_template->getAttribute('context'))) as $ctx) {
110
                            $data['exception.templates.' . $ctx] = $tpl;
111
                        }
112
                    } else {
113
                        $data['exception.default_template'] = Toolkit::expandDirectives($tpl);
114
                    }
115
                }
116
            }
117
        }
118
119
        $code = 'Agavi\\Config\\Config::fromArray(' . var_export($data, true) . ');';
120
121
        return $this->generate($code, $document->documentURI);
122
    }
123
}
124