Issues (18)

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/ZfcUser/Authentication/Storage/Db.php (1 issue)

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 ZfcUser\Authentication\Storage;
4
5
use Zend\Authentication\Storage;
6
use Zend\Authentication\Storage\StorageInterface;
7
use Zend\ServiceManager\ServiceManagerAwareInterface;
8
use Zend\ServiceManager\ServiceManager;
9
use ZfcUser\Mapper\UserInterface as UserMapper;
10
11
class Db implements Storage\StorageInterface, ServiceManagerAwareInterface
12
{
13
    /**
14
     * @var StorageInterface
15
     */
16
    protected $storage;
17
18
    /**
19
     * @var UserMapper
20
     */
21
    protected $mapper;
22
23
    /**
24
     * @var mixed
25
     */
26
    protected $resolvedIdentity;
27
28
    /**
29
     * @var ServiceManager
30
     */
31
    protected $serviceManager;
32
33
    /**
34
     * Returns true if and only if storage is empty
35
     *
36
     * @throws \Zend\Authentication\Exception\InvalidArgumentException If it is impossible to determine whether
37
     * storage is empty or not
38
     * @return boolean
39
     */
40
    public function isEmpty()
41
    {
42
        if ($this->getStorage()->isEmpty()) {
43
            return true;
44
        }
45
        $identity = $this->read();
46
        if ($identity === null) {
47
            $this->clear();
48
            return true;
49
        }
50
51
        return false;
52
    }
53
54
    /**
55
     * Returns the contents of storage
56
     *
57
     * Behavior is undefined when storage is empty.
58
     *
59
     * @throws \Zend\Authentication\Exception\InvalidArgumentException If reading contents from storage is impossible
60
     * @return mixed
61
     */
62
    public function read()
63
    {
64
        if (null !== $this->resolvedIdentity) {
65
            return $this->resolvedIdentity;
66
        }
67
68
        $identity = $this->getStorage()->read();
69
70
        if (is_int($identity) || is_scalar($identity)) {
71
            $identity = $this->getMapper()->findById($identity);
72
        }
73
74
        if ($identity) {
75
            $this->resolvedIdentity = $identity;
76
        } else {
77
            $this->resolvedIdentity = null;
78
        }
79
80
        return $this->resolvedIdentity;
81
    }
82
83
    /**
84
     * Writes $contents to storage
85
     *
86
     * @param  mixed $contents
87
     * @throws \Zend\Authentication\Exception\InvalidArgumentException If writing $contents to storage is impossible
88
     * @return void
89
     */
90
    public function write($contents)
91
    {
92
        $this->resolvedIdentity = null;
93
        $this->getStorage()->write($contents);
94
    }
95
96
    /**
97
     * Clears contents from storage
98
     *
99
     * @throws \Zend\Authentication\Exception\InvalidArgumentException If clearing contents from storage is impossible
100
     * @return void
101
     */
102
    public function clear()
103
    {
104
        $this->resolvedIdentity = null;
105
        $this->getStorage()->clear();
106
    }
107
108
    /**
109
     * getStorage
110
     *
111
     * @return Storage\StorageInterface
112
     */
113
    public function getStorage()
114
    {
115
        if (null === $this->storage) {
116
            $this->setStorage(new Storage\Session);
117
        }
118
        return $this->storage;
119
    }
120
121
    /**
122
     * setStorage
123
     *
124
     * @param Storage\StorageInterface $storage
125
     * @access public
126
     * @return Db
127
     */
128
    public function setStorage(Storage\StorageInterface $storage)
129
    {
130
        $this->storage = $storage;
131
        return $this;
132
    }
133
134
    /**
135
     * getMapper
136
     *
137
     * @return UserMapper
138
     */
139
    public function getMapper()
140
    {
141
        if (null === $this->mapper) {
142
            $this->mapper = $this->getServiceManager()->get('zfcuser_user_mapper');
143
        }
144
        return $this->mapper;
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->mapper; of type object|array adds the type array to the return on line 144 which is incompatible with the return type documented by ZfcUser\Authentication\Storage\Db::getMapper of type ZfcUser\Mapper\UserInterface.
Loading history...
145
    }
146
147
    /**
148
     * setMapper
149
     *
150
     * @param UserMapper $mapper
151
     * @return Db
152
     */
153
    public function setMapper(UserMapper $mapper)
154
    {
155
        $this->mapper = $mapper;
156
        return $this;
157
    }
158
159
    /**
160
     * Retrieve service manager instance
161
     *
162
     * @return ServiceManager
163
     */
164
    public function getServiceManager()
165
    {
166
        return $this->serviceManager;
167
    }
168
169
    /**
170
     * Set service manager instance
171
     *
172
     * @param ServiceManager $locator
173
     * @return void
174
     */
175
    public function setServiceManager(ServiceManager $serviceManager)
176
    {
177
        $this->serviceManager = $serviceManager;
178
    }
179
}
180