Issues (63)

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.

Security/User/LdapUser.php (3 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
 * This file is part of the LdapToolsBundle package.
4
 *
5
 * (c) Chad Sikorra <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace LdapTools\Bundle\LdapToolsBundle\Security\User;
12
13
use LdapTools\Object\LdapObject;
14
use Symfony\Component\Security\Core\User\AdvancedUserInterface;
15
16
/**
17
 * Represents a user from LDAP.
18
 *
19
 * @author Chad Sikorra <[email protected]>
20
 */
21
class LdapUser extends LdapObject implements LdapUserInterface, AdvancedUserInterface, \Serializable
0 ignored issues
show
Deprecated Code introduced by
The interface Symfony\Component\Securi...r\AdvancedUserInterface has been deprecated with message: since Symfony 4.1

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
22
{
23
    /**
24
     * @var array The Symfony roles for this user.
25
     */
26
    protected $roles = [];
27
28
    public function __construct()
29
    {
30
        parent::__construct([]);
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function getSalt()
37
    {
38
        return null;
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public function getPassword()
45
    {
46
        return null;
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function eraseCredentials()
53
    {
54
        return null;
55
    }
56
57
    /**
58
     * {@inheritdoc}
59
     */
60
    public function getRoles()
61
    {
62
        return $this->roles;
63
    }
64
65
    /**
66
     * {@inheritdoc}
67
     */
68
    public function setRoles(array $roles)
69
    {
70
        $this->roles = [];
71
        foreach ($roles as $role) {
72
            $this->addRole($role);
73
        }
74
75
        return $this;
76
    }
77
78
    /**
79
     * {@inheritdoc}
80
     */
81 View Code Duplication
    public function addRole($role)
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...
82
    {
83
        $role = strtoupper($role);
84
85
        if (!in_array($role, $this->roles)) {
86
            $this->roles[] = $role;
87
        }
88
89
        return $this;
90
    }
91
92
    /**
93
     * {@inheritdoc}
94
     */
95 View Code Duplication
    public function removeRole($role)
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...
96
    {
97
        $role = strtoupper($role);
98
99
        if (in_array($role, $this->roles)) {
100
            $this->roles = array_diff($this->roles, [$role]);
101
        }
102
103
        return $this;
104
    }
105
106
    /**
107
     * {@inheritdoc}
108
     */
109
    public function getUsername()
110
    {
111
        return $this->get('username');
112
    }
113
114
    /**
115
     * {@inheritdoc}
116
     */
117
    public function setUsername($username)
118
    {
119
        return $this->set('username', $username);
120
    }
121
122
    /**
123
     * {@inheritdoc}
124
     */
125
    public function isAccountNonExpired()
126
    {
127
        if (!$this->has('accountExpirationDate') || $this->get('accountExpirationDate') === false) {
128
            $result = true;
129
        } elseif ($this->get('accountExpirationDate') instanceof \DateTime) {
130
            $result = ($this->get('accountExpirationDate') > new \DateTime());
131
        } else {
132
            $result = (bool) $this->get('accountExpirationDate');
133
        }
134
135
        return $result;
136
    }
137
138
    /**
139
     * {@inheritdoc}
140
     */
141
    public function isAccountNonLocked()
142
    {
143
        return $this->has('locked') ? !$this->get('locked') : true;
144
    }
145
146
    /**
147
     * {@inheritdoc}
148
     */
149
    public function isCredentialsNonExpired()
150
    {
151
        return $this->has('passwordMustChange') ? !$this->get('passwordMustChange') : true;
152
    }
153
154
    /**
155
     * {@inheritdoc}
156
     */
157
    public function isEnabled()
158
    {
159
        return $this->has('enabled') ? $this->get('enabled') : true;
160
    }
161
162
    /**
163
     * {@inheritdoc}
164
     */
165
    public function getLdapGuid()
166
    {
167
        return $this->get('guid');
168
    }
169
170
    /**
171
     * {@inheritdoc}
172
     */
173
    public function setLdapGuid($guid)
174
    {
175
        return $this->set('guid', $guid);
176
    }
177
178
    /**
179
     * {@inheritdoc}
180
     */
181
    public function getGroups()
182
    {
183
        return $this->has('groups') ? $this->get('groups') : [];
184
    }
185
186
    /**
187
     * {@inheritdoc}
188
     */
189
    public function serialize()
190
    {
191
        return serialize([
192
            $this->attributes,
193
            $this->type,
194
            $this->roles
195
        ]);
196
    }
197
198
    /**
199
     * {@inheritdoc}
200
     */
201
    public function unserialize($serialized)
202
    {
203
        list($this->attributes, $this->type, $this->roles) = unserialize($serialized);
204
    }
205
206
    /**
207
     * @return string
208
     */
209
    public function __toString()
210
    {
211
        return $this->getUsername();
212
    }
213
}
214