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/view/FileTemplateLayer.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
namespace Agavi\View;
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\Core\Context;
18
use Agavi\Exception\AgaviException;
19
use Agavi\Util\Toolkit;
20
21
/**
22
 * Template layer implementation for templates fetched using a PHP stream.
23
 *
24
 * @package    agavi
25
 * @subpackage view
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 FileTemplateLayer extends StreamTemplateLayer
36
{
37
    /**
38
     * Constructor.
39
     *
40
     * @param      array $parameters Initial parameters.
41
     *
42
     * @author     David Zülke <[email protected]>
43
     * @since      0.11.0
44
     */
45
    public function __construct(array $parameters = array())
46
    {
47
        $targets = array();
48
        if (Config::get('core.use_translation')) {
49
            $targets[] = '${directory}/${locale}/${template}${extension}';
50
            $targets[] = '${directory}/${template}.${locale}${extension}';
51
        }
52
        $targets[] = '${directory}/${template}${extension}';
53
        
54
        parent::__construct(array_merge(array(
55
            'directory' => Config::get('core.module_dir') . '/${module}/templates',
56
            'scheme' => 'file',
57
            'check' => true,
58
            'targets' => $targets,
59
        ), $parameters));
60
    }
61
    
62
    /**
63
     * Initialize the layer.
64
     *
65
     * Will try and figure out an alternative default for "directory".
66
     *
67
     * @param      Context The current Context instance.
68
     * @param      array        An array of initialization parameters.
69
     *
70
     * @author     David Zülke <[email protected]>
71
     * @since      1.0.0
72
     */
73
    public function initialize(Context $context, array $parameters = array())
74
    {
75
        $this->setParameter('directory', Toolkit::evaluateModuleDirective(isset($parameters['module']) ? $parameters['module'] : '', 'agavi.template.directory'));
76
        
77
        parent::initialize($context, $parameters);
78
    }
79
    
80
    /**
81
     * Get the full, resolved stream location name to the template resource.
82
     *
83
     * @return     string A PHP stream resource identifier.
84
     *
85
     * @throws     AgaviException If the template could not be found.
86
     *
87
     * @author     David Zülke <[email protected]>
88
     * @since      0.11.0
89
     */
90
    public function getResourceStreamIdentifier()
91
    {
92
        $retval = null;
0 ignored issues
show
$retval 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...
93
        $template = $this->getParameter('template');
94
        
95
        if ($template === null) {
96
            // no template set, we return null so nothing gets rendered
97
            return null;
98
        } elseif (Toolkit::isPathAbsolute($template)) {
99
            // the template is an absolute path, ignore the dir
100
            $directory = dirname($template);
101
            $template = basename($template);
102
        } else {
103
            $directory = $this->getParameter('directory');
104
        }
105
        // treat the directory as sprintf format string and inject module name
106
        $directory = Toolkit::expandVariables($directory, array_merge(array_filter($this->getParameters(), 'is_scalar'), array_filter($this->getParameters(), 'is_null')));
107
        
108
        $this->setParameter('directory', $directory);
109
        $this->setParameter('template', $template);
110
        if (!$this->hasParameter('extension')) {
111
            $this->setParameter('extension', $this->renderer->getDefaultExtension());
112
        }
113
        
114
        // everything set up for the parent
115
        return parent::getResourceStreamIdentifier();
116
    }
117
}
118