Issues (12)

Security Analysis    no request data  

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/User.php (2 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
namespace CJ\User;
3
4
use \Anax\Database\ActiveRecordModel;
5
6
/**
7
 * A database driven model.
8
 */
9
class User extends ActiveRecordModel
10
{
11
    /**
12
     * @var string $tableName name of the database table.
13
     */
14
    protected $tableName = "User";
15
16
    /**
17
     * Columns in the table.
18
     *
19
     * @var integer $id primary key auto incremented.
20
     */
21
    public $id;
22
    public $mail;
23
    public $password;
24
    public $created;
25
    public $updated;
26
    public $deleted;
27
    public $active;
28
29
30
    /**
31
    * Creating $session var for inject
32
    */
33
    private $session;
34
35
    /**
36
    *   Init the class with session and database
37
    */
38 10
    public function init($db, $session)
39
    {
40 10
        $this->session = $session;
41 10
        $this->setDb($db);
42 10
    }
43
44
    /**
45
     * Set the password.
46
     *
47
     * @param string $password the password to use.
48
     *
49
     * @return void
50
     */
51 2
    public function setPassword($password)
52
    {
53 2
        $this->password = password_hash($password, PASSWORD_DEFAULT);
54 2
    }
55
56
57
    /**
58
     * Verify the acronym and the password, if successful the object contains
59
     * all details from the database row.
60
     *
61
     * @param string $acronym  acronym to check.
0 ignored issues
show
There is no parameter named $acronym. 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...
62
     * @param string $password the password to use.
63
     *
64
     * @return boolean true if acronym and password matches, else false.
65
     */
66 1
    public function verifyPassword($mail, $password)
67
    {
68 1
        $this->find("mail", $mail);
69 1
        return password_verify($password, $this->password);
70
    }
71
72
    /*
73
    * Get all users.
74
    */
75 1
    public function getAllUsers()
76
    {
77 1
        return $this->findAll();
78
    }
79
80
81
    /*
82
    * Get all users.
83
    */
84 2
    public function deleteUser($id)
85
    {
86 2
        $this->find("id", $id);
87 2
        $this->delete();
88 2
    }
89
90
91
    /*
92
    * Get a user based on ID
93
    */
94 1
    public function getUser($id)
95
    {
96 1
        return $this->find("id", $id);
97
    }
98
99
    /*
100
    * Get a user based on ID
101
    */
102 2
    public function isLoggedIn()
103
    {
104 2
        return $this->session->has("user");
105
    }
106
107
108
    /*
109
    * Get a user based on ID
110
    */
111 2
    public function getLoggedInUserId()
112
    {
113 2
        return $this->session->get("user");
114
    }
115
116
117
    /*
118
    * Get logged in user
119
    * @return user class
120
    */
121 1
    public function getLoggedInUser()
122
    {
123 1
        if ($this->session->has("user")) {
124 1
            return $this->find("id", $this->session->get("user"));
125
        }
126 1
    }
127
128
129 1
    public function getUserImg($mail, $classes = "", $size = 125)
130
    {
131 1
        $hash = md5($mail);
132
133 1
        $html = "<img src='https://www.gravatar.com/avatar/$hash?s=$size&default=mm' class='$classes'>";
134 1
        return $html;
135
    }
136
137
138
    /*
139
    * Return true is user is admin
140
    */
141 1
    public function isUserAdmin()
142
    {
143 1
        if ($this->isLoggedIn()) {
144 1
            $id = $this->getLoggedInUserId();
145
146 1
            $this->find("id", $id);
147 1
            if ($this->userType == "admin") {
0 ignored issues
show
The property userType does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
148 1
                return true;
149
            }
150 1
        }
151
152 1
        return false;
153
    }
154
}
155