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/renderer/Renderer.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
namespace Agavi\Renderer;
3
4
// +---------------------------------------------------------------------------+
5
// | This file is part of the Agavi package.                                   |
6
// | Copyright (c) 2005-2011 the Agavi Project.                                |
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
use Agavi\Core\Context;
17
use Agavi\Exception\AgaviException;
18
use Agavi\Util\ParameterHolder;
19
use Agavi\View\TemplateLayer;
20
21
/**
22
 * A renderer produces the output as defined by a View
23
 *
24
 * @package    agavi
25
 * @subpackage renderer
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
abstract class Renderer extends ParameterHolder
36
{
37
    /**
38
     * @var        Context An Context instance.
39
     */
40
    protected $context = null;
41
42
    /**
43
     * @var        string The context name.
44
     */
45
    protected $contextName = null;
46
    /**
47
     * @var        string A string with the default template file extension,
48
     *                    including the dot.
49
     */
50
    protected $defaultExtension = '';
51
    
52
    /**
53
     * @var        string The name of the array that contains the template vars.
54
     */
55
    protected $varName = 'template';
56
    
57
    /**
58
     * @var        string The name of the array that contains the slots output.
59
     */
60
    protected $slotsVarName = 'slots';
61
    
62
    /**
63
     * @var        bool Whether or not the template vars should be extracted.
64
     */
65
    protected $extractVars = false;
66
    
67
    /**
68
     * @var        array An array of objects to be exported for use in templates.
69
     */
70
    protected $assigns = array();
71
    
72
    /**
73
     * @var        array An array of names for the "more" assigns.
74
     */
75
    protected $moreAssignNames = array();
76
    
77
    /**
78
     * Pre-serialization callback.
79
     *
80
     * Will set the name of the context and exclude the instance from serializing.
81
     *
82
     * @author     David Zülke <[email protected]>
83
     * @since      0.11.0
84
     */
85 View Code Duplication
    public function __sleep()
0 ignored issues
show
This method seems to be duplicated in 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...
86
    {
87
        $this->contextName = $this->context->getName();
88
        $arr = get_object_vars($this);
89
        unset($arr['context']);
90
        return array_keys($arr);
91
    }
92
    
93
    /**
94
     * Post-unserialization callback.
95
     *
96
     * Will restore the context based on the names set by __sleep.
97
     *
98
     * @author     David Zülke <[email protected]>
99
     * @since      0.11.0
100
     */
101
    public function __wakeup()
102
    {
103
        $this->context = Context::getInstance($this->contextName);
104
        unset($this->contextName);
105
    }
106
    
107
    /**
108
     * Initialize this Renderer.
109
     *
110
     * @param      Context $context The current application context.
111
     * @param      array   $parameters An associative array of initialization parameters.
112
     *
113
     * @author     David Zülke <[email protected]>
114
     * @since      0.11.0
115
     */
116
    public function initialize(Context $context, array $parameters = array())
117
    {
118
        $this->context = $context;
119
        
120
        $this->setParameters($parameters);
121
        
122
        $this->varName = $this->getParameter('var_name', $this->varName);
123
        $this->slotsVarName = $this->getParameter('slots_var_name', $this->slotsVarName);
124
        $this->extractVars = $this->getParameter('extract_vars', $this->extractVars);
125
        
126
        $this->defaultExtension = $this->getParameter('default_extension', $this->defaultExtension);
127
        
128
        if (!$this->extractVars && $this->varName == $this->slotsVarName) {
129
            throw new AgaviException('Template and Slots container variable names cannot be identical.');
130
        }
131
        
132
        foreach ($this->getParameter('assigns', array()) as $item => $var) {
133
            $getter = 'get' . str_replace('_', '', $item);
134
            if (is_callable(array($this->context, $getter))) {
135
                if ($var === null) {
136
                    // the name is null, which means this one should not be assigned
137
                    // we do this in here, not for the moreAssignNames, since those are checked later in the renderer
138
                    continue;
139
                }
140
                $this->assigns[$var] = $getter;
141
            } else {
142
                $this->moreAssignNames[$item] = $var;
143
            }
144
        }
145
    }
146
    
147
    /**
148
     * Retrieve the current application context.
149
     *
150
     * @return     Context The current Context instance.
151
     *
152
     * @author     David Zülke <[email protected]>
153
     * @since      0.11.0
154
     */
155
    final public function getContext()
156
    {
157
        return $this->context;
158
    }
159
    
160
    /**
161
     * Get the template file extension
162
     *
163
     * @return     string The extension, including a leading dot.
164
     *
165
     * @author     David Zülke <[email protected]>
166
     * @since      0.11.0
167
     */
168
    public function getDefaultExtension()
169
    {
170
        return $this->defaultExtension;
171
    }
172
    
173
    /**
174
     * Build an array of "more" assigns.
175
     *
176
     * @param      array $moreAssigns The values to be assigned.
177
     * @param      array $moreAssignNames Assigns name map.
178
     *
179
     * @return     array The data.
180
     *
181
     * @author     David Zülke <[email protected]>
182
     * @since      1.0.0
183
     */
184
    protected static function &buildMoreAssigns(&$moreAssigns, $moreAssignNames)
185
    {
186
        $retval = array();
187
        
188
        foreach ($moreAssigns as $name => &$value) {
189
            if (isset($moreAssignNames[$name])) {
190
                $name = $moreAssignNames[$name];
191
            } elseif (array_key_exists($name, $moreAssignNames)) {
192
                // the name is null, which means this one should not be assigned
193
                continue;
194
            }
195
            $retval[$name] =& $value;
196
        }
197
        
198
        return $retval;
199
    }
200
    
201
    /**
202
     * Render the presentation and return the result.
203
     *
204
     * @param      TemplateLayer $layer The template layer to render.
205
     * @param      array         $attributes The template variables.
206
     * @param      array         $slots The slots.
207
     * @param      array         $moreAssigns Associative array of additional assigns.
208
     *
209
     * @return     string A rendered result.
210
     *
211
     * @author     David Zülke <[email protected]>
212
     * @since      0.11.0
213
     */
214
    abstract public function render(TemplateLayer $layer, array &$attributes = array(), array &$slots = array(), array &$moreAssigns = array());
215
}
216