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

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
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\XmlConfigDomElement;
20
use Agavi\Exception\AgaviException;
21
use Agavi\Util\Toolkit;
22
use Agavi\Config\Util\Dom\XmlConfigDomDocument;
23
24
/**
25
 * ConfigHandlersConfigHandler allows you to specify configuration handlers
26
 * for the application or on a module level.
27
 *
28
 * @package    agavi
29
 * @subpackage config
30
 *
31
 * @author     Dominik del Bondio <[email protected]>
32
 * @author     Noah Fontes <[email protected]>
33
 * @author     David Zülke <[email protected]>
34
 * @copyright  Authors
35
 * @copyright  The Agavi Project
36
 *
37
 * @since      0.11.0
38
 *
39
 * @version    $Id$
40
 */
41
class ConfigHandlersConfigHandler extends XmlConfigHandler
42
{
43
    const XML_NAMESPACE = 'http://agavi.org/agavi/config/parts/config_handlers/1.1';
44
    
45
    /**
46
     * Execute this configuration handler.
47
     *
48
     * @param      XmlConfigDomDocument $document The document to handle.
49
     *
50
     * @return     string Data to be written to a cache file.
51
     *
52
     * @throws     <b>UnreadableException</b> If a requested configuration
53
     *                                        file does not exist or is not
54
     *                                        readable.
55
     * @throws     <b>ParseException</b> If a requested configuration file is
56
     *                                   improperly formatted.
57
     *
58
     * @author     Dominik del Bondio <[email protected]>
59
     * @author     Noah Fontes <[email protected]>
60
     * @author     David Zülke <[email protected]>
61
     * @since      0.11.0
62
     */
63
    public function execute(XmlConfigDomDocument $document)
64
    {
65
        // set up our default namespace
66
        $document->setDefaultNamespace(self::XML_NAMESPACE, 'config_handlers');
67
        
68
        // init our data arrays
69
        $handlers = array();
70
        
71
        foreach ($document->getConfigurationElements() as $configuration) {
72
            if (!$configuration->has('handlers')) {
73
                continue;
74
            }
75
            
76
            // let's do our fancy work
77
            /** @var XmlConfigDomElement $handler */
78
            foreach ($configuration->get('handlers') as $handler) {
79
                $pattern = $handler->getAttribute('pattern');
80
                
81
                $category = Toolkit::normalizePath(Toolkit::expandDirectives($pattern));
82
                
83
                $class = $handler->getAttribute('class');
84
                
85
                $transformations = array(
86
                    XmlConfigParser::STAGE_SINGLE => array(),
87
                    XmlConfigParser::STAGE_COMPILATION => array(),
88
                );
89
                if ($handler->has('transformations')) {
90
                    /** @var XmlConfigDomElement $transformation */
91
                    foreach ($handler->get('transformations') as $transformation) {
92
                        $path = Toolkit::literalize($transformation->getValue());
93
                        $for = $transformation->getAttribute('for', XmlConfigParser::STAGE_SINGLE);
94
                        $transformations[$for][] = $path;
95
                    }
96
                }
97
                
98
                $validations = array(
99
                    XmlConfigParser::STAGE_SINGLE => array(
100
                        XmlConfigParser::STEP_TRANSFORMATIONS_BEFORE => array(
101
                            XmlConfigParser::VALIDATION_TYPE_RELAXNG => array(
102
                            ),
103
                            XmlConfigParser::VALIDATION_TYPE_SCHEMATRON => array(
104
                            ),
105
                            XmlConfigParser::VALIDATION_TYPE_XMLSCHEMA => array(
106
                            ),
107
                        ),
108
                        XmlConfigParser::STEP_TRANSFORMATIONS_AFTER => array(
109
                            XmlConfigParser::VALIDATION_TYPE_RELAXNG => array(
110
                            ),
111
                            XmlConfigParser::VALIDATION_TYPE_SCHEMATRON => array(
112
                            ),
113
                            XmlConfigParser::VALIDATION_TYPE_XMLSCHEMA => array(
114
                            ),
115
                        ),
116
                    ),
117
                    XmlConfigParser::STAGE_COMPILATION => array(
118
                        XmlConfigParser::STEP_TRANSFORMATIONS_BEFORE => array(
119
                            XmlConfigParser::VALIDATION_TYPE_RELAXNG => array(
120
                            ),
121
                            XmlConfigParser::VALIDATION_TYPE_SCHEMATRON => array(
122
                            ),
123
                            XmlConfigParser::VALIDATION_TYPE_XMLSCHEMA => array(
124
                            ),
125
                        ),
126
                        XmlConfigParser::STEP_TRANSFORMATIONS_AFTER => array(
127
                            XmlConfigParser::VALIDATION_TYPE_RELAXNG => array(
128
                            ),
129
                            XmlConfigParser::VALIDATION_TYPE_SCHEMATRON => array(
130
                            ),
131
                            XmlConfigParser::VALIDATION_TYPE_XMLSCHEMA => array(
132
                            ),
133
                        ),
134
                    ),
135
                );
136
                if ($handler->has('validations')) {
137
                    /** @var XmlConfigDomElement $validation */
138
                    foreach ($handler->get('validations') as $validation) {
139
                        $path = Toolkit::literalize($validation->getValue());
140
                        $type = null;
0 ignored issues
show
$type is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
141
                        if (!$validation->hasAttribute('type')) {
142
                            $type = $this->guessValidationType($path);
143
                        } else {
144
                            $type = $validation->getAttribute('type');
145
                        }
146
                        $for = $validation->getAttribute('for', XmlConfigParser::STAGE_SINGLE);
147
                        $step = $validation->getAttribute('step', XmlConfigParser::STEP_TRANSFORMATIONS_AFTER);
148
                        $validations[$for][$step][$type][] = $path;
149
                    }
150
                }
151
                
152
                $handlers[$category] = isset($handlers[$category])
153
                    ? $handlers[$category]
154
                    : array(
155
                        'parameters' => array(),
156
                        );
157
                $handlers[$category] = array(
158
                    'class' => $class,
159
                    'parameters' => $handler->getAgaviParameters($handlers[$category]['parameters']),
160
                    'transformations' => $transformations,
161
                    'validations' => $validations,
162
                );
163
            }
164
        }
165
        
166
        $data = array(
167
            'return ' . var_export($handlers, true),
168
        );
169
        
170
        return $this->generate($data, $document->documentURI);
171
    }
172
    
173
    /**
174
     * Convenience method to quickly guess the type of a validation file using its
175
     * file extension.
176
     *
177
     * @param      string $path The path to the file.
178
     *
179
     * @return     string An XmlConfigParser::VALIDATION_TYPE_* const value.
180
     *
181
     * @throws     AgaviException If the type could not be determined.
182
     *
183
     * @author     David Zülke <[email protected]>
184
     * @since      1.0.0
185
     */
186
    protected function guessValidationType($path)
187
    {
188
        switch (pathinfo($path, PATHINFO_EXTENSION)) {
189
            case 'rng':
190
                return XmlConfigParser::VALIDATION_TYPE_RELAXNG;
191
            case 'rnc':
192
                return XmlConfigParser::VALIDATION_TYPE_RELAXNG;
193
            case 'sch':
194
                return XmlConfigParser::VALIDATION_TYPE_SCHEMATRON;
195
            case 'xsd':
196
                return XmlConfigParser::VALIDATION_TYPE_XMLSCHEMA;
197
            default:
198
                throw new AgaviException(sprintf('Could not determine validation type for file "%s"', $path));
199
        }
200
    }
201
}
202