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/Document.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
abstract class Ajde_Document extends Ajde_Object_Standard
4
{
5
    const CACHE_CONTROL_PUBLIC = 'public';
6
    const CACHE_CONTROL_PRIVATE = 'private';
7
    const CACHE_CONTROL_NOCACHE = 'no-cache';
8
9
    protected $_cacheControl = self::CACHE_CONTROL_PUBLIC;
10
    protected $_contentType = 'text/html';
11
    protected $_maxAge = 604800; // 1 week
12
13
    public function __construct()
14
    {
15
        $this->setFormat(strtolower(str_replace('Ajde_Document_Format_', '', get_class($this))));
0 ignored issues
show
Documentation Bug introduced by
The method setFormat does not exist on object<Ajde_Document>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
16
    }
17
18
    /**
19
     * @param Ajde_Core_Route $route
20
     *
21
     * @return Ajde_Document
22
     */
23
    public static function fromRoute(Ajde_Core_Route $route)
24
    {
25
        $format = $route->getFormat();
26
        $documentClass = 'Ajde_Document_Format_'.ucfirst($format);
27
        if (!class_exists($documentClass)) {
28
            $exception = new Ajde_Core_Exception_Routing("Document format $format not found",
29
                90009);
30
            Ajde::routingError($exception);
31
        }
32
33
        return new $documentClass();
34
    }
35
36
    /**
37
     * @return Ajde_Layout
38
     */
39
    public function setLayout(Ajde_Layout $layout)
40
    {
41
        if (!$layout instanceof Ajde_Layout) {
42
            $layout = new Ajde_Layout($layout);
43
        }
44
        $layout->setDocument($this);
45
46
        return $this->set('layout', $layout);
47
    }
48
49
    /**
50
     * @return Ajde_Layout
51
     */
52
    public function getLayout()
53
    {
54
        if (!$this->hasLayout()) {
0 ignored issues
show
Documentation Bug introduced by
The method hasLayout does not exist on object<Ajde_Document>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
55
            // Load default layout into document
56
            $this->setLayout(new Ajde_Layout(config('layout.frontend')));
57
        }
58
59
        return $this->get('layout');
60
    }
61
62
    /**
63
     * @param string $contents
64
     */
65
    public function setBody($contents)
66
    {
67
        $this->set('body', $contents);
68
    }
69
70
    /**
71
     * @return string
72
     */
73
    public function getBody()
74
    {
75
        if ($this->has('body')) {
76
            return $this->get('body');
77
        } else {
78
            return '';
79
        }
80
    }
81
82
    public function setTitle($title)
83
    {
84
        $this->set('title', $title);
85
    }
86
87
    public function getTitle()
88
    {
89
        return $this->has('title') ? $this->get('title') : trans('Untitled page');
90
    }
91
92
    public function getFullTitle()
93
    {
94
        $projectTitle = config('app.title');
95
        if ($this->has('title')) {
96
            return sprintf(config('layout.titleFormat'),
97
                $projectTitle,
98
                $this->get('title')
99
            );
100
        } else {
101
            return $projectTitle;
102
        }
103
    }
104
105
    public function setDescription($description)
106
    {
107
        $this->set('description', $description);
108
    }
109
110
    public function getDescription()
111
    {
112
        if ($this->has('description')) {
113
            return $this->get('description');
114
        } else {
115
            return config('app.description');
116
        }
117
    }
118
119
    public function setAuthor($author)
120
    {
121
        $this->set('author', $author);
122
    }
123
124
    public function getAuthor()
125
    {
126
        if ($this->has('author')) {
127
            return $this->get('author');
128
        } else {
129
            return config('app.author');
130
        }
131
    }
132
133
    public function render()
134
    {
135
        return $this->getLayout()->getContents();
136
    }
137
138
    public function getCacheControl()
139
    {
140
        return $this->_cacheControl;
141
    }
142
143
    public function setCacheControl($cacheControl)
144
    {
145
        $this->_cacheControl = $cacheControl;
146
    }
147
148
    public function getContentType()
149
    {
150
        return $this->_contentType;
151
    }
152
153
    public function setContentType($mimeType)
154
    {
155
        $this->_contentType = $mimeType;
156
    }
157
158
    public function getMaxAge()
159
    {
160
        return (int) $this->_maxAge;
161
    }
162
163
    public function setMaxAge($days)
164
    {
165
        $this->_maxAge = (int) (60 * 60 * 24 * $days);
166
    }
167
168
    /**
169
     * @param Ajde_Resource $resource
170
     */
171
    public function addResource(Ajde_Resource $resource)
172
    {
173
    }
174
175
    public function getResourceTypes()
176
    {
177
    }
178
179
    // Render helpers
180
181
    /**
182
     * @deprecated
183
     *
184
     * @throws Ajde_Core_Exception_Deprecated
185
     */
186
    protected function setContentTypeHeader($contentType = null)
0 ignored issues
show
The parameter $contentType is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
187
    {
188
        throw new Ajde_Core_Exception_Deprecated();
189
    }
190
191
    /**
192
     * @deprecated
193
     *
194
     * @throws Ajde_Core_Exception_Deprecated
195
     */
196
    protected function setCacheControlHeader($cacheControl = null)
0 ignored issues
show
The parameter $cacheControl is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
197
    {
198
        throw new Ajde_Core_Exception_Deprecated();
199
    }
200
201
    public static function registerDocumentProcessor($format, $registerOn = 'layout')
202
    {
203
        $documentProcessors = config('layout.filters.documentProcessors');
204
        if (is_array($documentProcessors) && isset($documentProcessors[$format])) {
205
            foreach ($documentProcessors[$format] as $processor) {
206
                $processorClass = 'Ajde_Document_Processor_'.ucfirst($format).'_'.$processor;
207
                if (!class_exists($processorClass)) {
208
                    // TODO:
209
                    throw new Ajde_Exception('Processor '.$processorClass.' not found', 90022);
210
                }
211
                if ($registerOn == 'layout') {
212
                    Ajde_Event::register('Ajde_Layout', 'beforeGetContents', $processorClass.'::preProcess');
213
                    Ajde_Event::register('Ajde_Layout', 'afterGetContents', $processorClass.'::postProcess');
214
                } elseif ($registerOn == 'compressor') {
215
                    Ajde_Event::register('Ajde_Resource_Local_Compressor', 'beforeCompress',
216
                        $processorClass.'::preCompress');
217
                    Ajde_Event::register('Ajde_Resource_Local_Compressor', 'afterCompress',
218
                        $processorClass.'::postCompress');
219
                } else {
220
                    // TODO:
221
                    throw new Ajde_Exception('Document processor must be registered on either \'layout\' or \'compressor\'');
222
                }
223
            }
224
        }
225
    }
226
}
227