Issues (165)

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/ThemeEngine/CThemeEngine.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
3
namespace Anax\ThemeEngine;
4
5
/**
6
 * Anax base class for wrapping sessions.
7
 *
8
 */
9
class CThemeEngine implements IThemeEngine, \Anax\DI\IInjectionAware
10
{
11
    use \Anax\View\THelpers,
12
        \Anax\TConfigure,
13
        \Anax\DI\TInjectionAware;
14
15
16
17
    /**
18
     * Array with variables to provide to theme template files.
19
     */
20
    protected $data = [];
21
22
23
24
    /**
25
     * Overwrite template file as defined in config.
26
     */
27
    protected $template = null;
28
29
30
31
    /**
32
     * Set another template file to use.
33
     *
34
     * @param string $name of the template file.
35
     *
36
     * @return $this
37
     */
38
    public function setTemplate($name)
39
    {
40
        $this->template = $name;
41
        return $this;
42
    }
43
44
45
46
    /**
47
     * Shortcut to set title.
48
     *
49
     * @param string $value of the variable.
50
     *
51
     * @return $this
52
     */
53
    public function setTitle($value)
54
    {
55
        return $this->setVariable("title", $value);
56
    }
57
58
59
60
    /**
61
     * Set a base title which is appended to the page title.
62
     *
63
     * @param string $value of the variable.
64
     *
65
     * @return $this
66
     */
67
    public function setBaseTitle($value)
68
    {
69
        return $this->setVariable("title_append", $value);
70
    }
71
72
73
74
    /**
75
     * Set a variable which will be exposed to the template files during render.
76
     *
77
     * @param string $which variable to set value of.
78
     * @param mixed  $value of the variable.
79
     *
80
     * @return $this
81
     */
82
    public function setVariable($which, $value)
83
    {
84
        $this->data[$which] = $value;
85
        return $this;
86
    }
87
88
89
90
    /**
91
     * Append value to variable by making the variable an array.
92
     *
93
     * @param string $which variable to set value of.
94
     * @param mixed  $value of the variable.
95
     *
96
     * @return $this
97
     */
98
    public function appendToVariable($which, $value)
99
    {
100
        $this->data[$which][] = $value;
101
        return $this;
102
    }
103
104
105
106
    /**
107
     * Add frontmatter to be exposed to theme template file.
108
     *
109
     * @param array|null $matter to add.
110
     *
111
     * @return $this
112
     */
113
    public function addFrontmatter($matter)
114
    {
115
        $this->data = array_merge($this->data, $matter);
116
        return $this;
117
    }
118
119
120
121
    /**
122
     * Get a value of a variable which will be exposed to the template files
123
     * during render.
124
     *
125
     * @param string $which variable to get value of.
126
     *
127
     * @return mixed as value of variable, or null if value is not set.
128
     */
129
    public function getVariable($which)
130
    {
131
        if (isset($this->data[$which])) {
132
            return $this->data[$which];
133
        } elseif (isset($this->config["data"])) {
134
            return $this->config["data"][$which];
135
        }
136
137
        return null;
138
    }
139
140
141
142
    /**
143
     * Add a stylesheet.
144
     *
145
     * @param string $uri to add.
146
     *
147
     * @return $this
148
     */
149
    public function addStylesheet($uri)
150
    {
151
        $this->config["view"]["data"]["stylesheets"][] = $uri;
152
        return $this;
153
    }
154
155
156
157
    /**
158
     * Add a javascript asset.
159
     *
160
     * @param string $uri to add.
161
     *
162
     * @return $this
163
     */
164
    public function addJavaScript($uri)
165
    {
166
        $this->config["view"]["data"]["javascript_include"][] = $uri;
167
        return $this;
168
    }
169
170
171
172
    /**
173
     * Set/clear a key/value from the configuration file.
174
     *
175
     * @param string $uri to add.
0 ignored issues
show
There is no parameter named $uri. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
176
     *
177
     * @return $this
178
     */
179
    public function setConfigKey($key, $value)
180
    {
181
        $this->config["view"]["data"][$key] = $value;
182
        return $this;
183
    }
184
185
186
187
    /**
188
     * Render the theme by applying the variables onto the template files.
189
     *
190
     * @return void
191
     */
192
    public function render()
193
    {
194
        // Create views for regions, from config-file
195
        if (isset($this->config["views"])) {
196
            foreach ($this->config["views"] as $view) {
197
                $this->di->views->add($view);
198
            }
199
        }
200
201
        // Get default view to start render from
202
        $defaultData = [
203
            "currentRoute" => "route-" . str_replace("/", "-", $this->di->get("request")->getRoute()),
204
        ];
205
        $view = $this->config["view"];
206
207
        $view["data"] = array_merge_recursive($defaultData, $this->data, $view["data"]);
208
209
        if (isset($this->template)) {
210
            $view["template"] = $this->template;
211
        }
212
213
        // Get the path to the view template file
214
        $view["template"] = $this->di->get("views")->getTemplateFile($view["template"]);
215
216
        // Send response headers, if any.
217
        $this->di->get("response")->sendHeaders();
218
219
        // Execute the default view
220
        $start = $this->di->get("view");
221
        $start->setDI($this->di);
222
        $start->set($view);
223
        $start->render();
224
    }
225
}
226