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/WsdlConfigHandler.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
// |                                                                           |
7
// | For the full copyright and license information, please view the LICENSE   |
8
// | file that was distributed with this source code. You can also view the    |
9
// | LICENSE file online at http://www.agavi.org/LICENSE.txt                   |
10
// |   vi: set noexpandtab:                                                    |
11
// |   Local Variables:                                                        |
12
// |   indent-tabs-mode: t                                                     |
13
// |   End:                                                                    |
14
// +---------------------------------------------------------------------------+
15
16
namespace Agavi\Config;
17
18
use Agavi\Config\Util\Dom\XmlConfigDomElement;
19
use Agavi\Config\Util\Dom\XmlConfigDomDocument;
20
21
/**
22
 * WsdlConfigHandler simply writes the given WSDL file to disk.
23
 *
24
 * @package    agavi
25
 * @subpackage config
26
 *
27
 * @author     David Zülke <[email protected]>
28
 * @copyright  Authors
29
 * @copyright  The Agavi Project
30
 *
31
 * @since      0.11.0
32
 *
33
 * @version    $Id$
34
 */
35
class WsdlConfigHandler extends XmlConfigHandler
36
{
37
    /**
38
     * Execute this configuration handler.
39
     *
40
     * @param      XmlConfigDomDocument $doc The document to parse.
41
     *
42
     * @return     string Data to be written to a cache file.
43
     *
44
     * @throws     <b>AgaviParseException</b> If a requested configuration file is
45
     *                                        improperly formatted.
46
     *
47
     * @author     David Zülke <[email protected]>
48
     * @since      0.11.0
49
     */
50
    public function execute(XmlConfigDomDocument $doc)
51
    {
52
        $ro = $this->context->getRouting();
53
        
54
        $cleanAppName = preg_replace('/\W/', '', Config::get('core.app_name'));
55
        
56
        $xpath = new \DOMXPath($doc);
57
        $xpath->registerNamespace('soap', 'http://schemas.xmlsoap.org/wsdl/soap/');
58
        $xpath->registerNamespace('wsdl', 'http://schemas.xmlsoap.org/wsdl/');
59
        
60
        $paramWsdlDefinitionsName     = $ro->getParameter('wsdl_generator[wsdl][definitions][name]', $cleanAppName);
61
        
62
        $paramSoapAddressLocation     = $ro->getParameter('wsdl_generator[soap][address][location]');
63
                                      
64
        $paramSoapBindingStyle        = $ro->getParameter('wsdl_generator[soap][binding][style]', 'rpc');
65
        $paramSoapBindingTransport    = $ro->getParameter('wsdl_generator[soap][binding][transport]', 'http://schemas.xmlsoap.org/soap/http');
66
        
67
        $paramSoapBodyUse             = $ro->getParameter('wsdl_generator[soap][body][use]', 'literal');
68
        $paramSoapBodyNamespace       = $ro->getParameter('wsdl_generator[soap][body][namespace]', /*'urn:' . $paramWsdlDefinitionsName*/ null);
69
        $paramSoapBodyEncodingStyle   = $ro->getParameter('wsdl_generator[soap][body][encoding_style]', 'http://schemas.xmlsoap.org/soap/encoding/');
70
        
71
        $paramSoapHeaderUse           = $ro->getParameter('wsdl_generator[soap][header][use]', 'literal');
72
        $paramSoapHeaderNamespace     = $ro->getParameter('wsdl_generator[soap][header][namespace]', /*'urn:' . $paramWsdlDefinitionsName*/ null);
73
        $paramSoapHeaderEncodingStyle = $ro->getParameter('wsdl_generator[soap][header][encoding_style]', 'http://schemas.xmlsoap.org/soap/encoding/');
74
        
75
        $paramSoapFaultUse            = $ro->getParameter('wsdl_generator[soap][fault][use]', 'encoded');
76
        $paramSoapFaultNamespace      = $ro->getParameter('wsdl_generator[soap][fault][namespace]', /*'urn:' . $paramWsdlDefinitionsName*/ null);
77
        $paramSoapFaultEncodingStyle  = $ro->getParameter('wsdl_generator[soap][fault][encoding_style]', 'http://schemas.xmlsoap.org/soap/encoding/');
78
        
79
        $paramGlobalRequestHeaders    = $ro->getParameter('wsdl_generator[global_headers][request]', array());
80
        $paramGlobalResponseHeaders   = $ro->getParameter('wsdl_generator[global_headers][response]', array());
81
        
82
        $wsdlDefinitions = $xpath->query('/wsdl:definitions');
83
        /** @var XmlConfigDomElement $wsdlDefinition */
84
        foreach ($wsdlDefinitions as $wsdlDefinition) {
85
            $targetNamespaceUri = $wsdlDefinition->getAttribute('targetNamespace');
86
            $targetNamespacePrefix = $wsdlDefinition->lookupPrefix($targetNamespaceUri);
87
            
88
            $wsdlDefinition->setAttribute('name', $paramWsdlDefinitionsName);
89
            
90
            $wsdlBindings = $xpath->query('wsdl:binding', $wsdlDefinition);
91
            /** @var XmlConfigDomElement $wsdlBinding */
92
            foreach ($wsdlBindings as $wsdlBinding) {
93
                $wsdlBinding->setAttribute('name', $paramWsdlDefinitionsName . 'Binding');
94
                $wsdlBinding->setAttribute('type', $targetNamespacePrefix . ':' . $paramWsdlDefinitionsName . 'PortType');
95
                
96
                $soapBindings = $xpath->query('soap:binding', $wsdlBinding);
97
                /** @var XmlConfigDomElement $soapBinding */
98
                foreach ($soapBindings as $soapBinding) {
99
                    $soapBinding->setAttribute('style', $paramSoapBindingStyle);
100
                    $soapBinding->setAttribute('transport', $paramSoapBindingTransport);
101
                }
102
                
103
                $wsdlOperations = $xpath->query('wsdl:operation', $wsdlBinding);
104
                /** @var XmlConfigDomElement $wsdlOperation */
105
                foreach ($wsdlOperations as $wsdlOperation) {
106
                    foreach (array('input' => $paramGlobalRequestHeaders, 'output' => $paramGlobalResponseHeaders) as $target => $headers) {
107
                        foreach ($headers as $header) {
108
                            if (!isset($header['namespace'])) {
109
                                $header['namespace'] = $targetNamespaceUri;
110
                            }
111
                            $element = $doc->createElementNS('http://schemas.xmlsoap.org/wsdl/soap/', 'soap:header');
112
                            foreach (array('encodingStyle', 'message', 'namespace', 'part', 'use') as $key) {
113
                                if (isset($header[$key])) {
114
                                    $element->setAttribute($key, $header[$key]);
115
                                }
116
                            }
117
                            $wsdlOperation->getElementsByTagNameNS('http://schemas.xmlsoap.org/wsdl/', $target)->item(0)->appendChild($element);
118
                        }
119
                    }
120
                    
121
                    if ($paramSoapBodyNamespace !== null) {
122
                        $soapOperations = $xpath->query('soap:operation', $wsdlOperation);
123
                        /** @var XmlConfigDomElement $soapOperation */
124
                        foreach ($soapOperations as $soapOperation) {
125
                            $soapOperation->setAttribute('soapAction', $paramSoapBodyNamespace . '#' . $wsdlOperation->getAttribute('name'));
126
                        }
127
                    }
128
                    
129
                    $soapBodies = $xpath->query('.//soap:body', $wsdlOperation);
130
                    /** @var XmlConfigDomElement $soapBody */
131 View Code Duplication
                    foreach ($soapBodies as $soapBody) {
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...
132
                        if (!$soapBody->hasAttribute('use')) {
133
                            $soapBody->setAttribute('use', $paramSoapBodyUse);
134
                        }
135
                        if ($paramSoapBodyNamespace !== null) {
136
                            $soapBody->setAttribute('namespace', $paramSoapBodyNamespace);
137
                        } elseif ($soapBody->getAttribute('use') == 'literal' && $paramSoapBindingStyle == 'document') {
138
                            $soapBody->removeAttribute('namespace');
139
                        }
140
                        if ($soapBody->getAttribute('use') == 'encoded') {
141
                            $soapBody->setAttribute('encodingStyle', $paramSoapBodyEncodingStyle);
142
                        }
143
                    }
144
                    
145
                    $soapHeaders = $xpath->query('.//soap:header', $wsdlOperation);
146
                    /** @var XmlConfigDomElement $soapHeader */
147 View Code Duplication
                    foreach ($soapHeaders as $soapHeader) {
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...
148
                        if (!$soapHeader->hasAttribute('use')) {
149
                            $soapHeader->setAttribute('use', $paramSoapHeaderUse);
150
                        }
151
                        if ($paramSoapHeaderNamespace !== null) {
152
                            $soapHeader->setAttribute('namespace', $paramSoapHeaderNamespace);
153
                        } elseif ($soapHeader->getAttribute('use') == 'literal' && $paramSoapBindingStyle == 'document') {
154
                            $soapHeader->removeAttribute('namespace');
155
                        }
156
                        if ($soapHeader->getAttribute('use') == 'encoded') {
157
                            $soapHeader->setAttribute('encodingStyle', $paramSoapHeaderEncodingStyle);
158
                        }
159
                    }
160
                    
161
                    $soapFaults = $xpath->query('.//soap:fault', $wsdlOperation);
162
                    /** @var XmlConfigDomElement $soapFault */
163 View Code Duplication
                    foreach ($soapFaults as $soapFault) {
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...
164
                        if (!$soapFault->hasAttribute('use')) {
165
                            $soapFault->setAttribute('use', $paramSoapFaultUse);
166
                        }
167
                        if ($paramSoapFaultNamespace !== null) {
168
                            $soapFault->setAttribute('namespace', $paramSoapFaultNamespace);
169
                        } elseif ($soapFault->getAttribute('use') == 'literal' && $paramSoapBindingStyle == 'document') {
170
                            $soapFault->removeAttribute('namespace');
171
                        }
172
                        if ($soapFault->getAttribute('use') == 'encoded') {
173
                            $soapFault->setAttribute('encodingStyle', $paramSoapFaultEncodingStyle);
174
                        }
175
                    }
176
                }
177
            }
178
            
179
            $wsdlPortTypes = $xpath->query('wsdl:portType', $wsdlDefinition);
180
            /** @var XmlConfigDomElement $wsdlPortType */
181
            foreach ($wsdlPortTypes as $wsdlPortType) {
182
                $wsdlPortType->setAttribute('name', $paramWsdlDefinitionsName . 'PortType');
183
            }
184
            
185
            $wsdlServices = $xpath->query('wsdl:service', $wsdlDefinition);
186
            /** @var XmlConfigDomElement $wsdlService */
187
            foreach ($wsdlServices as $wsdlService) {
188
                $wsdlService->setAttribute('name', $paramWsdlDefinitionsName . 'Service');
189
                
190
                $wsdlPorts = $xpath->query('wsdl:port', $wsdlService);
191
                /** @var XmlConfigDomElement $wsdlPort */
192
                foreach ($wsdlPorts as $wsdlPort) {
193
                    $wsdlPort->setAttribute('name', $paramWsdlDefinitionsName . 'Port');
194
                    $wsdlPort->setAttribute('binding', $targetNamespacePrefix . ':' . $paramWsdlDefinitionsName . 'Binding');
195
                    
196
                    $soapAddresses = $xpath->query('soap:address', $wsdlPort);
197
                    /** @var XmlConfigDomElement $soapAddress */
198
                    foreach ($soapAddresses as $soapAddress) {
199
                        $soapAddress->setAttribute('location', $paramSoapAddressLocation);
200
                    }
201
                }
202
            }
203
        }
204
        
205
        return $doc->saveXML();
206
    }
207
}
208