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.

  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/Palladium/Service/Search.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Palladium\Service;
4
5
6
/**
7
 * Class for finding identities based on various conditions
8
 */
9
10
use Palladium\Entity as Entity;
11
use Palladium\Exception\IdentityNotFound;
12
use Palladium\Repository\Identity as Repository;
13
use Psr\Log\LoggerInterface;
14
15
16
class Search
17
{
18
19
    private $repository;
20
    private $logger;
21
22
    /**
23
     * @param Repository $repository Repository for abstracting persistence layer structures
24
     * @param LoggerInterface $logger PSR-3 compatible logger
25
     */
26 38
    public function __construct(Repository $repository, LoggerInterface $logger)
27
    {
28 38
        $this->repository = $repository;
29 38
        $this->logger = $logger;
30 38
    }
31
32
33
    /**
34
     * Locates identity based on ID
35
     *
36
     * @throws IdentityNotFound if identity was not found
37
     */
38 2
    public function findIdentityById(int $identityId): Entity\Identity
39
    {
40 2
        $identity = new Entity\Identity;
41 2
        $identity->setId($identityId);
42
43 2
        $this->repository->load($identity, Entity\Identity::class);
44
45 2
        if ($identity->getAccountId() === null) {
46 1
            $this->logger->notice('identity not found', [
47
                'input' => [
48 1
                    'id' => $identityId,
49
                ],
50
            ]);
51
52 1
            throw new IdentityNotFound;
53
        }
54
55 1
        return $identity;
56
    }
57
58
59
    /**
60
     * Locates identity based on email address
61
     *
62
     * @throws IdentityNotFound if identity was not found
63
     */
64 13
    public function findStandardIdentityByIdentifier(string $identifier): Entity\StandardIdentity
65
    {
66 13
        $identity = new Entity\StandardIdentity;
67 13
        $identity->setIdentifier($identifier);
68
69 13
        $this->repository->load($identity);
70
71 13
        if ($identity->getId() === null) {
72 2
            $this->logger->notice('identity not found', [
73
                'input' => [
74 2
                    'identifier' => $identifier,
75
                ],
76
            ]);
77
78 2
            throw new IdentityNotFound;
79
        }
80
81 11
        return $identity;
82
    }
83
84
85 5
    public function findNonceIdentityByIdentifier(string $identifier): Entity\NonceIdentity
86
    {
87 5
        $identity = new Entity\NonceIdentity;
88 5
        $identity->setIdentifier($identifier);
89
90 5
        $this->repository->load($identity);
91
92 5
        if ($identity->getId() === null) {
93 2
            $this->logger->notice('identity not found', [
94
                'input' => [
95 2
                    'identifier' => $identifier,
96
                ],
97
            ]);
98
99 2
            throw new IdentityNotFound;
100
        }
101
102 3
        return $identity;
103
    }
104
105
106
    /**
107
     * @throws IdentityNotFound if identity was not found
108
     */
109 8
    public function findStandardIdentityByToken(string $token, int $action = Entity\Identity::ACTION_NONE): Entity\StandardIdentity
110
    {
111 8
        $entry = $this->findIdentityByToken($token, $action);
0 ignored issues
show
It seems like $action can also be of type null; however, parameter $action of Palladium\Service\Search::findIdentityByToken() does only seem to accept integer, maybe add an additional type check? ( Ignorable by Annotation )

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

111
        $entry = $this->findIdentityByToken($token, /** @scrutinizer ignore-type */ $action);
Loading history...
112
113 8
        if ($entry->getId() === null) {
114 4
            $this->logger->notice('identity not found', [
115
                'input' => [
116 4
                    'token' => $token,
117
                ],
118
            ]);
119
120 4
            throw new IdentityNotFound;
121
        }
122
123
124 4
        $identity = new Entity\StandardIdentity;
125 4
        $identity->setId($entry->getId());
126
127 4
        $this->repository->load($identity);
128
129 4
        return $identity;
130
    }
131
132
133
    /**
134
     * @throws IdentityNotFound if identity was not found
135
     * @throws \Palladium\Exception\InvalidToken
136
     */
137 8
     public function findIdentityByToken(string $token, int $action = Entity\Identity::ACTION_NONE): Entity\Identity
138
     {
139 8
         $identity = new Entity\Identity;
140
141 8
         $identity->setToken($token);
142 8
         $identity->setTokenAction($action);
143 8
         $identity->setTokenEndOfLife(time());
144
145 8
         $this->repository->load($identity);
146
147 8
         return $identity;
148
     }
149
150
    /**
151
     * @throws IdentityNotFound if identity was not found
152
     */
153 5
    public function findStandardIdentityById(int $identityId): Entity\StandardIdentity
154
    {
155 5
        $identity = new Entity\StandardIdentity;
156 5
        $identity->setId($identityId);
157
158 5
        $this->repository->load($identity);
159
160 5
        if ($identity->getAccountId() === null) {
161 1
            $this->logger->notice('identity not found', [
162
                'input' => [
163 1
                    'id' => $identityId,
164
                ],
165
            ]);
166
167 1
            throw new IdentityNotFound;
168
        }
169
170 4
        return $identity;
171
    }
172
173
174
    /**
175
     * @throws IdentityNotFound if identity was not found
176
     */
177 8
    public function findCookieIdentity(int $accountId, string $series): Entity\CookieIdentity
178
    {
179 8
        $cookie = new Entity\CookieIdentity;
180 8
        $cookie->setStatus(Entity\Identity::STATUS_ACTIVE);
181 8
        $cookie->setAccountId($accountId);
182 8
        $cookie->setSeries($series);
183
184 8
        $this->repository->load($cookie);
185
186 8
        if ($cookie->getId() === null) {
187 3
            $this->logger->notice('identity not found', [
188
                'input' => [
189 3
                    'account' => $cookie->getAccountId(),
190 3
                    'series' => $cookie->getSeries(),
191
                ],
192
            ]);
193
194 3
            throw new IdentityNotFound;
195
        }
196
197 7
        return $cookie;
198
    }
199
200
201 1
    public function findIdentitiesByAccountId(int $accountId, int $type = Entity\Identity::TYPE_ANY, int $status = Entity\Identity::STATUS_ACTIVE): Entity\IdentityCollection
202
    {
203 1
        $collection = new Entity\IdentityCollection;
204 1
        $collection->forAccountId($accountId);
205 1
        $collection->forType($type);
206
207 1
        return $this->fetchIdentitiesWithStatus($collection, $status);
208
    }
209
210
211 1
    public function findIdentitiesByParentId(int $parentId, int $status = Entity\Identity::STATUS_ACTIVE): Entity\IdentityCollection
212
    {
213 1
        $collection = new Entity\IdentityCollection;
214 1
        $collection->forParentId($parentId);
215
216 1
        return $this->fetchIdentitiesWithStatus($collection, $status);
217
    }
218
219
220 2
    private function fetchIdentitiesWithStatus(Entity\IdentityCollection $collection, int $status): Entity\IdentityCollection
221
    {
222 2
        $collection->forStatus($status);
223 2
        $this->repository->load($collection);
224
225 2
        return $collection;
226
    }
227
}
228