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/ConfigParser.class.php (3 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
// +---------------------------------------------------------------------------+
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\ParseException;
21
22
/**
23
 * ConfigParser parses XML files using XmlConfigParser, but returns
24
 * old-style ConfigValueHolders.
25
 *
26
 * @package    agavi
27
 * @subpackage config
28
 *
29
 * @author     David Zülke <[email protected]>
30
 * @copyright  Authors
31
 * @copyright  The Agavi Project
32
 *
33
 * @since      0.11.0
34
 *
35
 * @deprecated Superseded by XmlConfigParser, will be removed in Agavi 1.1
36
 *
37
 * @version    $Id$
38
 */
39
class ConfigParser
40
{
41
    /**
42
     * @var        string The encoding of the DOMDocument
43
     */
44
    protected $encoding = 'utf-8';
45
    
46
    /**
47
     * @var        string The filesystem path to the configuration file.
48
     */
49
    protected $config = '';
50
    
51
    /**
52
     * @param      string $config         An absolute filesystem path to a configuration file.
53
     * @param      array  $validationFile An associative array of validation information.
54
     *
55
     * @return     ConfigValueHolder The data handlers use to perform tasks.
56
     *
57
     * @author     David Zülke <[email protected]>
58
     * @since      0.11.0
59
     */
60
    public function parse($config, $validationFile = null)
61
    {
62
        // copy path in case convertEncoding() needs to complain about a missing ICONV extension
63
        $this->config = $config;
64
        
65
        $parser = new XmlConfigParser($config, Config::get('core.environment'), null);
66
        
67
        $validation = array(
68
            XmlConfigParser::STEP_TRANSFORMATIONS_BEFORE => array(),
69
            XmlConfigParser::STEP_TRANSFORMATIONS_AFTER => array(
70
                XmlConfigParser::VALIDATION_TYPE_XMLSCHEMA => array(),
71
            ),
72
        );
73
        if ($validationFile !== null) {
74
            $validation[XmlConfigParser::STEP_TRANSFORMATIONS_AFTER][XmlConfigParser::VALIDATION_TYPE_XMLSCHEMA][] = $validationFile;
75
        }
76
        $doc = $parser->execute(array(), $validation);
77
        
78
        // remember encoding for convertEncoding()
79
        $this->encoding = strtolower($doc->encoding);
80
        
81
        $rootRes = new ConfigValueHolder();
0 ignored issues
show
Deprecated Code introduced by
The class Agavi\Config\ConfigValueHolder has been deprecated with message: Not used anymore by XML config handlers, to be removed in Agavi 1.1

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
82
        
83
        if ($doc->documentElement) {
84
            $this->parseNodes(array($doc->documentElement), $rootRes);
85
        }
86
        
87
        return $rootRes;
88
    }
89
90
    /**
91
     * Iterates through a list of nodes and stores to each node in the
92
     * ConfigValueHolder
93
     *
94
     * @param      mixed             $nodes      An array or an object that can be iterated over
95
     * @param      ConfigValueHolder $parentVh   The storage for the info from the nodes
96
     * @param      bool              $isSingular Whether this list is the singular form of the parent node
97
     *
98
     * @author     David Zülke <[email protected]>
99
     * @author     Dominik del Bondio <[email protected]>
100
     * @since      0.11.0
101
     */
102
    protected function parseNodes($nodes, ConfigValueHolder $parentVh, $isSingular = false)
0 ignored issues
show
The parameter $isSingular 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...
103
    {
104
        /** @var XmlConfigDomElement $node */
105
        foreach ($nodes as $node) {
106
            if ($node->nodeType == XML_ELEMENT_NODE && (!$node->namespaceURI || $node->namespaceURI == XmlConfigParser::NAMESPACE_AGAVI_ENVELOPE_0_11)) {
107
                $vh = new ConfigValueHolder();
0 ignored issues
show
Deprecated Code introduced by
The class Agavi\Config\ConfigValueHolder has been deprecated with message: Not used anymore by XML config handlers, to be removed in Agavi 1.1

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
108
                $nodeName = $this->convertEncoding($node->localName);
109
                $vh->setName($nodeName);
110
                $parentVh->addChildren($nodeName, $vh);
111
112
                foreach ($node->attributes as $attribute) {
113
                    if ((!$attribute->namespaceURI || $attribute->namespaceURI == XmlConfigParser::NAMESPACE_AGAVI_ENVELOPE_0_11)) {
114
                        $vh->setAttribute($this->convertEncoding($attribute->localName), $this->convertEncoding($attribute->nodeValue));
115
                    }
116
                }
117
118
                // there are no child nodes so we set the node text contents as the value for the valueholder
119
                if ($node->getElementsByTagName('*')->length == 0) {
120
                    $vh->setValue($this->convertEncoding($node->nodeValue));
121
                }
122
123
                if ($node->hasChildNodes()) {
124
                    $this->parseNodes($node->childNodes, $vh);
125
                }
126
            }
127
        }
128
    }
129
    
130
    /**
131
     * Handle encoding for a value, i.e. translate from UTF-8 if necessary.
132
     *
133
     * @param      string $value A UTF-8 string value from the DomDocument.
134
     *
135
     * @return     string A value in the correct encoding of the parsed document.
136
     *
137
     * @author     David Zülke <[email protected]>
138
     * @since      0.11.0
139
     */
140
    protected function convertEncoding($value)
141
    {
142
        if ($this->encoding == 'utf-8') {
143
            return $value;
144
        } elseif ($this->encoding == 'iso-8859-1') {
145
            return utf8_decode($value);
146
        } elseif (function_exists('iconv')) {
147
            return iconv('UTF-8', $this->encoding, $value);
148
        } else {
149
            throw new ParseException('No iconv module available, configuration file "' . $this->config . '" with input encoding "' . $this->encoding . '" cannot be parsed.');
150
        }
151
    }
152
}
153