Issues (458)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  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.
  Header Injection
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 (4 issues)

Labels
Severity
1
<?php
2
3
namespace Alvo\User;
4
5
use \Anax\Database\ActiveRecordModel;
6
use \Anax\DI\InjectionAwareInterface;
7
use \Anax\DI\InjectionAwareTrait;
8
9
/**
10
 * A database driven model.
11
 */
12
class User extends ActiveRecordModel implements InjectionAwareInterface
13
{
14
    use InjectionAwareTrait;
15
    use UserUtils;
16
17
18
19
    /**
20
     * @var string $tableName name of the database table.
21
     */
22
    protected $tableName = "User";
23
24
    /**
25
     * Columns in the table.
26
     *
27
     * @var integer $id primary key auto incremented.
28
     */
29
    public $id;
30
    public $email;
31
    public $password;
32
    public $created;
33
    public $updated;
34
    public $deleted;
35
    public $admin;
36
37
38
39
    /**
40
     * Set the password.
41
     *
42
     * @param string $password the password to use.
43
     *
44
     * @return void
45
     */
46 1
    public function setPassword($password)
47
    {
48 1
        $this->password = password_hash($password, PASSWORD_DEFAULT);
0 ignored issues
show
The constant Alvo\User\PASSWORD_DEFAULT was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
The function password_hash was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

48
        $this->password = /** @scrutinizer ignore-call */ password_hash($password, PASSWORD_DEFAULT);
Loading history...
49 1
    }
50
51
52
53
    /**
54
     * Verify the email and the password, if successful the object contains
55
     * all details from the database row.
56
     *
57
     * @param string $email  email to check.
58
     * @param string $password the password to use.
59
     *
60
     * @return boolean true if email and password matches, else false.
61
     */
62 1
    public function verifyPassword($email, $password)
63
    {
64 1
        $this->find("email", $email);
65 1
        return password_verify($password, $this->password);
0 ignored issues
show
The function password_verify was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

65
        return /** @scrutinizer ignore-call */ password_verify($password, $this->password);
Loading history...
66
    }
67
68
69
70 1
    public function getUser($column = null, $param = null)
71
    {
72 1
        if (!$column) {
73 1
            $column = "id";
74
        }
75
76 1
        if (!$param) {
77 1
            $param = $this->di->get("session")->get("userId");
78
        }
79
80 1
        return $this->find($column, $param);
81
    }
82
83
84
85 1
    public function getAllUsers()
86
    {
87 1
        return $this->db
88 1
            ->connect()
89 1
            ->select()
90 1
            ->from($this->tableName)
91 1
            ->where("deleted is NULL")
92 1
            ->execute()
93 1
            ->fetchAllClass(get_class($this));
94
    }
95
96
97
98 1
    public function delete($id = null)
99
    {
100 1
        $id = $id ?: $this->id;
101
102 1
        $comment = new User();
103 1
        $comment->setDb($this->db);
104 1
        $comment->find("id", $id);
105 1
        $comment->deleted = date("Y-m-d H:i:s");
106 1
        $comment->save();
107 1
    }
108
109
110
111
    /**
112
     * Get either a Gravatar URL or complete image tag for a specified email address.
113
     *
114
     * @param string $email The email address
115
     * @param string $s Size in pixels, defaults to 80px [ 1 - 2048 ]
116
     * @param string $d Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ]
117
     * @param string $r Maximum rating (inclusive) [ g | pg | r | x ]
118
     * @param boole $img True to return a complete IMG tag False for just the URL
0 ignored issues
show
The type Alvo\User\boole was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
119
     * @param array $atts Optional, additional key/value attributes to include in the IMG tag
120
     * @return String containing either just a URL or a complete image tag
121
     * @source https://gravatar.com/site/implement/images/php/
122
     */
123 1
    public function getGravatar($email = null, $sss = 80, $ddd = 'mm', $rrr = 'g', $img = false, $atts = array())
124
    {
125 1
        $email = $email ?? $this->email;
126 1
        $url = 'https://www.gravatar.com/avatar/';
127 1
        $url .= md5(strtolower(trim($email)));
128 1
        $url .= "?s=$sss&d=$ddd&r=$rrr";
129 1
        if ($img) {
130
            $url = '<img src="' . $url . '"';
131
            foreach ($atts as $key => $val) {
132
                $url .= ' ' . $key . '="' . $val . '"';
133
            }
134
            $url .= ' />';
135
        }
136 1
        return $url;
137
    }
138
}
139