Issues (24)

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 (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
namespace Oenstrom\User;
4
5
use \Anax\DI\InjectionAwareInterface;
6
use \Anax\DI\InjectionAwareTrait;
7
use \Oenstrom\User\HTMLForm\LoginForm;
8
use \Oenstrom\User\HTMLForm\RegisterForm;
9
use \Oenstrom\User\HTMLForm\ProfileForm;
10
11
// use \Anax\Book\HTMLForm\UpdateForm;
12
/**
13
 * A User controller class.
14
 */
15
class UserController implements InjectionAwareInterface
16
{
17
    use InjectionAwareTrait;
18
19
20
21
    /**
22
     * @var $data description
23
     */
24
    //private $data;
25
26
27
28
    /**
29
     * Handler with form to register an user.
30
     *
31
     * @return void
32
     */
33 1 View Code Duplication
    public function getPostRegister()
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...
34
    {
35 1
        $title       = "Sign up";
36 1
        $view        = $this->di->get("view");
37 1
        $pageRender  = $this->di->get("pageRender");
38 1
        $form        = new RegisterForm($this->di);
39
40 1
        $form->check();
41
42
        $data = [
43 1
            "form" => $form->getHTML(["use_buttonbar" => false]),
44 1
            "title" => $title,
45 1
        ];
46 1
        $view->add("user/user-register", $data);
47 1
        $pageRender->renderPage(["title" => $title]);
48 1
    }
49
50
51
52
    /**
53
     * Handler with form to login an user.
54
     *
55
     * @return void
56
     */
57 1 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...
58
    {
59 1
        $title       = "Sign in";
60 1
        $view        = $this->di->get("view");
61 1
        $pageRender  = $this->di->get("pageRender");
62 1
        $form        = new LoginForm($this->di);
63
64 1
        $form->check();
65
66
        $data = [
67 1
            "form" => $form->getHTML(["use_fieldset" => false, "use_buttonbar" => false]),
68 1
        ];
69 1
        $view->add("user/user-login", $data);
70 1
        $pageRender->renderPage(["title" => $title]);
71 1
    }
72
73
74
75
    /**
76
     * Handler to logout an user.
77
     *
78
     * @return void
79
     */
80 1
    public function getLogout()
81
    {
82 1
        $session = $this->di->get("session");
83 1
        $session->destroy();
84 1
        $this->di->get("response")->redirect("");
85 1
    }
86
87
88
89
    /**
90
     * Get all users.
91
     */
92 1
    public function getUsers()
93
    {
94 1
        $title       = "Users";
95 1
        $view        = $this->di->get("view");
96 1
        $pageRender  = $this->di->get("pageRender");
97 1
        $user        = $this->di->get("user");
98
99 1
        $view->add("user/user-list", ["users" => $user->findAll()]);
100 1
        return $pageRender->renderPage(["title" => $title]);
101
    }
102
103
104
105
    /**
106
     * Handler with form to update an user profile.
107
     *
108
     * @return void
109
     */
110 1
    public function getPostProfile()
111
    {
112 1
        $title       = "Your profile";
113 1
        $view        = $this->di->get("view");
114 1
        $pageRender  = $this->di->get("pageRender");
115 1
        $auth        = $this->di->get("authHelper");
116 1
        $form        = new ProfileForm($this->di);
117
118 1
        $form->check();
119
120
121
        $data = [
122 1
            "form" => $form->getHTML(["use_buttonbar" => false]),
123 1
            "gravatar" => $this->getGravatar($this->di->get("session")->get("email"), true, 256)
0 ignored issues
show
true is of type boolean, but the function expects a false|object<Oenstrom\User\boole>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
124 1
        ];
125
126 1
        if ($auth->isAdmin()) {
127 1
            $view->add("user/admin/admin-links", []);
128 1
        }
129 1
        $view->add("user/profile", $data);
130 1
        $pageRender->renderPage(["title" => $title]);
131 1
    }
132
133
134
135
    /**
136
     * Get either a Gravatar URL or complete image tag for a specified email address.
137
     *
138
     * @param string $email The email address
139
     * @param boole $img True to return a complete IMG tag False for just the URL
140
     * @param string $size Size in pixels, defaults to 80px [ 1 - 2048 ]
141
     * @param string $default Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ]
142
     * @param string $rating Maximum rating (inclusive) [ g | pg | r | x ]
143
     * @param array $atts Optional, additional key/value attributes to include in the IMG tag
144
     * @return String containing either just a URL or a complete image tag
145
     * @source https://gravatar.com/site/implement/images/php/
146
     */
147 2
    public function getGravatar($email, $img = false, $size = 80, $default = 'mm', $rating = 'g', $atts = array())
148
    {
149 2
        $url = 'https://www.gravatar.com/avatar/';
150 2
        $url .= md5(strtolower(trim($email)));
151 2
        $url .= "?s=$size&d=$default&r=$rating";
152 2 View Code Duplication
        if ($img) {
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...
153 2
            $url = '<img src="' . $url . '" alt="' . $email . '"';
154 2
            foreach ($atts as $key => $val) {
155 1
                $url .= ' ' . $key . '="' . $val . '"';
156 2
            }
157 2
            $url .= ' />';
158 2
        }
159 2
        return $url;
160
    }
161
}
162