Issues (1919)

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.

lib/Ajde/Template.php (4 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
class Ajde_Template extends Ajde_Object_Standard
4
{
5
    protected $_contents = null;
6
    protected $_table = [];
7
8
    public function __construct($base, $action, $format = 'html')
9
    {
10
        $this->set('base', $base);
11
        $this->set('action', $action);
12
        $this->set('format', $format);
13
        $this->setFileinfo();
14
    }
15
16
    protected function setFileinfo()
17
    {
18
        if (($fileInfo = $this->getFileInfo()) === false) {
19
            $exception = new Ajde_Core_Exception_Routing(sprintf('Template file in %s,
20
					for action %s with format %s not found',
21
                $this->getBase(), $this->getAction(), $this->getFormat()), 90010);
22
            Ajde::routingError($exception);
23
        }
24
        $className = 'Ajde_Template_Parser_'.$fileInfo['parser'];
25
        $parser = new $className($this);
26
27
        $this->setFilename($fileInfo['filename']);
28
        $this->setParser($parser);
29
    }
30
31
    public function setBase($base)
32
    {
33
        $this->set('base', $base);
34
        $this->setFileinfo();
35
    }
36
37
    public function setAction($action)
38
    {
39
        $this->set('action', $action);
40
        $this->setFileinfo();
41
    }
42
43
    public function setFormat($format)
44
    {
45
        $this->set('format', $format);
46
        $this->setFileinfo();
47
    }
48
49 View Code Duplication
    public function __fallback($method, $arguments)
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...
50
    {
51
        $helper = $this->getParser()->getHelper();
52
        if (method_exists($helper, $method)) {
53
            return call_user_func_array([$helper, $method], $arguments);
54
        } else {
55
            throw new Ajde_Exception('Call to undefined method '.get_class($this)."::$method()", 90006);
56
        }
57
    }
58
59
    protected function getFileInfo()
60
    {
61
        return $this->_getFileInfo($this->getBase(), $this->getAction(), $this->getFormat());
62
    }
63
64
    private static function _getFileInfo($base, $action, $format = 'html')
65
    {
66
        // go see what templates are available
67
        $dirPrefixPatterns = [
68
            APP_DIR,
69
            CORE_DIR,
70
        ];
71
        $fileNamePatterns = [
72
            $action.'.'.$format,
73
            $action,
74
        ];
75
        $fileTypes = [
76
            'phtml' => 'Phtml',
77
            'xhtml' => 'Xhtml',
78
        ];
79
        foreach ($dirPrefixPatterns as $dirPrefixPattern) {
80
            $prefixedBase = $dirPrefixPattern.$base;
81
            foreach ($fileNamePatterns as $fileNamePattern) {
82
                foreach ($fileTypes as $fileType => $parserType) {
83
                    $filePattern = $fileNamePattern.'.'.$fileType;
84
                    if (!substr_count($prefixedBase, DIRECTORY_SEPARATOR.'layout'.DIRECTORY_SEPARATOR)) {
85
                        $layoutDir = 'layout.'.Ajde::app()->getDocument()->getLayout()->getName().DIRECTORY_SEPARATOR;
86 View Code Duplication
                        if ($fileMatch = Ajde_Fs_Find::findFile($prefixedBase.TEMPLATE_DIR.$layoutDir,
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...
87
                            $filePattern)
88
                        ) {
89
                            return ['filename' => $fileMatch, 'parser' => $parserType];
90
                        }
91
                    }
92 View Code Duplication
                    if ($fileMatch = Ajde_Fs_Find::findFile($prefixedBase.TEMPLATE_DIR, $filePattern)) {
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...
93
                        return ['filename' => $fileMatch, 'parser' => $parserType];
94
                    }
95
                }
96
            }
97
        }
98
99
        return false;
100
    }
101
102
    public function setParser(Ajde_Template_Parser $parser)
103
    {
104
        $this->set('parser', $parser);
105
    }
106
107
    /**
108
     * @return Ajde_Template_Parser
109
     */
110
    public function getParser()
111
    {
112
        return $this->get('parser');
113
    }
114
115
    public static function exist($base, $action, $format = 'html')
116
    {
117
        return self::_getFileInfo($base, $action, $format);
118
    }
119
120
    public function setFilename($filename)
121
    {
122
        $this->set('filename', $filename);
123
    }
124
125
    public function getFilename()
126
    {
127
        return $this->get('filename');
128
    }
129
130
    public function getBase()
131
    {
132
        return $this->get('base');
133
    }
134
135
    public function getAction()
136
    {
137
        return $this->get('action');
138
    }
139
140
    public function getFormat()
141
    {
142
        return $this->get('format');
143
    }
144
145
    public function assign($key, $value)
146
    {
147
        $this->_table[$key] = $value;
148
    }
149
150
    public function assignArray($array)
151
    {
152
        foreach ($array as $key => $value) {
153
            $this->assign($key, $value);
154
        }
155
    }
156
157
    public function hasAssigned($key)
158
    {
159
        return array_key_exists($key, $this->_table);
160
    }
161
162
    public function getAssigned($key)
163
    {
164
        return $this->_table[$key];
165
    }
166
167
    public function getAllAssigned()
168
    {
169
        return $this->_table;
170
    }
171
172
    public function getContents()
173
    {
174
        if (!isset($this->_contents)) {
175
            Ajde_Event::trigger($this, 'beforeGetContents');
176
            Ajde_Cache::getInstance()->addFile($this->getFilename());
177
            $contents = $this->getParser()->parse($this);
0 ignored issues
show
The call to Ajde_Template_Parser::parse() has too many arguments starting with $this.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
178
            $this->setContents($contents);
179
            Ajde_Event::trigger($this, 'afterGetContents');
180
        }
181
182
        return $this->_contents;
183
    }
184
185
    /**
186
     * Alias for $this->getContents().
187
     *
188
     * @see self::getContents()
189
     */
190
    public function render()
191
    {
192
        return $this->getContents();
193
    }
194
195
    public function setContents($contents)
196
    {
197
        $this->_contents = $contents;
198
    }
199
200
    public function getDefaultResourcePosition()
201
    {
202
        return Ajde_Document_Format_Html::RESOURCE_POSITION_DEFAULT;
203
    }
204
}
205