Issues (30)

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 (8 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\User;
12
use \Anax\User\HTMLForm\UpdateForm;
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
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...
37
     *
38
     * @throws Exception
39
     *
40
     * @return void
41
     */
42
    public function getIndex()
43
    {
44
        $session = $this->di->get("session");
45 View Code Duplication
        if ($session->has("username")) {
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...
46
            $user = new User();
47
            $user->setDb($this->di->get("db"));
48
            $title      = "Profile";
49
            $view       = $this->di->get("view");
50
            $pageRender = $this->di->get("pageRender");
51
52
            $data = [
53
                "content" => $user->getUserData($session->get("username")),
54
            ];
55
56
            $view->add("user/profile", $data);
57
58
            $pageRender->renderPage(["title" => $title]);
59
        } else {
60
            $this->di->get("response")->redirect("user/login");
61
        }
62
    }
63
64
65
66
    /**
67
     * Description.
68
     *
69
     * @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...
70
     *
71
     * @throws Exception
72
     *
73
     * @return void
74
     */
75 View Code Duplication
    public function getPostLogin()
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...
76
    {
77
        $title      = "Login";
78
        $view       = $this->di->get("view");
79
        $pageRender = $this->di->get("pageRender");
80
        $form       = new UserLoginForm($this->di);
81
82
        $form->check();
83
84
        $data = [
85
            "content" => $form->getHTML(),
86
        ];
87
88
        $view->add("login/login", $data);
89
90
        $pageRender->renderPage(["title" => $title]);
91
    }
92
93
94
95
    /**
96
     * Description.
97
     *
98
     * @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...
99
     *
100
     * @throws Exception
101
     *
102
     * @return void
103
     */
104 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...
105
    {
106
        $title      = "A create user page";
107
        $view       = $this->di->get("view");
108
        $pageRender = $this->di->get("pageRender");
109
        $form       = new CreateUserForm($this->di);
110
111
        $form->check();
112
113
        $data = [
114
            "content" => $form->getHTML(),
115
        ];
116
117
        $view->add("default2/article", $data);
118
119
        $pageRender->renderPage(["title" => $title]);
120
    }
121
122
    /**
123
     * Handler with form to update an item.
124
     *
125
     * @return void
126
     */
127 View Code Duplication
    public function getPostUpdateUser($id)
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...
128
    {
129
        $title      = "Updatera användare";
130
        $view       = $this->di->get("view");
131
        $pageRender = $this->di->get("pageRender");
132
        $form       = new UpdateForm($this->di, $id);
133
134
        $form->check();
135
136
        $data = [
137
            "form" => $form->getHTML(),
138
        ];
139
140
        $view->add("user/update", $data);
141
142
        $pageRender->renderPage(["title" => $title]);
143
    }
144
145
    /**
146
     * Logout the user
147
     *
148
     * @return void
149
     */
150
    public function logoutUser()
151
    {
152
        $this->di->get("session")->destroy();
153
        $this->di->get("response")->redirect("user/login");
154
    }
155
156
    /**
157
     * Render admin page with all users
158
     *
159
     * @return void
160
     */
161
    public function getAdminIndex()
162
    {
163 View Code Duplication
        if ($this->di->get("session")->has("admin")) {
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...
164
            $title      = "Admin";
165
            $user       = new User();
166
            $user->setDb($this->di->get("db"));
167
            $view       = $this->di->get("view");
168
            $pageRender = $this->di->get("pageRender");
169
170
171
            $data = [
172
                "users" => $user->findAll(),
173
            ];
174
175
            $view->add("user/admin", $data);
176
177
            $pageRender->renderPage(["title" => $title]);
178
        } else {
179
            $this->di->get("response")->redirect("user/profile");
180
        }
181
    }
182
183
    /**
184
     * Delete a user
185
     *
186
     *@var integer id of user to delete
187
     *
188
     * @return void
189
     */
190
    public function adminDeleteUser($id)
191
    {
192
        if ($this->di->get("session")->has("admin")) {
193
            $user       = new User();
194
            $user->setDb($this->di->get("db"));
195
            $user->delete($id);
196
            $this->di->get("response")->redirect("user/admin");
197
        } else {
198
            $this->di->get("response")->redirect("user/profile");
199
        }
200
    }
201
}
202