Issues (46)

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/User/UserController.php (7 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
namespace Anax\User;
4
5
use \Anax\Configure\ConfigureInterface;
6
use \Anax\Configure\ConfigureTrait;
7
use \Anax\DI\InjectionAwareInterface;
8
use \Anax\Di\InjectionAwareTrait;
9
use \Anax\User\HTMLForm\UserLoginForm;
10
use \Anax\User\HTMLForm\CreateUserForm;
11
use \Anax\User\HTMLForm\EditUserForm;
12
use \Anax\User\HTMLForm\DeleteUserForm;
13
14
/**
15
 * A controller class.
16
 */
17
class UserController implements
18
    ConfigureInterface,
19
    InjectionAwareInterface
20
{
21
    use ConfigureTrait,
22
        InjectionAwareTrait;
23
24
25
26
    /**
27
     * @var $data description
28
     */
29
    //private $data;
30
31
32
33
    /**
34
     * Description.
35
     *
36
     * @param datatype $variable Description
37
     *
38
     * @throws Exception
39
     *
40
     * @return void
41
     */
42
    // public function getIndex()
43
    // {
44
    //     $title      = "A index page";
45
    //     $view       = $this->di->get("view");
46
    //     $pageRender = $this->di->get("pageRender");
47
    //
48
    //     $data = [
49
    //         "content" => "An index page",
50
    //     ];
51
    //
52
    //     $view->add("default2/article", $data);
53
    //
54
    //     $pageRender->renderPage(["title" => $title]);
55
    // }
56
57
58
59
    /**
60
     * Description.
61
     *
62
     * @param datatype $variable Description
0 ignored issues
show
There is no parameter named $variable. 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...
63
     *
64
     * @throws Exception
65
     *
66
     * @return void
67
     */
68
    public function getPostLogin()
69
    {
70
        $title      = "A login page";
71
        $view       = $this->di->get("view");
72
        $pageRender = $this->di->get("pageRender");
73
        $form       = new UserLoginForm($this->di);
74
75
        $form->check();
76
77
78
        $data = [
79
            "content" => $form->getHTML(),
80
        ];
81
82
        $view->add("default2/article", $data);
83
84
        $pageRender->renderPage(["title" => $title]);
85
    }
86
87
88
89
    /**
90
     * Description.
91
     *
92
     * @param datatype $variable Description
0 ignored issues
show
There is no parameter named $variable. 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...
93
     *
94
     * @throws Exception
95
     *
96
     * @return void
97
     */
98 View Code Duplication
    public function getPostCreateUser()
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...
99
    {
100
        $title      = "A create user page";
101
        $view       = $this->di->get("view");
102
        $pageRender = $this->di->get("pageRender");
103
        $form       = new CreateUserForm($this->di);
104
105
        $form->check();
106
107
        $data = [
108
            "content" => $form->getHTML(),
109
        ];
110
111
        $view->add("default2/article", $data);
112
113
        $pageRender->renderPage(["title" => $title]);
114
    }
115
116
    /**
117
     * Description.
118
     *
119
     * @param datatype $variable Description
0 ignored issues
show
There is no parameter named $variable. 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...
120
     *
121
     * @throws Exception
122
     *
123
     * @return void
124
     */
125
    public function editAllUsers()
126
    {
127
        $acronym = $this->di->session->get("user");
128
        $role = $this->di->get("commentController")->getRole($acronym);
129
        if ($role != 10) {
130
            echo "Du har ej tillgĂĄng till sidan.";
131
            return false;
132
        }
133
134
        $title      = "An edit all users page";
135
        $view       = $this->di->get("view");
136
        $pageRender = $this->di->get("pageRender");
137
        $form       = new DeleteUserForm($this->di);
138
139
        $form->check();
140
141
        $data = [
142
            "content" => $form->getHTML(),
143
        ];
144
145
        $view->add("default2/article", $data);
146
147
        $pageRender->renderPage(["title" => $title]);
148
    }
149
150
    /**
151
     * Description.
152
     *
153
     * @param datatype $variable Description
0 ignored issues
show
There is no parameter named $variable. 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...
154
     *
155
     * @throws Exception
156
     *
157
     * @return void
158
     */
159
    public function showProfile()
160
    {
161
        $acronym = $this->di->session->get("user");
162
        $user = new User();
163
        $user->setDb($this->di->get("db"));
164
        $user = $user->find("acronym", $acronym);
165
166
        if (isset($user->email)) {
167
            $this->editUser($user->id);
168
        }
169
        // if no user is logged in:
170
171
        $val = $this->di->get("url")->createRelative("user/login");
172
        $view       = $this->di->get("view");
173
        $pageRender = $this->di->get("pageRender");
174
        $data = [
175
            "content" => "<h2><a href='$val'>Logga in</a> för att se din profil.</h2>"
176
        ];
177
178
        $view->add("default2/article", $data);
179
        $pageRender->renderPage(["title" => "Ej tillgĂĄng"]);
180
    }
181
182
    /**
183
     * Description.
184
     *
185
     * @param datatype $variable Description
0 ignored issues
show
There is no parameter named $variable. 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...
186
     *
187
     * @throws Exception
188
     *
189
     * @return void
190
     */
191
    public function editUser($id)
192
    {
193
        $title      = "Redigera användare";
194
        $view       = $this->di->get("view");
195
        $pageRender = $this->di->get("pageRender");
196
197
        $user = new User;
198
        $user->setDb($this->di->get("db"));
199
        $user = $user->find("id", $id);
200
201
        $data = [
202
            "title" => $title,
203
            "email" => $user->email,
204
            "acronym" => $user->acronym,
205
            "gravatar" => $user->gravatar,
206
            "role" => $user->role,
207
        ];
208
209
        $form       = new EditUserForm($this->di, $user->acronym);
210
        $form->check();
211
212
        $formdata = [
213
            "content" => $form->getHTML(),
214
        ];
215
216
        $view->add("take1/profile", $data);
217
        $view->add("default2/article", $formdata);
218
219
        $pageRender->renderPage(["title" => $title]);
220
        return true;
221
    }
222
223
    /**
224
     * Description.
225
     *
226
     * @param datatype $variable Description
0 ignored issues
show
There is no parameter named $variable. 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...
227
     *
228
     * @throws Exception
229
     *
230
     * @return void
231
     */
232
    public function editOneUser($id)
233
    {
234
        $title      = "Redigera en användare";
235
        $view       = $this->di->get("view");
236
        $pageRender = $this->di->get("pageRender");
237
238
        $user = new User;
239
        $user->setDb($this->di->get("db"));
240
        $user = $user->find("id", $id);
241
242
        // $data = [
243
        //     "title" => $title,
244
        //     "email" => $user->email,
245
        //     "acronym" => $user->acronym,
246
        //     "gravatar" => $user->gravatar,
247
        // ];
248
249
        $form       = new EditUserForm($this->di, $user->acronym);
250
        $form->check();
251
252
        $formdata = [
253
            "content" => $form->getHTML(),
254
        ];
255
256
        $view->add("default2/article", $formdata);
257
258
        $pageRender->renderPage(["title" => $title]);
259
        return true;
260
    }
261
}
262