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

Labels
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
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\Config\Config;
17
use Agavi\Util\Toolkit;
18
use Agavi\View\TemplateLayer;
19
20
/**
21
 * A renderer produces the output as defined by a View
22
 *
23
 * @package    agavi
24
 * @subpackage renderer
25
 *
26
 * @author     Felix Weis <[email protected]>
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 EzctemplateRenderer extends Renderer implements ReusableRendererInterface
36
{
37
    /**
38
     * @constant   string The directory inside the cache dir where templates will
39
     *                    be stored in compiled form.
40
     */
41
    const COMPILE_DIR = 'templates';
42
43
    /**
44
     * @constant   string The subdirectory inside the compile dir where templates
45
     *                    will be stored in compiled form.
46
     */
47
    const COMPILE_SUBDIR = 'ezctemplate';
48
49
    /**
50
     * @constant   string The directory inside the cache dir where cached content
51
     *                    will be stored.
52
     */
53
    const CACHE_DIR = 'content';
54
55
    /**
56
     * @var        ezcTemplate The template engine instance.
57
     */
58
    protected $ezcTemplate = null;
59
60
    /**
61
     * @var        string A string with the default template file extension,
62
     *                    including the dot.
63
     */
64
    protected $defaultExtension = '.ezt';
65
66
    /**
67
     * Pre-serialization callback.
68
     *
69
     * Excludes the ezcTemplate instance to prevent excessive serialization load.
70
     *
71
     * @author     Felix Weis <[email protected]>
72
     * @since      0.11.0
73
     */
74
    public function __sleep()
75
    {
76
        $keys = parent::__sleep();
77
        unset($keys[array_search('ezctemplate', $keys)]);
78
        return $keys;
79
    }
80
    
81
    /**
82
     * Create an instance of ezcTemplate and initialize it correctly.
83
     * Returns an instance of EzctemplateTemplate by default.
84
     *
85
     * @return     ezcTemplate The ezcTemplate instance.
86
     *
87
     * @author     David Zülke <[email protected]>
88
     * @since      1.0.2
89
     */
90
    protected function createEngineInstance()
91
    {
92
        $cls = $this->getParameter('template_class', 'EzctemplateTemplate');
93
        
94
        $ezcTemplate = new $cls();
95
        if ($ezcTemplate instanceof AgaviIEzctemplateTemplate) {
0 ignored issues
show
The class Agavi\Renderer\AgaviIEzctemplateTemplate does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
96
            $ezcTemplate->setContext($this->context);
97
        }
98
        
99
        return $ezcTemplate;
100
    }
101
102
    /**
103
     * Grab a cleaned up ezctemplate instance.
104
     *
105
     * @return     ezcTemplate A ezcTemplate instance.
106
     *
107
     * @author     Felix Weis <[email protected]>
108
     * @since      0.11.0
109
     */
110
    protected function getEngine()
111
    {
112
        // ezcTemplate already initialized, only clear the assigns and retun the engine
113
        if ($this->ezcTemplate) {
114
            $this->ezcTemplate->send = new ezcTemplateVariableCollection();
115
            return $this->ezcTemplate;
116
        }
117
118
        $this->ezcTemplate = $this->createEngineInstance();
119
        // initialize ezcTemplate
120
        
121
        $parentMode = fileperms(Config::get('core.cache_dir'));
122
123
        $compileDir = Config::get('core.cache_dir') . DIRECTORY_SEPARATOR . self::COMPILE_DIR . DIRECTORY_SEPARATOR . self::COMPILE_SUBDIR;
124
        Toolkit::mkdir($compileDir, $parentMode, true);
125
126
        // templatePath unnessesary because Agavi will always supply the absolute ressource path
127
        $config = new ezcTemplateConfiguration();
128
        $config->templatePath = "";
129
        $config->compilePath = $compileDir;
130
131
        // set the ezcTemplateOutputContext (standard is ezcTemplateXhtmlContext)
132
        if ($this->hasParameter('context')) {
133
            $contextClass = $this->getParameter('context');
134
            $config->context = new $contextClass();
135
        }
136
137
        // add some usefull Agavi Functions/Blocks as Extension
138
        $config->addExtension('EzctemplateCustomBlocks');
139
        $config->addExtension('EzctemplateCustomFunctions');
140
        
141
        foreach ($this->getParameter('extensions', array()) as $extension) {
142
            $config->addExtension($extension);
143
        }
144
        
145
        $this->ezcTemplate->configuration = $config;
146
147
        return $this->ezcTemplate;
148
    }
149
150
    /**
151
     * Render the presentation and return the result.
152
     *
153
     * @param      TemplateLayer $layer The template layer to render.
154
     * @param      array         $attributes The template variables.
155
     * @param      array         $slots The slots.
156
     * @param      array         $moreAssigns Associative array of additional assigns.
157
     *
158
     * @return     string A rendered result.
159
     *
160
     * @author     Felix Weis <[email protected]>
161
     * @since      0.11.0
162
     */
163
    public function render(TemplateLayer $layer, array &$attributes = array(), array &$slots = array(), array &$moreAssigns = array())
164
    {
165
        $engine = $this->getEngine();
166
167
        if ($this->extractVars) {
168
            foreach ($attributes as $name => &$value) {
169
                $engine->send->{$name} = $value;
170
            }
171
        } else {
172
            $engine->send->{$this->varName} = $attributes;
173
        }
174
175
        $key = $this->slotsVarName;
176
        $engine->send->{$key} = $slots;
177
178
        foreach ($this->assigns as $key => $getter) {
179
            $engine->send->{$key} = $this->context->$getter();
180
        }
181
182
        $finalMoreAssigns =& self::buildMoreAssigns($moreAssigns, $this->moreAssignNames);
183
        foreach ($finalMoreAssigns as $key => &$value) {
184
            $engine->send->{$key} = $value;
185
        }
186
187
        return $engine->process($layer->getResourceStreamIdentifier());
188
    }
189
}
190